blob: 67b21b771f794b5868eae33500d7e2c692d208cc [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
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530408eHalStatus csrInitChannelsForCC(tpAniSirGlobal pMac, driver_load_type init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530409{
410 eHalStatus status = eHAL_STATUS_SUCCESS;
411 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530412 tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN];
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530413
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530414 /* In case of driver load ; driver need to get channel
415 * list with default Countrycode.
416 * In case of SSR; driver need to get channel list
417 * with old country code. 0 is for init and
418 * 1 is for reinit
419 */
420 switch (init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530421 {
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530422 case INIT:
423 vos_mem_copy(cc, pMac->scan.countryCodeDefault,
424 WNI_CFG_COUNTRY_CODE_LEN);
425 if (!('0' == cc[0] &&
426 '0' == cc[1]))
427 {
428 csrGetRegulatoryDomainForCountry(pMac, cc,
429 &regId, COUNTRY_NV);
430 }
431 else
432 {
433 return status;
434 }
435 pMac->scan.domainIdDefault = regId;
436 break;
437 case REINIT:
438 vos_getCurrentCountryCode(&cc[0]);
439 status = csrGetRegulatoryDomainForCountry(pMac,
440 cc, &regId, COUNTRY_QUERY);
441 break;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530442 }
443 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530444 pMac->scan.domainIdCurrent = regId;
445 vos_mem_copy(pMac->scan.countryCodeCurrent, cc,
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530446 WNI_CFG_COUNTRY_CODE_LEN);
447 status = csrInitGetChannels( pMac );
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530448
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530449 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
450 FL("Current Country is %c%c "), pMac->scan.countryCodeCurrent[0],
451 pMac->scan.countryCodeCurrent[1]);
452
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530453 /* reset info based on new cc, and we are done */
454 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
455 csrScanFilterResults(pMac);
456
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530457 return status;
458}
459
Jeff Johnson295189b2012-06-20 16:38:30 -0700460eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
461{
462 eHalStatus status = eHAL_STATUS_SUCCESS;
463 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
464 v_REGDOMAIN_t regId;
465 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700466 if(NULL == apCntryCode)
467 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530468 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700469 return eHAL_STATUS_FAILURE;
470 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530471 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700472 /* To get correct Regulatory domain from NV table
473 * 2 character Country code should be used
474 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700475 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
476/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700478
479 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
480 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800481 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700482 return eHAL_STATUS_FAILURE;
483 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700484*/
Kiet Lam6c583332013-10-14 05:37:09 +0530485 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
486 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 if (status != eHAL_STATUS_SUCCESS)
488 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700489 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 return status;
491 }
Abhishek Singha306a442013-11-07 18:39:01 +0530492 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 if (status != eHAL_STATUS_SUCCESS)
494 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700495 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700496 return status;
497 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700498 pMac->scan.domainIdDefault = regId;
499 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700500 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530501 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
502
Jeff Johnson295189b2012-06-20 16:38:30 -0700503 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530504 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
505
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 /* If 2 bytes country code, 3rd byte must be filled with space */
507 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
508 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530509 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530511 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
512 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700514 return status;
515}
Jeff Johnson295189b2012-06-20 16:38:30 -0700516eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
517{
518 eHalStatus status = eHAL_STATUS_SUCCESS;
519 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
520 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530521 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
522 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
524 {
525 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
526 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
527 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
528 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
529 }
530 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
531
532 return status;
533}
Jeff Johnson295189b2012-06-20 16:38:30 -0700534eHalStatus csrClose(tpAniSirGlobal pMac)
535{
536 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800537
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 csrRoamClose(pMac);
539 csrScanClose(pMac);
540 csrLLClose(&pMac->roam.statsClientReqList);
541 csrLLClose(&pMac->roam.peStatsReqList);
542 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 /* DeInit Globals */
544 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 return (status);
546}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530547
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800548eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530549{
550 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800551 tCsrScanStruct *pScan = &pMac->scan;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530552 tANI_U32 numChan = 0;
553 tANI_U32 bufLen ;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530554 vos_msg_t msg;
555 tANI_U8 i;
556
Atul Mittalb849d5a2014-07-29 12:08:39 +0530557 limInitOperatingClasses((tHalHandle)pMac);
Agarwal Ashish738843c2014-09-25 12:27:56 +0530558 numChan = sizeof(pMac->roam.validChannelList);
559
560 if ( !HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
561 (tANI_U8 *)pMac->roam.validChannelList, &numChan)))
562 {
563 smsLog( pMac, LOGE, "Failed to get Channel list from CFG");
564 return eHAL_STATUS_FAILED_ALLOC;
565 }
566
567 bufLen = sizeof(tSirUpdateChanList) +
568 (sizeof(tSirUpdateChanParam) * (numChan - 1));
569
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530570 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
571 if (!pChanList)
572 {
573 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
574 "Failed to allocate memory for tSirUpdateChanList");
575 return eHAL_STATUS_FAILED_ALLOC;
576 }
577
578 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
579 msg.reserved = 0;
580 msg.bodyptr = pChanList;
581 pChanList->numChan = numChan;
582 for (i = 0; i < pChanList->numChan; i++)
583 {
Agarwal Ashish738843c2014-09-25 12:27:56 +0530584 pChanList->chanParam[i].chanId = pMac->roam.validChannelList[i];
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800585 pChanList->chanParam[i].pwr = cfgGetRegulatoryMaxTransmitPower(pMac,
586 pScan->defaultPowerTable[i].chanId);
587 if (vos_nv_getChannelEnabledState(pChanList->chanParam[i].chanId) ==
588 NV_CHANNEL_DFS)
589 pChanList->chanParam[i].dfsSet = VOS_TRUE;
590 else
591 pChanList->chanParam[i].dfsSet = VOS_FALSE;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530592 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
593 "%s Supported Channel: %d\n", __func__, pChanList->chanParam[i].chanId);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530594 }
595
596 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
597 {
598 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
599 "%s: Failed to post msg to WDA", __func__);
600 vos_mem_free(pChanList);
601 return eHAL_STATUS_FAILURE;
602 }
603
604 return eHAL_STATUS_SUCCESS;
605}
606
Jeff Johnson295189b2012-06-20 16:38:30 -0700607eHalStatus csrStart(tpAniSirGlobal pMac)
608{
609 eHalStatus status = eHAL_STATUS_SUCCESS;
610 tANI_U32 i;
611
612 do
613 {
614 //save the global vos context
615 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
616 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
617 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
618
619 status = csrRoamStart(pMac);
620 if(!HAL_STATUS_SUCCESS(status)) break;
621 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
622 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
623 if(!HAL_STATUS_SUCCESS(status)) break;
624 pMac->roam.sPendingCommands = 0;
625 csrScanEnable(pMac);
626#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
627 status = csrNeighborRoamInit(pMac);
628#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
629 pMac->roam.tlStatsReqInfo.numClient = 0;
630 pMac->roam.tlStatsReqInfo.periodicity = 0;
631 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
632 //init the link quality indication also
633 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
634 if(!HAL_STATUS_SUCCESS(status))
635 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800636 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 break;
638 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530639
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700641#if defined(ANI_LOGDUMP)
642 csrDumpInit(pMac);
643#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 return (status);
645}
646
Kiet Lama72a2322013-11-15 11:18:11 +0530647eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700648{
649 tANI_U32 sessionId;
650 tANI_U32 i;
651
652 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
653 {
654 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
655 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700656 csrScanDisable(pMac);
657 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
658 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
660
661#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
662 csrNeighborRoamClose(pMac);
663#endif
664 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 // deregister from PMC since we register during csrStart()
666 // (ignore status since there is nothing we can do if it fails)
667 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 //Reset the domain back to the deault
669 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800670 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700671
672 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
673 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530674 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
676 }
677
Kiet Lama72a2322013-11-15 11:18:11 +0530678#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
679 /* When HAL resets all the context information
680 * in HAL is lost, so we might need to send the
681 * scan offload request again when it comes
682 * out of reset for scan offload to be functional
683 */
684 if (HAL_STOP_TYPE_SYS_RESET == stopType)
685 {
686 bRoamScanOffloadStarted = VOS_FALSE;
687 }
688#endif
689
Jeff Johnson295189b2012-06-20 16:38:30 -0700690 return (eHAL_STATUS_SUCCESS);
691}
692
Jeff Johnson295189b2012-06-20 16:38:30 -0700693eHalStatus csrReady(tpAniSirGlobal pMac)
694{
695 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 csrScanGetSupportedChannels( pMac );
697 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
698 //use it to init the background scan list
699 csrInitBGScanChannelList(pMac);
700 /* HDD issues the init scan */
701 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800702 /* If the gScanAgingTime is set to '0' then scan results aging timeout
703 based on timer feature is not enabled*/
704 if(0 != pMac->scan.scanResultCfgAgingTime )
705 {
706 csrScanStartResultCfgAgingTimer(pMac);
707 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 //Store the AC weights in TL for later use
709 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 status = csrInitChannelList( pMac );
711 if ( ! HAL_STATUS_SUCCESS( status ) )
712 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800713 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 status );
715 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 return (status);
717}
Jeff Johnson295189b2012-06-20 16:38:30 -0700718void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
719{
720 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
722 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
723}
Jeff Johnson295189b2012-06-20 16:38:30 -0700724void csrSetGlobalCfgs( tpAniSirGlobal pMac )
725{
Jeff Johnsone7245742012-09-05 17:12:55 -0700726
Jeff Johnson295189b2012-06-20 16:38:30 -0700727 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
728 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
729 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
730 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
731 NULL, eANI_BOOLEAN_FALSE);
732 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700733 /* 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
734 * Once session is established we will use the session related params stored in PE session for CB mode
735 */
736 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
738
739 //Update the operating mode to configured value during initialization,
740 //So that client can advertise full capabilities in Probe request frame.
741 csrSetDefaultDot11Mode( pMac );
742}
743
Jeff Johnson295189b2012-06-20 16:38:30 -0700744eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
745{
746 eHalStatus status = eHAL_STATUS_SUCCESS;
747 tANI_U32 i;
748 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 do
750 {
751 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
752 {
753 pSession = CSR_GET_SESSION( pMac, i );
754 pSession->roamingTimerInfo.pMac = pMac;
755 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
756 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
758 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530759 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
760 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700761 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530762 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800764 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 break;
766 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530767 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
768 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
769 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800771 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 return eHAL_STATUS_FAILURE;
773 }
774 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 return (status);
776}
777
Jeff Johnson295189b2012-06-20 16:38:30 -0700778eHalStatus csrRoamClose(tpAniSirGlobal pMac)
779{
780 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700781 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
782 {
783 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
784 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530785 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
786 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
787 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
788 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 return (eHAL_STATUS_SUCCESS);
790}
791
Jeff Johnson295189b2012-06-20 16:38:30 -0700792eHalStatus csrRoamStart(tpAniSirGlobal pMac)
793{
794 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700795 return (eHAL_STATUS_SUCCESS);
796}
797
Jeff Johnson295189b2012-06-20 16:38:30 -0700798void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
799{
800 csrRoamStopRoamingTimer(pMac, sessionId);
801 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
802 csrRoamDeregStatisticsReq(pMac);
803}
Jeff Johnson295189b2012-06-20 16:38:30 -0700804eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
805{
806 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800807 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700808 {
809 status = eHAL_STATUS_SUCCESS;
810 *pState = pMac->roam.roamSession[sessionId].connectState;
811 }
812 return (status);
813}
814
Jeff Johnson295189b2012-06-20 16:38:30 -0700815eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
816{
817 eHalStatus status = eHAL_STATUS_FAILURE;
818 tANI_U32 size = 0;
819 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700820
821 if(!pSession)
822 {
823 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
824 return eHAL_STATUS_FAILURE;
825 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700826
827 if(pProfile)
828 {
829 if(pSession->pConnectBssDesc)
830 {
831 do
832 {
833 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
834 if(size)
835 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530836 pProfile->pBssDesc = vos_mem_malloc(size);
837 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530839 vos_mem_copy(pProfile->pBssDesc,
840 pSession->pConnectBssDesc, size);
841 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 }
843 else
844 break;
845 }
846 else
847 {
848 pProfile->pBssDesc = NULL;
849 }
850 pProfile->AuthType = pSession->connectedProfile.AuthType;
851 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
852 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
853 pProfile->BSSType = pSession->connectedProfile.BSSType;
854 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
855 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530856 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
857 sizeof(tCsrBssid));
858 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
859 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700860#ifdef WLAN_FEATURE_VOWIFI_11R
861 if (pSession->connectedProfile.MDID.mdiePresent)
862 {
863 pProfile->MDID.mdiePresent = 1;
864 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
865 }
866 else
867 {
868 pProfile->MDID.mdiePresent = 0;
869 pProfile->MDID.mobilityDomain = 0;
870 }
871#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800872#ifdef FEATURE_WLAN_ESE
873 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
874 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800876 vos_mem_copy (pProfile->eseCckmInfo.krk,
877 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530878 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800879 pProfile->eseCckmInfo.reassoc_req_num=
880 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
881 pProfile->eseCckmInfo.krk_plumbed =
882 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 }
884#endif
885 }while(0);
886 }
887 }
888
889 return (status);
890}
891
Jeff Johnson295189b2012-06-20 16:38:30 -0700892eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
893{
894 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700895
896 if((csrIsConnStateConnected(pMac, sessionId)) ||
897 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 {
899 if(pProfile)
900 {
901 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
902 }
903 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 return (status);
905}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700906
Jeff Johnson295189b2012-06-20 16:38:30 -0700907eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
908{
909 eHalStatus status = eHAL_STATUS_SUCCESS;
910
Kiet Lam64c1b492013-07-12 13:56:44 +0530911 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530913 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530915 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700916 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530917 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700918 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530919 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
920
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
922 return (status);
923}
924
Jeff Johnson295189b2012-06-20 16:38:30 -0700925static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
926{
927 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700928 if( pConnectedInfo->pbFrames )
929 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530930 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700931 pConnectedInfo->pbFrames = NULL;
932 }
933 pConnectedInfo->nBeaconLength = 0;
934 pConnectedInfo->nAssocReqLength = 0;
935 pConnectedInfo->nAssocRspLength = 0;
936 pConnectedInfo->staId = 0;
937#ifdef WLAN_FEATURE_VOWIFI_11R
938 pConnectedInfo->nRICRspLength = 0;
939#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800940#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700941 pConnectedInfo->nTspecIeLength = 0;
942#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 return ( status );
944}
945
Jeff Johnson295189b2012-06-20 16:38:30 -0700946
947
Jeff Johnsone7245742012-09-05 17:12:55 -0700948
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700949void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
950{
951 csrReinitPreauthCmd(pMac, pCommand);
952 csrReleaseCommand( pMac, pCommand );
953}
954
Jeff Johnson295189b2012-06-20 16:38:30 -0700955void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
956{
957 csrReinitRoamCmd(pMac, pCommand);
958 csrReleaseCommand( pMac, pCommand );
959}
960
Jeff Johnson295189b2012-06-20 16:38:30 -0700961void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
962{
963 csrReinitScanCmd(pMac, pCommand);
964 csrReleaseCommand( pMac, pCommand );
965}
966
Jeff Johnson295189b2012-06-20 16:38:30 -0700967void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
968{
969 csrReinitWmStatusChangeCmd(pMac, pCommand);
970 csrReleaseCommand( pMac, pCommand );
971}
972
Jeff Johnson295189b2012-06-20 16:38:30 -0700973void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
974{
Kiet Lam64c1b492013-07-12 13:56:44 +0530975 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700976}
977
Jeff Johnson295189b2012-06-20 16:38:30 -0700978void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
979{
Kiet Lam64c1b492013-07-12 13:56:44 +0530980 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700981}
982
Jeff Johnson295189b2012-06-20 16:38:30 -0700983void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
984{
985 csrReinitSetKeyCmd(pMac, pCommand);
986 csrReleaseCommand( pMac, pCommand );
987}
Jeff Johnson295189b2012-06-20 16:38:30 -0700988void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
989{
990 csrReinitRemoveKeyCmd(pMac, pCommand);
991 csrReleaseCommand( pMac, pCommand );
992}
Jeff Johnson295189b2012-06-20 16:38:30 -0700993void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
994{
995
996 if( eSmeCsrCommandMask & pCommand->command )
997 {
998 switch (pCommand->command)
999 {
1000 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -08001001 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -08001002 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
1003 __func__, pCommand->u.scanCmd.reason,
1004 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -07001005 if (NULL != pCommand->u.scanCmd.callback)
1006 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001007 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
1009 }
1010 csrReleaseCommandScan( pMac, pCommand );
1011 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 case eSmeCommandRoam:
1013 csrReleaseCommandRoam( pMac, pCommand );
1014 break;
1015
1016 case eSmeCommandWmStatusChange:
1017 csrReleaseCommandWmStatusChange( pMac, pCommand );
1018 break;
1019
1020 case eSmeCommandSetKey:
1021 csrReleaseCommandSetKey( pMac, pCommand );
1022 break;
1023
1024 case eSmeCommandRemoveKey:
1025 csrReleaseCommandRemoveKey( pMac, pCommand );
1026 break;
1027
1028 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001029 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 csrReleaseCommand( pMac, pCommand );
1031 break;
1032 }
1033 }
1034}
1035
Jeff Johnson295189b2012-06-20 16:38:30 -07001036void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
1037{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301038 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1039 macTraceGetcsrRoamSubState(NewSubstate),
1040 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001041
Jeff Johnson295189b2012-06-20 16:38:30 -07001042 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1043 {
1044 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001046 pMac->roam.curSubState[sessionId] = NewSubstate;
1047}
1048
Jeff Johnson295189b2012-06-20 16:38:30 -07001049eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1050{
1051 eCsrRoamState PreviousState;
1052
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301053 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1054 macTraceGetcsrRoamState(NewRoamState),
1055 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001056
1057 PreviousState = pMac->roam.curState[sessionId];
1058
1059 if ( NewRoamState != pMac->roam.curState[sessionId] )
1060 {
1061 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1062 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1063 {
1064 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1065 }
1066
1067 pMac->roam.curState[sessionId] = NewRoamState;
1068 }
1069 return( PreviousState );
1070}
1071
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001072void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001073{
1074 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 if(catOffset)
1076 {
1077 pMac->roam.configParam.bCatRssiOffset = catOffset;
1078 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1079 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001080 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 -07001081 }
1082 }
1083}
1084
Jeff Johnson295189b2012-06-20 16:38:30 -07001085static void initConfigParam(tpAniSirGlobal pMac)
1086{
1087 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301089 pMac->roam.configParam.channelBondingMode24GHz =
1090 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1091 pMac->roam.configParam.channelBondingMode5GHz =
1092 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001093 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1094 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1095 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1096 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1097 pMac->roam.configParam.HeartbeatThresh24 = 40;
1098 pMac->roam.configParam.HeartbeatThresh50 = 40;
1099 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1100 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1101 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001102 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 pMac->roam.configParam.RTSThreshold = 2346;
1104 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1105 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1106 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1107 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1108 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1109 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1110 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1111 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1112 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1113 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1114 {
1115 pMac->roam.configParam.BssPreferValue[i] = i;
1116 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001117 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001118 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1119 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1120 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001121 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1122 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05301123 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001124 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1125 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1126 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1127 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001128 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1129 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001130 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001131#ifdef WLAN_AP_STA_CONCURRENCY
1132 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1133 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1134 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1135 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1136 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001137 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1138 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001139#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1141 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1142 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1143 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001144#ifdef WLAN_FEATURE_VOWIFI_11R
1145 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1146#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001147#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1148 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1149 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1150 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1151 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1152 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1153 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1154 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1155 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1156 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1157 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1158 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001159 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Mukul Sharma20aa6582014-08-07 21:36:12 +05301160 pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001161#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001162#ifdef WLAN_FEATURE_11AC
1163 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1164#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001165
1166 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1167 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001168
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001169 //Remove this code once SLM_Sessionization is supported
1170 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001171 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001172
Jeff Johnsone7245742012-09-05 17:12:55 -07001173}
Jeff Johnson295189b2012-06-20 16:38:30 -07001174eCsrBand csrGetCurrentBand(tHalHandle hHal)
1175{
1176 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1177 return pMac->roam.configParam.bandCapability;
1178}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001179
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001180
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001181#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001182/*
1183 This function flushes the roam scan cache
1184*/
1185eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1186{
1187 eHalStatus status = eHAL_STATUS_SUCCESS;
1188 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1189
1190 /* Free up the memory first (if required) */
1191 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1192 {
1193 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1194 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1195 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1196 }
1197 return status;
1198}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001199#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001200
1201
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001202#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001203/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001204 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001205*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001206eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001207{
1208 eHalStatus status = eHAL_STATUS_SUCCESS;
1209 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1210
1211 /* Free up the memory first (if required) */
1212 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1213 {
1214 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1215 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001216 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001217 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001218 return status;
1219}
1220
1221
1222
1223/*
1224 This function flushes the roam scan cache and creates fresh cache
1225 based on the input channel list
1226*/
1227eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1228 const tANI_U8 *pChannelList,
1229 const tANI_U8 numChannels)
1230{
1231 eHalStatus status = eHAL_STATUS_SUCCESS;
1232 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1233
Srinivas Girigowdade697412013-02-14 16:31:48 -08001234 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1235
1236 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1237 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1238
1239 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1240 {
1241 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1242 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1243 return eHAL_STATUS_RESOURCES;
1244 }
1245
1246 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301247 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1248 pChannelList,
1249 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001250 return status;
1251}
1252
1253/* This function modifies the bgscan channel list set via config ini or
1254 runtime, whenever the band changes.
1255 if the band is auto, then no operation is performed on the channel list
1256 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1257 if the band is 5G, then make sure channel list contains only 5G valid channels
1258*/
1259eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1260 eCsrBand eBand)
1261{
1262 eHalStatus status = eHAL_STATUS_SUCCESS;
1263 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1264 tANI_U8 outNumChannels = 0;
1265 tANI_U8 inNumChannels = 0;
1266 tANI_U8 *inPtr = NULL;
1267 tANI_U8 i = 0;
1268 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1269
1270 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1271
1272 {
1273 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1274 "No update required for channel list "
1275 "either cfg.ini channel list is not set up or "
1276 "auto band (Band %d)", eBand);
1277 return status;
1278 }
1279
1280 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1281 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1282 if (eCSR_BAND_24 == eBand)
1283 {
1284 for (i = 0; i < inNumChannels; i++)
1285 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001286 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001287 {
1288 ChannelList[outNumChannels++] = inPtr[i];
1289 }
1290 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001291 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001292 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001293 }
1294 else if (eCSR_BAND_5G == eBand)
1295 {
1296 for (i = 0; i < inNumChannels; i++)
1297 {
1298 /* Add 5G Non-DFS channel */
1299 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001300 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001301 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1302 {
1303 ChannelList[outNumChannels++] = inPtr[i];
1304 }
1305 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001306 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001307 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001308 }
1309 else if (eCSR_BAND_ALL == eBand)
1310 {
1311 for (i = 0; i < inNumChannels; i++)
1312 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001313 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001314 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1315 {
1316 ChannelList[outNumChannels++] = inPtr[i];
1317 }
1318 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001319 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001320 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001321 }
1322 else
1323 {
1324 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1325 "Invalid band, No operation carried out (Band %d)", eBand);
1326 status = eHAL_STATUS_INVALID_PARAMETER;
1327 }
1328
1329 return status;
1330}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001331#endif
1332
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001333#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001334/* This function modifies the roam scan channel list as per AP neighbor
1335 report; AP neighbor report may be empty or may include only other AP
1336 channels; in any case, we merge the channel list with the learned occupied
1337 channels list.
1338 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1339 if the band is 5G, then make sure channel list contains only 5G valid channels
1340*/
1341eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1342 tANI_U8 *pChannelList,
1343 tANI_U8 numChannels,
1344 const eCsrBand eBand)
1345{
1346 eHalStatus status = eHAL_STATUS_SUCCESS;
1347 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1348 tANI_U8 outNumChannels = 0;
1349 tANI_U8 inNumChannels = numChannels;
1350 tANI_U8 *inPtr = pChannelList;
1351 tANI_U8 i = 0;
1352 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1353 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1354 tANI_U8 mergedOutputNumOfChannels = 0;
1355 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1356
1357 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1358 * report Channels. This increases the chances of the DUT to get a candidate AP while
1359 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1360 if (pMac->scan.occupiedChannels.numChannels)
1361 {
1362 csrNeighborRoamMergeChannelLists(pMac,
1363 &pMac->scan.occupiedChannels.channelList[0],
1364 pMac->scan.occupiedChannels.numChannels,
1365 inPtr,
1366 inNumChannels,
1367 &mergedOutputNumOfChannels);
1368 inNumChannels = mergedOutputNumOfChannels;
1369 }
1370
1371 if (eCSR_BAND_24 == eBand)
1372 {
1373 for (i = 0; i < inNumChannels; i++)
1374 {
1375 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1376 {
1377 ChannelList[outNumChannels++] = inPtr[i];
1378 }
1379 }
1380 }
1381 else if (eCSR_BAND_5G == eBand)
1382 {
1383 for (i = 0; i < inNumChannels; i++)
1384 {
1385 /* Add 5G Non-DFS channel */
1386 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1387 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1388 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1389 {
1390 ChannelList[outNumChannels++] = inPtr[i];
1391 }
1392 }
1393 }
1394 else if (eCSR_BAND_ALL == eBand)
1395 {
1396 for (i = 0; i < inNumChannels; i++)
1397 {
1398 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1399 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1400 {
1401 ChannelList[outNumChannels++] = inPtr[i];
1402 }
1403 }
1404 }
1405 else
1406 {
1407 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1408 "Invalid band, No operation carried out (Band %d)", eBand);
1409 return eHAL_STATUS_INVALID_PARAMETER;
1410 }
1411
1412 /* if roaming within band is enabled, then select only the
1413 in band channels .
1414 This is required only if the band capability is set to ALL,
1415 E.g., if band capability is only 2.4G then all the channels in the
1416 list are already filtered for 2.4G channels, hence ignore this check*/
1417
1418 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1419 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05301420 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001421 pMac,
1422 ChannelList,
1423 outNumChannels,
1424 tmpChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05301425 &outNumChannels,
1426 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Kiet Lamf2f201e2013-11-16 21:24:16 +05301427 vos_mem_copy(ChannelList,
1428 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001429 }
1430
1431 /* Prepare final roam scan channel list */
1432 if(outNumChannels)
1433 {
1434 /* Clear the channel list first */
1435 if (NULL != currChannelListInfo->ChannelList)
1436 {
1437 vos_mem_free(currChannelListInfo->ChannelList);
1438 currChannelListInfo->ChannelList = NULL;
1439 currChannelListInfo->numOfChannels = 0;
1440 }
1441
1442 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1443 if (NULL == currChannelListInfo->ChannelList)
1444 {
1445 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1446 "Failed to allocate memory for roam scan channel list");
1447 currChannelListInfo->numOfChannels = 0;
1448 return VOS_STATUS_E_RESOURCES;
1449 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301450 vos_mem_copy(currChannelListInfo->ChannelList,
1451 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001452 }
1453 return status;
1454}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001455#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001456
Jeff Johnson295189b2012-06-20 16:38:30 -07001457eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1458{
1459 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1460 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1462 (eBand == eCSR_BAND_24))
1463 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001464 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001465 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001466 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001467 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001468 pMac->roam.configParam.uCfgDot11Mode, eBand);
1469 return eHAL_STATUS_INVALID_PARAMETER;
1470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1472 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1473 (eBand == eCSR_BAND_5G))
1474 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001475 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001477 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001478 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001479 pMac->roam.configParam.uCfgDot11Mode, eBand);
1480 return eHAL_STATUS_INVALID_PARAMETER;
1481 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001482 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001483 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001484 pMac->roam.configParam.eBand = eBand;
1485 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001486 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001487#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001488 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1489 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001490#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001491 status = csrInitGetChannels( pMac );
1492 if (eHAL_STATUS_SUCCESS == status)
1493 csrInitChannelList( hHal );
1494 return status;
1495}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001496
1497
Jeff Johnsone7245742012-09-05 17:12:55 -07001498/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1499 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1500 * Ideally we should have kept the ini value and enum value same and representing the same
1501 * cb values as in 11n standard i.e.
1502 * Set to 1 (SCA) if the secondary channel is above the primary channel
1503 * Set to 3 (SCB) if the secondary channel is below the primary channel
1504 * Set to 0 (SCN) if no secondary channel is present
1505 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1506 * 0 - secondary none
1507 * 1 - secondary LOW
1508 * 2 - secondary HIGH
1509 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1510 * The enum values are as follows:
1511 * PHY_SINGLE_CHANNEL_CENTERED = 0
1512 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1513 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1514 */
1515ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1516{
1517
1518 ePhyChanBondState phyCbState;
1519 switch (cbIniValue) {
1520 // secondary none
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301521 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001522 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1523 break;
1524 // secondary LOW
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301525 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001526 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1527 break;
1528 // secondary HIGH
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301529 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001530 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1531 break;
1532#ifdef WLAN_FEATURE_11AC
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301533 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1534 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001535 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301536 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001537 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1538 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301539 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1540 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
1541 break;
1542 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001543 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1544 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301545 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001546 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301547 break;
1548 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001549 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1550 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301551 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001552 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301553 break;
1554#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001555 default:
1556 // If an invalid value is passed, disable CHANNEL BONDING
1557 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1558 break;
1559 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301560
Jeff Johnsone7245742012-09-05 17:12:55 -07001561 return phyCbState;
1562}
1563
1564v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1565{
1566
1567 v_U32_t cbIniValue;
1568 switch (phyCbState) {
1569 // secondary none
1570 case PHY_SINGLE_CHANNEL_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301571 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001572 break;
1573 // secondary LOW
1574 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301575 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001576 break;
1577 // secondary HIGH
1578 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301579 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001580 break;
1581#ifdef WLAN_FEATURE_11AC
1582 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301583 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001584 break;
1585 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301586 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001587 break;
1588 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301589 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001590 break;
1591 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301592 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001593 break;
1594 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301595 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001596 break;
1597 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301598 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001599 break;
1600 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301601 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001602 break;
1603#endif
1604 default:
1605 // return some invalid value
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301606 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
Jeff Johnsone7245742012-09-05 17:12:55 -07001607 break;
1608 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301609
Jeff Johnsone7245742012-09-05 17:12:55 -07001610 return cbIniValue;
1611}
Jeff Johnson295189b2012-06-20 16:38:30 -07001612
1613eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1614{
1615 eHalStatus status = eHAL_STATUS_SUCCESS;
1616
1617 if(pParam)
1618 {
1619 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1620 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1621 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1622 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1623 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1624 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1625
1626 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001627 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1628
Jeff Johnsone7245742012-09-05 17:12:55 -07001629 /* channelBondingMode5GHz plays a dual role right now
1630 * 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
1631 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1632 */
1633 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1634 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001635 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001636 }
1637 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1638 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1639 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001640 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001641 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301642#ifdef WLAN_FEATURE_AP_HT40_24G
1643 pMac->roam.configParam.channelBondingAPMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingAPMode24GHz);
1644#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001645 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1647 pMac->roam.configParam.phyMode = pParam->phyMode;
1648 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1649 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1650 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1651 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1652 pMac->roam.configParam.TxRate = pParam->TxRate;
1653 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1654 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1655 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1656 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1657 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001658 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 //if HDD passed down non zero values then only update,
1660 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301661 if (pParam->nInitialDwellTime)
1662 {
1663 pMac->roam.configParam.nInitialDwellTime =
1664 pParam->nInitialDwellTime;
1665 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001666 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001667 {
1668 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301669 cfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1670 pParam->nActiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001671 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001672 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 {
1674 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301675 cfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1676 pParam->nActiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001677 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001678 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001679 {
1680 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301681 cfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1682 pParam->nPassiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001683 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001684 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 {
1686 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301687 cfgSetInt(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1688 pParam->nPassiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001689 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001690 if (pParam->nActiveMaxChnTimeBtc)
1691 {
1692 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1693 }
1694 if (pParam->nActiveMinChnTimeBtc)
1695 {
1696 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1697 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001698#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001699 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001700 {
1701 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1702 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001703 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001704 {
1705 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1706 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001707 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001708 {
1709 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1710 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001711 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001712 {
1713 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1714 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001715 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001716 {
1717 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1718 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001719 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001720 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001721 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1722 }
1723 if (pParam->nNumP2PChanCombinedConc)
1724 {
1725 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001726 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001727#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001728 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001729 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001730 {
1731 //Change the unit from second to microsecond
1732 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1734 {
1735 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1736 }
1737 else
1738 {
1739 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1740 }
1741 }
1742 else
1743 {
1744 pMac->roam.configParam.impsSleepTime = 0;
1745 }
1746 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001747 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1748 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001749 //if HDD passed down non zero values for age params, then only update,
1750 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001751 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 {
1753 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1754 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001755 if(pParam->scanAgeTimeNCNPS)
1756 {
1757 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1758 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001759 if(pParam->scanAgeTimeNCPS)
1760 {
1761 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1762 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 if(pParam->scanAgeTimeCNPS)
1764 {
1765 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1766 }
1767 if(pParam->scanAgeTimeCPS)
1768 {
1769 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1770 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301771 if (pParam->initialScanSkipDFSCh)
1772 {
1773 pMac->roam.configParam.initialScanSkipDFSCh =
1774 pParam->initialScanSkipDFSCh;
1775 }
1776
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001777 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1779 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1780 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1781 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1782 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001783 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1784 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001785 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1786 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1787 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1788 //Assign this before calling CsrInit11dInfo
1789 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001790 if( csrIs11dSupported( pMac ) )
1791 {
1792 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1793 }
1794 else
1795 {
1796 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1797 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001798
1799 /* Initialize the power + channel information if 11h is enabled.
1800 If 11d is enabled this information has already been initialized */
1801 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1802 {
1803 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1804 }
1805
1806
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301807#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301808 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1809 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001810 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001811#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001812#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001813 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001814 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001815 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001816 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001817 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001818 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001819 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001820 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001821 pMac->roam.configParam.nProbes = pParam->nProbes;
1822 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001823#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001824#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1825 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001826 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001827#endif
1828#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001829 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001830 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001831#endif
1832
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001833#ifdef FEATURE_WLAN_ESE
1834 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001835#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001836#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301837 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1838 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001839 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1840 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1841 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1842 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1843 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1844 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1845 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1846 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Mukul Sharma20aa6582014-08-07 21:36:12 +05301847 smsLog( pMac, LOG1, "nNeighborInitialForcedRoamTo5GhEnable = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001848 {
1849 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001850 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 -07001851 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1852 {
1853 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1854 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001855 }
1856#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1858 pMac->scan.fValidateList = pParam->fValidateList;
1859 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1860 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001861 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001862 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001863 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
Peng Xu2446a892014-09-05 17:21:18 +05301864 pMac->scan.scanBandPreference = pParam->scanBandPreference;
Jeff Johnsone7245742012-09-05 17:12:55 -07001865 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1866 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1867 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1868 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1869 * single session
1870 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001871 //Remove this code once SLM_Sessionization is supported
1872 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001873 pMac->roam.configParam.doBMPSWorkaround = 0;
1874
Jeff Johnsone7245742012-09-05 17:12:55 -07001875#ifdef WLAN_FEATURE_11AC
1876 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001877 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001878 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001879 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301880 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1881 if ( pParam->enableTxBF )
1882 pMac->roam.configParam.txMuBformee= pParam->enableMuBformee;
1883 else
1884 pMac->roam.configParam.txMuBformee= 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001885#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001886 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001887
1888 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001889 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001890 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1891 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301892 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05301893 pMac->roam.configParam.sendDeauthBeforeCon = pParam->sendDeauthBeforeCon;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301894#ifdef WLAN_FEATURE_AP_HT40_24G
1895 pMac->roam.configParam.apHT40_24GEnabled = pParam->apHT40_24GEnabled;
1896#endif
1897
Jeff Johnson295189b2012-06-20 16:38:30 -07001898 }
1899
1900 return status;
1901}
1902
Jeff Johnson295189b2012-06-20 16:38:30 -07001903eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1904{
1905 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 if(pParam)
1907 {
1908 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1909 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1910 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1911 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1912 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1913 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001914 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301915#ifdef WLAN_FEATURE_AP_HT40_24G
1916 pParam->channelBondingAPMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingAPMode24GHz);
1917#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001918 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001919 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1920 pParam->phyMode = pMac->roam.configParam.phyMode;
1921 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1922 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1923 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1924 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1925 pParam->TxRate = pMac->roam.configParam.TxRate;
1926 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1927 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1928 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1929 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1930 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001931 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1932 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1933 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1934 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001935 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1936 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1937 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001938#ifdef WLAN_AP_STA_CONCURRENCY
1939 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1940 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1941 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1942 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1943 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001944 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1945 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001946#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001947 //Change the unit from microsecond to second
1948 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1949 pParam->eBand = pMac->roam.configParam.eBand;
1950 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1951 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1952 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1953 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1954 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1955 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1956 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1957 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1958 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1959 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1960 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1961 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1962 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001963 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1964 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1965 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1966 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001967 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1968 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1969 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1970 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1971 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001972 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001973 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001974 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001975 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Peng Xu2446a892014-09-05 17:21:18 +05301976 pParam->scanBandPreference = pMac->scan.scanBandPreference;
Jeff Johnson295189b2012-06-20 16:38:30 -07001977#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301978 vos_mem_copy(&pParam->neighborRoamConfig,
1979 &pMac->roam.configParam.neighborRoamConfig,
1980 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001981#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001982#ifdef WLAN_FEATURE_11AC
1983 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001984 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001985 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001986 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301987 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1988 if ( pParam->enableTxBF )
1989 pParam->enableMuBformee = pMac->roam.configParam.txMuBformee;
1990 else
1991 pParam->enableMuBformee = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001992#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001993#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301994 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1995 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001996#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001997#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001998 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1999 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
2000 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
2001 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
2002 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07002003 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07002004 pParam->nProbes = pMac->roam.configParam.nProbes;
2005 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002006#endif
2007#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2008 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
2009 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
2010#endif
2011#ifdef FEATURE_WLAN_LFR
2012 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
2013#endif
2014
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002015#ifdef FEATURE_WLAN_ESE
2016 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002017#endif
2018#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302019 vos_mem_copy(&pParam->neighborRoamConfig,
2020 &pMac->roam.configParam.neighborRoamConfig,
2021 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002022 {
2023 int i;
2024 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
2025 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2026 {
2027 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2028 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002029 }
2030#endif
2031
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07002032 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07002033
krunal soni5afa96c2013-09-06 22:19:02 -07002034 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002035 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07002036
krunal sonie9002db2013-11-25 14:24:17 -08002037 pParam->isCoalesingInIBSSAllowed =
2038 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302039 pParam->allowDFSChannelRoam =
2040 pMac->roam.configParam.allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302041 pParam->sendDeauthBeforeCon = pMac->roam.configParam.sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07002042 csrSetChannels(pMac, pParam);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302043#ifdef WLAN_FEATURE_AP_HT40_24G
2044 pParam->apHT40_24GEnabled = pMac->roam.configParam.apHT40_24GEnabled;
2045#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002046
2047 status = eHAL_STATUS_SUCCESS;
2048 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002049 return (status);
2050}
2051
Jeff Johnson295189b2012-06-20 16:38:30 -07002052eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
2053{
2054 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2055 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2056 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
2057 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 do
2059 {
2060 if(eCSR_BAND_24 == eBand)
2061 {
2062 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
2063 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
2064 }
2065 if(eCSR_BAND_5G == eBand)
2066 {
2067 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
2068 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
2069 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
2070 )
2071 {
2072 break;
2073 }
2074 }
2075 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2076 {
2077 newPhyMode = eCSR_DOT11_MODE_TAURUS;
2078 }
2079 else if(eCSR_DOT11_MODE_AUTO & phyMode)
2080 {
2081 newPhyMode = eCSR_DOT11_MODE_AUTO;
2082 }
2083 else
2084 {
2085 //Check for dual band and higher capability first
2086 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2087 {
2088 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2089 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2090 }
2091 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2092 {
2093 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2094 if(eCSR_BAND_24 == eBand) break;
2095 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2096 eBand = eCSR_BAND_5G;
2097 }
2098 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2099 {
2100 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2101 if(eCSR_BAND_5G == eBand) break;
2102 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2103 eBand = eCSR_BAND_24;
2104 }
2105 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2106 {
2107 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2108 if(eCSR_BAND_5G == eBand) break;
2109 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2110 eBand = eCSR_BAND_24;
2111 }
2112 else if(eCSR_DOT11_MODE_11n & phyMode)
2113 {
2114 newPhyMode = eCSR_DOT11_MODE_11n;
2115 }
2116 else if(eCSR_DOT11_MODE_abg & phyMode)
2117 {
2118 newPhyMode = eCSR_DOT11_MODE_abg;
2119 }
2120 else if(eCSR_DOT11_MODE_11a & phyMode)
2121 {
2122 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2123 {
2124 if(eCSR_BAND_ALL == eBand)
2125 {
2126 newPhyMode = eCSR_DOT11_MODE_abg;
2127 }
2128 else
2129 {
2130 //bad setting
2131 break;
2132 }
2133 }
2134 else
2135 {
2136 newPhyMode = eCSR_DOT11_MODE_11a;
2137 eBand = eCSR_BAND_5G;
2138 }
2139 }
2140 else if(eCSR_DOT11_MODE_11g & phyMode)
2141 {
2142 newPhyMode = eCSR_DOT11_MODE_11g;
2143 eBand = eCSR_BAND_24;
2144 }
2145 else if(eCSR_DOT11_MODE_11b & phyMode)
2146 {
2147 newPhyMode = eCSR_DOT11_MODE_11b;
2148 eBand = eCSR_BAND_24;
2149 }
2150 else
2151 {
2152 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002153 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002154 newPhyMode = eCSR_DOT11_MODE_AUTO;
2155 }
2156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002157 //Done validating
2158 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 //Now we need to check whether a restart is needed.
2160 if(eBand != pMac->roam.configParam.eBand)
2161 {
2162 fRestartNeeded = eANI_BOOLEAN_TRUE;
2163 break;
2164 }
2165 if(newPhyMode != pMac->roam.configParam.phyMode)
2166 {
2167 fRestartNeeded = eANI_BOOLEAN_TRUE;
2168 break;
2169 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002170 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 if(HAL_STATUS_SUCCESS(status))
2172 {
2173 pMac->roam.configParam.eBand = eBand;
2174 pMac->roam.configParam.phyMode = newPhyMode;
2175 if(pfRestartNeeded)
2176 {
2177 *pfRestartNeeded = fRestartNeeded;
2178 }
2179 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002180 return (status);
2181}
2182
Jeff Johnson295189b2012-06-20 16:38:30 -07002183void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2184{
2185 tANI_U8 Index;
2186 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002187 // for dual band NICs, don't need to trim the channel list....
2188 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2189 {
2190 // 2.4 GHz band operation requires the channel list to be trimmed to
2191 // the 2.4 GHz channels only...
2192 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2193 {
2194 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2195 Index++ )
2196 {
2197 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2198 {
2199 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2200 cChannels++;
2201 }
2202 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002203 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2204 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2205 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2206 // only if we need to.
2207 //
2208 // The amount of memory to clear is the number of channesl that we trimmed
2209 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2210
2211 if ( pChannelList->numChannels > cChannels )
2212 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302213 vos_mem_set(&pChannelList->channelList[ cChannels ],
2214 sizeof( pChannelList->channelList[ 0 ] ) *
2215 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002216 }
2217
2218 pChannelList->numChannels = cChannels;
2219 }
2220 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2221 {
2222 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2223 {
2224 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2225 {
2226 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2227 cChannels++;
2228 }
2229 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2231 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2232 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2233 // only if we need to.
2234 //
2235 // The amount of memory to clear is the number of channesl that we trimmed
2236 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2237 if ( pChannelList->numChannels > cChannels )
2238 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302239 vos_mem_set(&pChannelList->channelList[ cChannels ],
2240 sizeof( pChannelList->channelList[ 0 ] ) *
2241 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002242 }
2243
2244 pChannelList->numChannels = cChannels;
2245 }
2246 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002247}
Jeff Johnson295189b2012-06-20 16:38:30 -07002248#define INFRA_AP_DEFAULT_CHANNEL 6
2249eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2250{
2251 tANI_U8 index= 0;
2252 eHalStatus status = eHAL_STATUS_FAILURE;
2253 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2254 {
2255 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2256 status = eHAL_STATUS_SUCCESS;
2257 break;
2258 }
2259 }
2260 return status;
2261}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002262
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002263
Jeff Johnson295189b2012-06-20 16:38:30 -07002264eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2265{
2266 eHalStatus status = eHAL_STATUS_SUCCESS;
2267 tANI_U8 num20MHzChannelsFound = 0;
2268 VOS_STATUS vosStatus;
2269 tANI_U8 Index = 0;
2270 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002271
Jeff Johnson295189b2012-06-20 16:38:30 -07002272
2273 //TODO: this interface changed to include the 40MHz channel list
2274 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2275 // Read the scan channel list (including the power limit) from EEPROM
2276 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2277 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2278 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2279 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002280 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002281 status = eHAL_STATUS_FAILURE;
2282 }
2283 else
2284 {
2285 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2286 {
2287 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2288 }
2289 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2290 // Move the channel list to the global data
2291 // structure -- this will be used as the scan list
2292 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2293 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 }
2296 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2297 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2298 {
2299 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2300 }
2301 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2302 {
2303 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2304 }
2305 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2306 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002307 return (status);
2308}
Jeff Johnson295189b2012-06-20 16:38:30 -07002309eHalStatus csrInitChannelList( tHalHandle hHal )
2310{
2311 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2312 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002313 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2314 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002315 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2316 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002318 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Atul Mittalb849d5a2014-07-29 12:08:39 +05302319 limInitOperatingClasses(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 return (status);
2321}
Jeff Johnson295189b2012-06-20 16:38:30 -07002322eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2323 tCsrUpdateConfigParam *pUpdateConfigParam)
2324{
2325 eHalStatus status = eHAL_STATUS_FAILURE;
2326 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2328 status = CsrInit11dInfo(pMac, ps11dinfo);
2329 return status;
2330}
2331
Jeff Johnson295189b2012-06-20 16:38:30 -07002332static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2333{
2334 eHalStatus status = eHAL_STATUS_FAILURE;
2335 tANI_U8 index;
2336 tANI_U32 count=0;
2337 tSirMacChanInfo *pChanInfo;
2338 tSirMacChanInfo *pChanInfoStart;
2339 tANI_BOOLEAN applyConfig = TRUE;
2340
Mihir Shetebc866f62014-02-13 16:08:53 +05302341 pMac->scan.currentCountryRSSI = -128;
2342
Jeff Johnson295189b2012-06-20 16:38:30 -07002343 if(!ps11dinfo)
2344 {
2345 return (status);
2346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002347 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2348 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302349 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2350 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2351 ps11dinfo->Channels.channelList,
2352 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002353 }
2354 else
2355 {
2356 //No change
2357 return (eHAL_STATUS_SUCCESS);
2358 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002359 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302360
2361 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2362 WNI_CFG_COUNTRY_CODE_LEN);
2363
2364
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 //Tush: at csropen get this initialized with default, during csr reset if this
2366 // already set with some value no need initilaize with default again
2367 if(0 == pMac->scan.countryCodeCurrent[0])
2368 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302369 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2370 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002371 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002372 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302373 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2374 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302376 vos_mem_set(pChanInfo,
2377 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2378 0);
2379
Jeff Johnson295189b2012-06-20 16:38:30 -07002380 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002381 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2382 {
2383 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2384 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2385 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2386 pChanInfo++;
2387 count++;
2388 }
2389 if(count)
2390 {
2391 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2392 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302393 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002394 }
2395 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2396 if( HAL_STATUS_SUCCESS(status) )
2397 {
2398 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2399 {
2400 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2401 {
2402 applyConfig = FALSE;
2403 }
2404 }
2405
2406 if(TRUE == applyConfig)
2407 {
2408 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002409 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002410 }
2411
2412 }
2413 return (status);
2414}
2415/* Initialize the Channel + Power List in the local cache and in the CFG */
2416eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2417{
2418 tANI_U8 index;
2419 tANI_U32 count=0;
2420 tSirMacChanInfo *pChanInfo;
2421 tSirMacChanInfo *pChanInfoStart;
2422
2423 if(!ps11dinfo || !pMac)
2424 {
2425 return eHAL_STATUS_FAILURE;
2426 }
2427
Kiet Lam64c1b492013-07-12 13:56:44 +05302428 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2429 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002430 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302431 vos_mem_set(pChanInfo,
2432 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2433 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002434 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002435
2436 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2437 {
2438 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2439 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2440 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2441 pChanInfo++;
2442 count++;
2443 }
2444 if(count)
2445 {
2446 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2447 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302448 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 }
2450
Jeff Johnsone7245742012-09-05 17:12:55 -07002451 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002452}
2453
2454//pCommand may be NULL
2455//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2456void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2457{
2458 tListElem *pEntry, *pNextEntry;
2459 tSmeCmd *pDupCommand;
2460 tDblLinkList localList;
2461
2462 vos_mem_zero(&localList, sizeof(tDblLinkList));
2463 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2464 {
2465 smsLog(pMac, LOGE, FL(" failed to open list"));
2466 return;
2467 }
2468 csrLLLock( &pMac->sme.smeCmdPendingList );
2469 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2470 while( pEntry )
2471 {
2472 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2473 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 // Remove the previous command if..
2475 // - the new roam command is for the same RoamReason...
2476 // - the new roam command is a NewProfileList.
2477 // - the new roam command is a Forced Dissoc
2478 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2479 if (
2480 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2481 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002482 /* This peermac check is requried for Softap/GO scenarios
2483 * For STA scenario below OR check will suffice as pCommand will
2484 * always be NULL for STA scenarios
2485 */
2486 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002487 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2488 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2489 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2490 ||
2491 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002492 ( (sessionId == pDupCommand->sessionId) &&
2493 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002494 ((eCsrForcedDisassoc == eRoamReason) ||
2495 (eCsrHddIssued == eRoamReason))
2496 )
2497 )
2498 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002499 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002500 // Remove the 'stale' roam command from the pending list...
2501 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2502 {
2503 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2504 }
2505 }
2506 pEntry = pNextEntry;
2507 }
2508 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2509
2510 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2511 {
2512 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2513 //Tell caller that the command is cancelled
2514 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2515 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2516 csrReleaseCommandRoam(pMac, pDupCommand);
2517 }
2518 csrLLClose(&localList);
2519}
Jeff Johnson295189b2012-06-20 16:38:30 -07002520eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2521 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2522{
2523 eHalStatus status = eHAL_STATUS_SUCCESS;
2524#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2525 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2526#endif
2527 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002528 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2529 {
2530 pSession = CSR_GET_SESSION( pMac, sessionId );
2531 }
2532 else
2533 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002534 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 VOS_ASSERT(0);
2536 return eHAL_STATUS_FAILURE;
2537 }
krunal soni587bf012014-02-04 12:35:11 -08002538
2539 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2540 {
2541 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2542 return eHAL_STATUS_FAILURE;
2543 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002544
krunal soni587bf012014-02-04 12:35:11 -08002545 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2546
krunal soni7f7d2c92014-02-06 15:08:43 -08002547 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002548 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002549 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002551 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2552 /*
2553 * Decrement bRefAssocStartCnt for FT reassoc failure.
2554 * Reason: For FT reassoc failures, we first call
2555 * csrRoamCallCallback before notifying a failed roam
2556 * completion through csrRoamComplete. The latter in
2557 * turn calls csrRoamProcessResults which tries to
2558 * once again call csrRoamCallCallback if bRefAssocStartCnt
2559 * is non-zero. Since this is redundant for FT reassoc
2560 * failure, decrement bRefAssocStartCnt.
2561 */
2562 pSession->bRefAssocStartCnt--;
2563 }
2564
Jeff Johnson295189b2012-06-20 16:38:30 -07002565 if(NULL != pSession->callback)
2566 {
2567 if( pRoamInfo )
2568 {
2569 pRoamInfo->sessionId = (tANI_U8)sessionId;
2570 }
2571
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302572 /* avoid holding the global lock when making the roaming callback, original change came
2573 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2574 is possible on other OS ports where the callback may need to take locks to protect
2575 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002576 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2577 that may actually depend on the lock being held */
2578 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2579 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2580 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2581 }
2582 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2583 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2584#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302585 vos_mem_set(&connectionStatus,
2586 sizeof(vos_event_wlan_status_payload_type), 0);
2587
krunal soni7f7d2c92014-02-06 15:08:43 -08002588 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002589 {
2590 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2591 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2592 if(NULL != pRoamInfo->pBssDesc)
2593 {
2594 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2595 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2598 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2599 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302600 vos_mem_copy(connectionStatus.ssid,
2601 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2602
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2604 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2605 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2607 {
2608 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2609 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2610 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002612 if(eCSR_ROAM_RESULT_FORCED == u2)
2613 {
2614 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2615 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2616 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2617 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002618 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2619 {
2620 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2621 connectionStatus.reason = eCSR_REASON_DISASSOC;
2622 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2623 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002624 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2625 {
2626 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2627 connectionStatus.reason = eCSR_REASON_DEAUTH;
2628 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002630#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2631
2632 return (status);
2633}
Jeff Johnson295189b2012-06-20 16:38:30 -07002634// Returns whether handoff is currently in progress or not
2635tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2636{
2637#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2638 return csrNeighborRoamIsHandoffInProgress(pMac);
2639#else
2640 return eANI_BOOLEAN_FALSE;
2641#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002642}
Jeff Johnson295189b2012-06-20 16:38:30 -07002643eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2644 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2645{
2646 eHalStatus status = eHAL_STATUS_SUCCESS;
2647 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2648 tANI_U16 reasonCode;
2649 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002650
2651 if(!pSession)
2652 {
2653 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2654 return eHAL_STATUS_FAILURE;
2655 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002656
2657 //Restore AC weight in case we change it
2658 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2659 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002660 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 -07002661 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2662 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2663 }
2664
2665 if ( fMICFailure )
2666 {
2667 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2668 }
2669 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2670 {
2671 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002672 }
2673 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 {
2675 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2676 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002677#ifdef WLAN_FEATURE_VOWIFI_11R
2678 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2679 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2680 {
2681 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302682 vos_mem_copy(&bssId,
2683 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2684 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002685 }
2686 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002687#endif
2688 if(pSession->pConnectBssDesc)
2689 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302690 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002692
Jeff Johnson295189b2012-06-20 16:38:30 -07002693
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302694 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2695 " subState = %s reason=%d"),
2696 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2697 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002698
Jeff Johnson295189b2012-06-20 16:38:30 -07002699 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2700
2701 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2702
2703 if(HAL_STATUS_SUCCESS(status))
2704 {
2705 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002706#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2707 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2708 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2709 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002710 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002711 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2712 }
2713#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002714 }
2715 else
2716 {
2717 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2718 }
2719
Jeff Johnson295189b2012-06-20 16:38:30 -07002720 return (status);
2721}
Jeff Johnson295189b2012-06-20 16:38:30 -07002722
Jeff Johnson295189b2012-06-20 16:38:30 -07002723/* ---------------------------------------------------------------------------
2724 \fn csrRoamIssueDisassociateStaCmd
2725 \brief csr function that HDD calls to disassociate a associated station
2726 \param sessionId - session Id for Soft AP
2727 \param pPeerMacAddr - MAC of associated station to delete
2728 \param reason - reason code, be one of the tSirMacReasonCodes
2729 \return eHalStatus
2730 ---------------------------------------------------------------------------*/
2731eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2732 tANI_U32 sessionId,
2733 tANI_U8 *pPeerMacAddr,
2734 tANI_U32 reason)
2735{
2736 eHalStatus status = eHAL_STATUS_SUCCESS;
2737 tSmeCmd *pCommand;
2738
2739 do
2740 {
2741 pCommand = csrGetCommandBuffer( pMac );
2742 if ( !pCommand )
2743 {
2744 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2745 status = eHAL_STATUS_RESOURCES;
2746 break;
2747 }
2748 pCommand->command = eSmeCommandRoam;
2749 pCommand->sessionId = (tANI_U8)sessionId;
2750 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2751 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2752 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2753 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2754 if( !HAL_STATUS_SUCCESS( status ) )
2755 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002756 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002757 csrReleaseCommandRoam( pMac, pCommand );
2758 }
2759 }while(0);
2760
2761 return status;
2762}
2763
2764
Jeff Johnson295189b2012-06-20 16:38:30 -07002765/* ---------------------------------------------------------------------------
2766 \fn csrRoamIssueDeauthSta
2767 \brief csr function that HDD calls to delete a associated station
2768 \param sessionId - session Id for Soft AP
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302769 \param pDelStaParams- Pointer to parameters of the station to deauthenticate
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 \return eHalStatus
2771 ---------------------------------------------------------------------------*/
2772eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302773 tANI_U32 sessionId,
2774 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002775{
2776 eHalStatus status = eHAL_STATUS_SUCCESS;
2777 tSmeCmd *pCommand;
2778
2779 do
2780 {
2781 pCommand = csrGetCommandBuffer( pMac );
2782 if ( !pCommand )
2783 {
2784 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2785 status = eHAL_STATUS_RESOURCES;
2786 break;
2787 }
2788 pCommand->command = eSmeCommandRoam;
2789 pCommand->sessionId = (tANI_U8)sessionId;
2790 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302791 vos_mem_copy(pCommand->u.roamCmd.peerMac, pDelStaParams->peerMacAddr,
2792 sizeof(tSirMacAddr));
2793 pCommand->u.roamCmd.reason =
2794 (tSirMacReasonCodes)pDelStaParams->reason_code;
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2796 if( !HAL_STATUS_SUCCESS( status ) )
2797 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002798 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002799 csrReleaseCommandRoam( pMac, pCommand );
2800 }
2801 }while(0);
2802
2803 return status;
2804}
Jeff Johnson295189b2012-06-20 16:38:30 -07002805eHalStatus
2806csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2807 tANI_BOOLEAN bEnable )
2808{
2809 eHalStatus status = eHAL_STATUS_FAILURE;
2810 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2811 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002812 if (!pSession)
2813 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002814 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002815 return (status);
2816 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 if (pSession->pConnectBssDesc)
2818 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302819 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002820 }
2821 else
2822 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002823 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 return (status);
2825 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002826 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2827 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002828 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2829 return (status);
2830}
Jeff Johnson295189b2012-06-20 16:38:30 -07002831eHalStatus
2832csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2833 VOS_MODULE_ID modId, void *pUsrContext,
2834 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2835{
2836 eHalStatus status = eHAL_STATUS_SUCCESS;
2837 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2838 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002839 if (!pSession)
2840 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002841 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002842 return (status);
2843 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002844 if(pSession->pConnectBssDesc)
2845 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302846 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002847 }
2848 else
2849 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002850 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002851 return (status);
2852 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002853 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2854 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2856 return (status);
2857}
Jeff Johnson295189b2012-06-20 16:38:30 -07002858eHalStatus
2859csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2860 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2861{
2862 eHalStatus status = eHAL_STATUS_SUCCESS;
2863 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2864 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2865
2866 if (!pSession)
2867 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002868 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002869 return (status);
2870 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 if(pSession->pConnectBssDesc)
2872 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302873 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002874 }
2875 else
2876 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002877 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002878 return (status);
2879 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002880 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2881 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002882
2883 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2884
2885 return (status);
2886}
Jeff Johnson295189b2012-06-20 16:38:30 -07002887eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2888{
2889 eHalStatus status = eHAL_STATUS_SUCCESS;
2890 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2891 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002892
2893 if (!pSession)
2894 {
2895 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2896 return eHAL_STATUS_FAILURE;
2897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002898
2899 if(pSession->pConnectBssDesc)
2900 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302901 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002902 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002903 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2904 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002905 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2906
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302907 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Mukul Sharma45049182014-06-17 23:34:10 +05302908 if(HAL_STATUS_SUCCESS(status))
2909 {
2910 csrRoamLinkDown(pMac, sessionId);
2911 }
2912 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002913 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302914 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2915 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002916 }
2917
Jeff Johnson295189b2012-06-20 16:38:30 -07002918 return (status);
2919}
2920
Jeff Johnson295189b2012-06-20 16:38:30 -07002921eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2922{
2923 eHalStatus status = eHAL_STATUS_SUCCESS;
2924 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2925 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002926
2927 if(!pSession)
2928 {
2929 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2930 return eHAL_STATUS_FAILURE;
2931 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002932
2933 // If no BSS description was found in this connection (happens with start IBSS), then
2934 // nix the BSS description that we keep around for the connected BSS) and get out...
2935 if(NULL == pBssDesc)
2936 {
2937 csrFreeConnectBssDesc(pMac, sessionId);
2938 }
2939 else
2940 {
2941 size = pBssDesc->length + sizeof( pBssDesc->length );
2942 if(NULL != pSession->pConnectBssDesc)
2943 {
2944 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2945 {
2946 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2947 csrFreeConnectBssDesc(pMac, sessionId);
2948 }
2949 }
2950 if(NULL == pSession->pConnectBssDesc)
2951 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302952 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002953 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302954 if (NULL == pSession->pConnectBssDesc)
2955 status = eHAL_STATUS_FAILURE;
2956 else
2957 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2958 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002959 return (status);
2960}
2961
Jeff Johnson295189b2012-06-20 16:38:30 -07002962eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2963 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2964 tDot11fBeaconIEs *pIes)
2965{
2966 eHalStatus status = eHAL_STATUS_SUCCESS;
2967 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302969 if (pIes == NULL)
2970 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002971
Jeff Johnson295189b2012-06-20 16:38:30 -07002972 do
2973 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302974 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2975 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002976 //get qos
2977 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2978 //get SSID
2979 if(pIes->SSID.present)
2980 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302981 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002982 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2983 }
2984 else
2985 pBssConfig->SSID.length = 0;
2986 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2987 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002988 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 //Return failed if profile doesn't have an SSID either.
2990 if(pProfile->SSIDs.numOfSSIDs == 0)
2991 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002992 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002993 status = eHAL_STATUS_FAILURE;
2994 break;
2995 }
2996 }
2997 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2998 {
2999 pBssConfig->eBand = eCSR_BAND_5G;
3000 }
3001 else
3002 {
3003 pBssConfig->eBand = eCSR_BAND_24;
3004 }
3005 //phymode
3006 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
3007 {
3008 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
3009 }
3010 else
3011 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003012 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003013 //force it
3014 if(eCSR_BAND_24 == pBssConfig->eBand)
3015 {
3016 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
3017 }
3018 else
3019 {
3020 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
3021 }
3022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003023 //Qos
3024 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
3025 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
3026 {
3027 //Joining BSS is not 11n capable and WMM is disabled on client.
3028 //Disable QoS and WMM
3029 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3030 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303031
3032 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05303033 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303034 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
3035 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
3036 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
3037 {
3038 //Joining BSS is 11n capable and WMM is disabled on AP.
3039 //Assume all HT AP's are QOS AP's and enable WMM
3040 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3041 }
3042
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 //auth type
3044 switch( pProfile->negotiatedAuthType )
3045 {
3046 default:
3047 case eCSR_AUTH_TYPE_WPA:
3048 case eCSR_AUTH_TYPE_WPA_PSK:
3049 case eCSR_AUTH_TYPE_WPA_NONE:
3050 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3051 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3052 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003053 case eCSR_AUTH_TYPE_SHARED_KEY:
3054 pBssConfig->authType = eSIR_SHARED_KEY;
3055 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 case eCSR_AUTH_TYPE_AUTOSWITCH:
3057 pBssConfig->authType = eSIR_AUTO_SWITCH;
3058 break;
3059 }
3060 //short slot time
3061 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3062 {
3063 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3064 }
3065 else
3066 {
3067 pBssConfig->uShortSlotTime = 0;
3068 }
3069 if(pBssConfig->BssCap.ibss)
3070 {
3071 //We don't support 11h on IBSS
3072 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3073 }
3074 else
3075 {
3076 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3077 }
3078 //power constraint
3079 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3080 //heartbeat
3081 if ( CSR_IS_11A_BSS( pBssDesc ) )
3082 {
3083 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3084 }
3085 else
3086 {
3087 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3088 }
3089 //Join timeout
3090 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07003091 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 if ( pBssDesc->beaconInterval )
3093 {
3094 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07003095 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003096 }
3097 else
3098 {
3099 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3100 }
3101 //validate CB
3102 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sandeep Puligilla60342762014-01-30 21:05:37 +05303103
Jeff Johnson295189b2012-06-20 16:38:30 -07003104 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003105 return (status);
3106}
3107
Jeff Johnson295189b2012-06-20 16:38:30 -07003108static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3109 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3110{
3111 eHalStatus status = eHAL_STATUS_SUCCESS;
3112 tANI_U8 operationChannel = 0;
3113 tANI_U8 qAPisEnabled = FALSE;
3114 //SSID
3115 pBssConfig->SSID.length = 0;
3116 if(pProfile->SSIDs.numOfSSIDs)
3117 {
3118 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303119 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3120 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003121 }
3122 else
3123 {
3124 //SSID must present
3125 return eHAL_STATUS_FAILURE;
3126 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003127 //Settomg up the capabilities
3128 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3129 {
3130 pBssConfig->BssCap.ibss = 1;
3131 }
3132 else
3133 {
3134 pBssConfig->BssCap.ess = 1;
3135 }
3136 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3137 {
3138 pBssConfig->BssCap.privacy = 1;
3139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003140 pBssConfig->eBand = pMac->roam.configParam.eBand;
3141 //phymode
3142 if(pProfile->ChannelInfo.ChannelList)
3143 {
3144 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3147 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003148 //QOS
3149 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003150 if ( pBssConfig->BssCap.ess == 1 )
3151 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 /*For Softap case enable WMM*/
3153 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3154 qAPisEnabled = TRUE;
3155 }
3156 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003157 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3158 qAPisEnabled = TRUE;
3159 } else {
3160 qAPisEnabled = FALSE;
3161 }
3162 } else {
3163 qAPisEnabled = TRUE;
3164 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3166 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3167 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3168 )
3169 {
3170 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3171 } else {
3172 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3173 }
3174
3175 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003176 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 {
3178 default:
3179 case eCSR_AUTH_TYPE_WPA:
3180 case eCSR_AUTH_TYPE_WPA_PSK:
3181 case eCSR_AUTH_TYPE_WPA_NONE:
3182 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3183 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3184 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003185 case eCSR_AUTH_TYPE_SHARED_KEY:
3186 pBssConfig->authType = eSIR_SHARED_KEY;
3187 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 case eCSR_AUTH_TYPE_AUTOSWITCH:
3189 pBssConfig->authType = eSIR_AUTO_SWITCH;
3190 break;
3191 }
3192 //short slot time
3193 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3194 {
3195 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3196 }
3197 else
3198 {
3199 pBssConfig->uShortSlotTime = 0;
3200 }
3201 //power constraint. We don't support 11h on IBSS
3202 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3203 pBssConfig->uPowerLimit = 0;
3204 //heartbeat
3205 if ( eCSR_BAND_5G == pBssConfig->eBand )
3206 {
3207 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3208 }
3209 else
3210 {
3211 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3212 }
3213 //Join timeout
3214 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003215
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 return (status);
3217}
Jeff Johnson295189b2012-06-20 16:38:30 -07003218static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3219{
3220 eHalStatus status = eHAL_STATUS_FAILURE;
3221 tDot11fBeaconIEs *pIes = NULL;
3222
3223 do
3224 {
3225 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3226 {
3227 //err msg
3228 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003229 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 break;
3231 }
3232 //check if the AP is QAP & it supports APSD
3233 if( CSR_IS_QOS_BSS(pIes) )
3234 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303235 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003236 }
3237 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303238
3239 if (NULL != pIes)
3240 {
3241 vos_mem_free(pIes);
3242 }
3243
Jeff Johnson295189b2012-06-20 16:38:30 -07003244 return status;
3245}
3246
Jeff Johnson295189b2012-06-20 16:38:30 -07003247void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3248{
Jeff Johnson295189b2012-06-20 16:38:30 -07003249 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3250 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3251 // See !!Note: below in this function...
3252 tANI_U32 PrivacyEnabled = 0;
3253 tANI_U32 RsnEnabled = 0;
3254 tANI_U32 WepDefaultKeyId = 0;
3255 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3256 tANI_U32 Key0Length = 0;
3257 tANI_U32 Key1Length = 0;
3258 tANI_U32 Key2Length = 0;
3259 tANI_U32 Key3Length = 0;
3260
3261 // Reserve for the biggest key
3262 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3263 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3264 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3265 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3266
3267 switch ( pProfile->negotiatedUCEncryptionType )
3268 {
3269 case eCSR_ENCRYPT_TYPE_NONE:
3270
3271 // for NO encryption, turn off Privacy and Rsn.
3272 PrivacyEnabled = 0;
3273 RsnEnabled = 0;
3274
3275 // WEP key length and Wep Default Key ID don't matter in this case....
3276
3277 // clear out the WEP keys that may be hanging around.
3278 Key0Length = 0;
3279 Key1Length = 0;
3280 Key2Length = 0;
3281 Key3Length = 0;
3282
3283 break;
3284
3285 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303286 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003287
3288 // Privacy is ON. NO RSN for Wep40 static key.
3289 PrivacyEnabled = 1;
3290 RsnEnabled = 0;
3291
3292 // Set the Wep default key ID.
3293 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003294 // Wep key size if 5 bytes (40 bits).
3295 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3296
3297 // set encryption keys in the CFG database or clear those that are not present in this profile.
3298 if ( pProfile->Keys.KeyLength[0] )
3299 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303300 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3301 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3303 }
3304 else
3305 {
3306 Key0Length = 0;
3307 }
3308
3309 if ( pProfile->Keys.KeyLength[1] )
3310 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303311 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3312 WNI_CFG_WEP_KEY_LENGTH_5);
3313 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003314 }
3315 else
3316 {
3317 Key1Length = 0;
3318 }
3319
3320 if ( pProfile->Keys.KeyLength[2] )
3321 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303322 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3323 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3325 }
3326 else
3327 {
3328 Key2Length = 0;
3329 }
3330
3331 if ( pProfile->Keys.KeyLength[3] )
3332 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303333 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3334 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3336 }
3337 else
3338 {
3339 Key3Length = 0;
3340 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 break;
3342
3343 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303344 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003345
3346 // Privacy is ON. NO RSN for Wep40 static key.
3347 PrivacyEnabled = 1;
3348 RsnEnabled = 0;
3349
3350 // Set the Wep default key ID.
3351 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3352
3353 // Wep key size if 13 bytes (104 bits).
3354 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3355
3356 // set encryption keys in the CFG database or clear those that are not present in this profile.
3357 if ( pProfile->Keys.KeyLength[0] )
3358 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303359 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3360 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003361 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3362 }
3363 else
3364 {
3365 Key0Length = 0;
3366 }
3367
3368 if ( pProfile->Keys.KeyLength[1] )
3369 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303370 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3371 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3373 }
3374 else
3375 {
3376 Key1Length = 0;
3377 }
3378
3379 if ( pProfile->Keys.KeyLength[2] )
3380 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303381 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3382 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003383 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3384 }
3385 else
3386 {
3387 Key2Length = 0;
3388 }
3389
3390 if ( pProfile->Keys.KeyLength[3] )
3391 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303392 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3393 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3395 }
3396 else
3397 {
3398 Key3Length = 0;
3399 }
3400
3401 break;
3402
Jeff Johnson295189b2012-06-20 16:38:30 -07003403 case eCSR_ENCRYPT_TYPE_TKIP:
3404 case eCSR_ENCRYPT_TYPE_AES:
3405#ifdef FEATURE_WLAN_WAPI
3406 case eCSR_ENCRYPT_TYPE_WPI:
3407#endif /* FEATURE_WLAN_WAPI */
3408 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3409 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3410 PrivacyEnabled = (0 != fPrivacy);
3411
3412 // turn on RSN enabled for WPA associations
3413 RsnEnabled = 1;
3414
3415 // WEP key length and Wep Default Key ID don't matter in this case....
3416
3417 // clear out the static WEP keys that may be hanging around.
3418 Key0Length = 0;
3419 Key1Length = 0;
3420 Key2Length = 0;
3421 Key3Length = 0;
3422
3423 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003424 default:
3425 PrivacyEnabled = 0;
3426 RsnEnabled = 0;
3427 break;
3428 }
3429
3430 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3431 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3432 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3433 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3434 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3435 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3436 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3437 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3438}
3439
Jeff Johnson295189b2012-06-20 16:38:30 -07003440static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3441{
3442 tANI_U32 len = 0;
3443 if(pSSID->length <= WNI_CFG_SSID_LEN)
3444 {
3445 len = pSSID->length;
3446 }
3447 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3448}
3449
Jeff Johnson295189b2012-06-20 16:38:30 -07003450eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3451{
3452 eHalStatus status = eHAL_STATUS_SUCCESS;
3453 tANI_U32 QoSEnabled;
3454 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 // set the CFG enable/disable variables based on the qosType being configured...
3456 switch( qosType )
3457 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3459 QoSEnabled = FALSE;
3460 WmeEnabled = TRUE;
3461 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003462 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3463 QoSEnabled = FALSE;
3464 WmeEnabled = TRUE;
3465 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003466 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3467 QoSEnabled = FALSE;
3468 WmeEnabled = TRUE;
3469 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003470 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3471 QoSEnabled = TRUE;
3472 WmeEnabled = FALSE;
3473 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 case eCSR_MEDIUM_ACCESS_11e_HCF:
3475 QoSEnabled = TRUE;
3476 WmeEnabled = FALSE;
3477 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 default:
3479 case eCSR_MEDIUM_ACCESS_DCF:
3480 QoSEnabled = FALSE;
3481 WmeEnabled = FALSE;
3482 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003483 }
3484 //save the WMM setting for later use
3485 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303486 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003487 return (status);
3488}
Jeff Johnson295189b2012-06-20 16:38:30 -07003489static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3490 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3491{
3492 eHalStatus status = eHAL_STATUS_FAILURE;
3493 int i;
3494 eCsrCfgDot11Mode cfgDot11Mode;
3495 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303496 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3497 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003499
3500 if( NULL != pIes )
3501 {
3502 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003503 // Originally, we thought that for 11a networks, the 11a rates are always
3504 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3505 // appear in the Operational Rate set. Consequently, in either case, we
3506 // would blindly put the rates we support into our Operational Rate set
3507 // (including the basic rates, which we have already verified are
3508 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 // However, it turns out that this is not always the case. Some AP's
3510 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3511 // too. Now, we're a little more careful:
3512 pDstRate = pOpRateSet->rate;
3513 if(pIes->SuppRates.present)
3514 {
3515 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3516 {
3517 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3518 {
3519 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003520 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 }
3522 }
3523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003524 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3525 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3526 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3527 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3528 {
3529 // If there are Extended Rates in the beacon, we will reflect those
3530 // extended rates that we support in out Extended Operational Rate
3531 // set:
3532 pDstRate = pExRateSet->rate;
3533 if(pIes->ExtSuppRates.present)
3534 {
3535 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3536 {
3537 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3538 {
3539 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3540 pExRateSet->numRates++;
3541 }
3542 }
3543 }
3544 }
3545 }//Parsing BSSDesc
3546 else
3547 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003548 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003549 }
3550 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3551 return status;
3552}
3553
3554static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3555 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3556{
3557 int i;
3558 tANI_U8 *pDstRate;
3559 eCsrCfgDot11Mode cfgDot11Mode;
3560 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3561 tANI_U32 OperationalRatesLength = 0;
3562 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3563 tANI_U32 ExtendedOperationalRatesLength = 0;
3564 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3565 tANI_U32 ProprietaryOperationalRatesLength = 0;
3566 tANI_U32 PropRatesEnable = 0;
3567 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3568 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003570 if( NULL != pIes )
3571 {
3572 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 // Originally, we thought that for 11a networks, the 11a rates are always
3574 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3575 // appear in the Operational Rate set. Consequently, in either case, we
3576 // would blindly put the rates we support into our Operational Rate set
3577 // (including the basic rates, which we have already verified are
3578 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003579 // However, it turns out that this is not always the case. Some AP's
3580 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3581 // too. Now, we're a little more careful:
3582 pDstRate = OperationalRates;
3583 if(pIes->SuppRates.present)
3584 {
3585 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3586 {
3587 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3588 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3589 {
3590 *pDstRate++ = pIes->SuppRates.rates[ i ];
3591 OperationalRatesLength++;
3592 }
3593 }
3594 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003595 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3596 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3597 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3598 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3599 {
3600 // If there are Extended Rates in the beacon, we will reflect those
3601 // extended rates that we support in out Extended Operational Rate
3602 // set:
3603 pDstRate = ExtendedOperationalRates;
3604 if(pIes->ExtSuppRates.present)
3605 {
3606 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3607 {
3608 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3609 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3610 {
3611 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3612 ExtendedOperationalRatesLength++;
3613 }
3614 }
3615 }
3616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003617 // Enable proprietary MAC features if peer node is Airgo node and STA
3618 // user wants to use them
3619 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3620 {
3621 PropRatesEnable = 1;
3622 }
3623 else
3624 {
3625 PropRatesEnable = 0;
3626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003627 // For ANI network companions, we need to populate the proprietary rate
3628 // set with any proprietary rates we found in the beacon, only if user
3629 // allows them...
3630 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3631 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3632 {
3633 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3634 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3635 {
3636 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3637 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303638 vos_mem_copy(ProprietaryOperationalRates,
3639 pIes->Airgo.PropSuppRates.rates,
3640 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 }
3642 else {
3643 // No proprietary modes...
3644 ProprietaryOperationalRatesLength = 0;
3645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 /* Get MCS Rate */
3647 pDstRate = MCSRateIdxSet;
3648 if ( pIes->HTCaps.present )
3649 {
3650 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3651 {
3652 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3653 {
3654 MCSRateLength++;
3655 *pDstRate++ = i;
3656 }
3657 }
3658 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 // Set the operational rate set CFG variables...
3660 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3661 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3662 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3663 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3664 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3665 ProprietaryOperationalRates,
3666 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3667 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3668 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3669 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3670 }//Parsing BSSDesc
3671 else
3672 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003673 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 }
3675}
3676
Jeff Johnson295189b2012-06-20 16:38:30 -07003677static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3678 tCsrRoamProfile *pProfile )
3679{
3680 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3681 { 8,
3682 { SIR_MAC_RATE_6,
3683 SIR_MAC_RATE_9,
3684 SIR_MAC_RATE_12,
3685 SIR_MAC_RATE_18,
3686 SIR_MAC_RATE_24,
3687 SIR_MAC_RATE_36,
3688 SIR_MAC_RATE_48,
3689 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003690 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3691 { 4,
3692 { SIR_MAC_RATE_1,
3693 SIR_MAC_RATE_2,
3694 SIR_MAC_RATE_5_5,
3695 SIR_MAC_RATE_11 } } };
3696
3697
3698 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3699 { SIR_MAC_RATE_72,
3700 SIR_MAC_RATE_96,
3701 SIR_MAC_RATE_108 } };
3702 eCsrCfgDot11Mode cfgDot11Mode;
3703 eCsrBand eBand;
3704 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3705 tANI_U32 OperationalRatesLength = 0;
3706 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3707 tANI_U32 ExtendedOperationalRatesLength = 0;
3708 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3709 tANI_U32 ProprietaryOperationalRatesLength = 0;
3710 tANI_U32 PropRatesEnable = 0;
3711 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 if(pProfile->ChannelInfo.ChannelList)
3713 {
3714 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3715 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003716 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003717 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3718 // networks, the 11b rates appear in the Operational Rate set. In either case,
3719 // we can blindly put the rates we support into our Operational Rate set
3720 // (including the basic rates, which we have already verified are supported
3721 // earlier in the roaming decision).
3722 if ( eCSR_BAND_5G == eBand )
3723 {
3724 // 11a rates into the Operational Rate Set.
3725 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3726 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303727 vos_mem_copy(OperationalRates,
3728 DefaultSupportedRates11a.supportedRateSet.rate,
3729 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003730
3731 // Nothing in the Extended rate set.
3732 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 // populate proprietary rates if user allows them
3734 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3735 {
3736 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3737 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303738 vos_mem_copy(ProprietaryOperationalRates,
3739 DefaultSupportedPropRates.propRate,
3740 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 }
3742 else
3743 {
3744 // No proprietary modes
3745 ProprietaryOperationalRatesLength = 0;
3746 }
3747 }
3748 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3749 {
3750 // 11b rates into the Operational Rate Set.
3751 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3752 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303753 vos_mem_copy(OperationalRates,
3754 DefaultSupportedRates11b.supportedRateSet.rate,
3755 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 // Nothing in the Extended rate set.
3757 ExtendedOperationalRatesLength = 0;
3758 // No proprietary modes
3759 ProprietaryOperationalRatesLength = 0;
3760 }
3761 else
3762 {
3763 // 11G
3764
3765 // 11b rates into the Operational Rate Set.
3766 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3767 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303768 vos_mem_copy(OperationalRates,
3769 DefaultSupportedRates11b.supportedRateSet.rate,
3770 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003771
3772 // 11a rates go in the Extended rate set.
3773 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3774 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303775 vos_mem_copy(ExtendedOperationalRates,
3776 DefaultSupportedRates11a.supportedRateSet.rate,
3777 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003778
3779 // populate proprietary rates if user allows them
3780 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3781 {
3782 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3783 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303784 vos_mem_copy(ProprietaryOperationalRates,
3785 DefaultSupportedPropRates.propRate,
3786 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003787 }
3788 else
3789 {
3790 // No proprietary modes
3791 ProprietaryOperationalRatesLength = 0;
3792 }
3793 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003794 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3795 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3796 {
3797 PropRatesEnable = 1;
3798 }
3799 else
3800 {
3801 PropRatesEnable = 0;
3802 }
3803
3804 // Set the operational rate set CFG variables...
3805 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3806 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3807 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3808 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3809 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3810 ProprietaryOperationalRates,
3811 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3812 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003813}
Jeff Johnson295189b2012-06-20 16:38:30 -07003814void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3815{
3816 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003817
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3819 tANI_U32 sessionId;
3820 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 if(NULL == pEntry)
3822 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003823 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003824 return;
3825 }
3826 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3827 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05303828 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
3829 " current state : %d sub state : %d "),
3830 result, pMac->roam.curState[sessionId],
3831 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003832 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3833 {
3834 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3835 }
3836}
3837
Jeff Johnson295189b2012-06-20 16:38:30 -07003838//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3839tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3840{
3841 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3842 {
3843 return (WNI_CFG_PHY_MODE_11B);
3844 }
3845 else
3846 {
3847 if(eCSR_BAND_24 == band)
3848 return (WNI_CFG_PHY_MODE_11G);
3849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 return (WNI_CFG_PHY_MODE_11A);
3851}
Jeff Johnson295189b2012-06-20 16:38:30 -07003852
Jeff Johnsone7245742012-09-05 17:12:55 -07003853
3854#ifdef WLAN_FEATURE_11AC
3855ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3856{
3857 switch ( aniCBMode )
3858 {
3859 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3860 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3861 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3862 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3863 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3864 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3865 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3866 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3867 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003868 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003869 return PHY_SINGLE_CHANNEL_CENTERED;
3870 }
3871}
3872#endif
3873
Jeff Johnson295189b2012-06-20 16:38:30 -07003874//pIes may be NULL
3875eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3876 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303877 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003878{
3879 eHalStatus status = eHAL_STATUS_SUCCESS;
3880 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3881 tANI_U8 channel = 0;
3882 //Make sure we have the domain info for the BSS we try to connect to.
3883 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303884 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05303886 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003887 {
3888 //Make sure the 11d info from this BSSDesc can be applied
3889 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303890 if (VOS_TRUE == resetCountry)
3891 {
3892 csrApplyCountryInformation(pMac, FALSE);
3893 }
3894 else
3895 {
3896 csrApplyCountryInformation(pMac, TRUE);
3897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 }
Kiran4a17ebe2013-01-31 10:43:43 -08003899 if ((csrIs11dSupported (pMac)) && pIes)
3900 {
3901 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003902 {
Kiran4a17ebe2013-01-31 10:43:43 -08003903 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003904 }
3905 else
3906 {
3907 //Let's also update the below to make sure we don't update CC while
3908 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303909 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003910 pBssDesc->bssId, sizeof(tSirMacAddr));
3911 }
Kiran4a17ebe2013-01-31 10:43:43 -08003912 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 //Qos
3915 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3916 //SSID
3917 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3918 //fragment threshold
3919 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3920 //RTS threshold
3921 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3922
3923 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 //Auth type
3925 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3926 //encryption type
3927 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3928 //short slot time
3929 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 //11d
3931 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3932 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3933 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 /*//11h
3935 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3936 */
3937 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3938 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003939
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003940 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003941 {
3942 channel = pProfile->operationChannel;
3943 }
3944 else
3945 {
3946 if(pBssDesc)
3947 {
3948 channel = pBssDesc->channelId;
3949 }
3950 }
3951 if(0 != channel)
3952 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05303953 if(CSR_IS_CHANNEL_24GHZ(channel) &&
3954 !pMac->roam.configParam.channelBondingMode24GHz &&
3955 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
3956 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05303958 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
3959 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
3960 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07003961 }
3962 else
3963 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003964 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 }
3966 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003967#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003968 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3969 // in function csrConvertCBIniValueToPhyCBState()
3970 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3971 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003972 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003973 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003974 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003975 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05303976 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003977 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003978 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003979 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003980 }
3981 else
3982#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3984 //Rate
3985 //Fixed Rate
3986 if(pBssDesc)
3987 {
3988 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3989 }
3990 else
3991 {
3992 csrSetCfgRateSetFromProfile(pMac, pProfile);
3993 }
3994 //Make this the last CFG to set. The callback will trigger a join_req
3995 //Join time out
3996 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3997
3998 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003999 return (status);
4000}
4001
Jeff Johnson295189b2012-06-20 16:38:30 -07004002eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4003 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
4004{
4005 eHalStatus status;
4006 tBssConfigParam *pBssConfig;
4007 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004008
4009 if(!pSession)
4010 {
4011 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4012 return eHAL_STATUS_FAILURE;
4013 }
4014
Kiet Lam64c1b492013-07-12 13:56:44 +05304015 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
4016 if ( NULL == pBssConfig )
4017 status = eHAL_STATUS_FAILURE;
4018 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304020 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
4022 if(HAL_STATUS_SUCCESS(status))
4023 {
4024 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004025 /* This will allow to pass cbMode during join req */
4026 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004027 //For IBSS, we need to prepare some more information
4028 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004030 )
4031 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004032 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004033 }
4034 // If we are in an IBSS, then stop the IBSS...
4035 ////Not worry about WDS connection for now
4036 if ( csrIsConnStateIbss( pMac, sessionId ) )
4037 {
4038 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
4039 }
4040 else
4041 {
4042 // if we are in an Infrastructure association....
4043 if ( csrIsConnStateInfra( pMac, sessionId ) )
4044 {
4045 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
4046 // across SSIDs (roaming to a new SSID)... //
4047 //Not worry about WDS connection for now
4048 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304049 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 {
4051 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304052 status = csrRoamIssueDisassociate( pMac, sessionId,
4053 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304055 else
4056 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004057 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4058 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304059 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304061 // Set parameters for this Bss.
4062 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4063 pBssDesc, pBssConfig,
4064 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304066 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304068 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 {
4070 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4071 // Nothing to stop.
4072 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304074 )
4075 {
4076 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4077 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4078 // Set parameters for this Bss.
4079 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4080 pBssDesc, pBssConfig,
4081 pIes, is11rRoamingFlag);
4082 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004083 }
4084 }
4085 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304086 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004087 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004088 return (status);
4089}
4090
Jeff Johnson295189b2012-06-20 16:38:30 -07004091eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4092 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4093{
4094 eCsrJoinState eRoamState = eCsrContinueRoaming;
4095 eHalStatus status;
4096 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4097 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4098 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004099
4100 if(!pSession)
4101 {
4102 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4103 return (eCsrStopRoaming);
4104 }
4105
Jeff Johnson295189b2012-06-20 16:38:30 -07004106 if( CSR_IS_WDS_STA( pProfile ) )
4107 {
4108 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4109 if( !HAL_STATUS_SUCCESS( status ) )
4110 {
4111 eRoamState = eCsrStopRoaming;
4112 }
4113 }
4114 else
4115 {
4116 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4117 {
4118 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4119 return (eCsrStopRoaming);
4120 }
4121 if ( csrIsInfraBssDesc( pBssDesc ) )
4122 {
4123 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4124 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4125 // have changed and handle the changes (without disturbing the current association).
4126
4127 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4128 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4129 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4130 )
4131 {
4132 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4133 // with Authenticating first. To force this, stop the current association (Disassociate) and
4134 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4135 // a new Association.
4136 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4137 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004138 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4140 {
4141 eRoamState = eCsrReassocToSelfNoCapChange;
4142 }
4143 else
4144 {
4145 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004146 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304147 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004148 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4149 if(HAL_STATUS_SUCCESS(status))
4150 {
4151 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004152 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004153 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304154 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4155 pBssDesc, &bssConfig,
4156 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 if(!HAL_STATUS_SUCCESS(status))
4158 {
4159 eRoamState = eCsrStopRoaming;
4160 }
4161 }
4162 else
4163 {
4164 eRoamState = eCsrStopRoaming;
4165 }
4166 }//same profile
4167 }
4168 else
4169 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304170 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004171 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4172 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304173 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4174 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304176 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004177 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304178 }
4179 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004180 {
4181 // 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 -07004182 // stop the existing network before attempting to join the new network...
4183 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4184 {
4185 eRoamState = eCsrStopRoaming;
4186 }
4187 }
4188 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304189 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 {
4191 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4192 {
4193 eRoamState = eCsrStopRoaming;
4194 }
4195 }
4196 if( pIesLocal && !pScanResult->pvIes )
4197 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304198 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 }
4200 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004201 return( eRoamState );
4202}
4203
Jeff Johnson295189b2012-06-20 16:38:30 -07004204eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4205 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4206{
4207 eHalStatus status = eHAL_STATUS_SUCCESS;
4208 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304209 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 roamInfo.pBssDesc = pBssDesc;
4211 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4212 return (status);
4213}
Jeff Johnson295189b2012-06-20 16:38:30 -07004214//In case no matching BSS is found, use whatever default we can find
4215static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4216{
4217 //Need to get all negotiated types in place first
4218 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004219 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004220 {
4221 default:
4222 case eCSR_AUTH_TYPE_WPA:
4223 case eCSR_AUTH_TYPE_WPA_PSK:
4224 case eCSR_AUTH_TYPE_WPA_NONE:
4225 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4226 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4227 break;
4228
4229 case eCSR_AUTH_TYPE_SHARED_KEY:
4230 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4231 break;
4232
4233 case eCSR_AUTH_TYPE_AUTOSWITCH:
4234 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4235 break;
4236 }
4237 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4238 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4239 //In this case, the multicast encryption needs to follow the uncast ones.
4240 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4241 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4242}
4243
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004244
4245static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4246{
4247 switch(pCommand->u.roamCmd.roamReason)
4248 {
4249 case eCsrLostLink1:
4250 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4251 break;
4252 case eCsrLostLink2:
4253 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4254 break;
4255 case eCsrLostLink3:
4256 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4257 break;
4258 default:
4259 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4260 pCommand->u.roamCmd.roamReason);
4261 break;
4262 }
4263}
4264
Jeff Johnson295189b2012-06-20 16:38:30 -07004265static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4266{
4267 eHalStatus status;
4268 tCsrScanResult *pScanResult = NULL;
4269 eCsrJoinState eRoamState = eCsrStopRoaming;
4270 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4271 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4272 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4273#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4274 v_U8_t acm_mask = 0;
4275#endif
4276 tANI_U32 sessionId = pCommand->sessionId;
4277 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4278 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4279 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004280
4281 if(!pSession)
4282 {
4283 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4284 return (eCsrStopRoaming);
4285 }
4286
Jeff Johnson295189b2012-06-20 16:38:30 -07004287 do
4288 {
4289 // Check for Cardbus eject condition, before trying to Roam to any BSS
4290 //***if( !balIsCardPresent(pAdapter) ) break;
4291
Kiet Lam64c1b492013-07-12 13:56:44 +05304292 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304293 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 if(NULL != pBSSList)
4295 {
4296 // When handling AP's capability change, continue to associate to
4297 // same BSS and make sure pRoamBssEntry is not Null.
4298 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4299 {
4300 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4301 {
4302 //Try the first BSS
4303 pCommand->u.roamCmd.pLastRoamBss = NULL;
4304 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4305 }
4306 else
4307 {
4308 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4309 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4310 {
4311 //Done with all the BSSs
4312 //In this case, will tell HDD the completion
4313 break;
4314 }
4315 else
4316 {
4317 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304318 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004319 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4320 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4321 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4322 pRoamInfo = &roamInfo;
4323 }
4324 }
4325 while(pCommand->u.roamCmd.pRoamBssEntry)
4326 {
4327 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004328 /*If concurrency enabled take the concurrent connected channel first. */
4329 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304330 if (vos_concurrent_open_sessions_running() &&
4331 !csrIsValidMcConcurrentSession(pMac, sessionId,
4332 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004333 {
4334 concurrentChannel =
4335 csrGetConcurrentOperationChannel(pMac);
4336 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004337 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 if ((concurrentChannel) &&
4339 (concurrentChannel ==
4340 pScanResult->Result.BssDescriptor.channelId))
4341 {
4342 //make this 0 because we do not want the
4343 //below check to pass as we don't want to
4344 //connect on other channel
4345 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4346 FL("Concurrent channel match =%d"),
4347 concurrentChannel);
4348 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004349 }
4350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004351
4352 if (!concurrentChannel)
4353 {
4354
4355 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4356 sessionId, &pScanResult->Result.BssDescriptor,
4357 pCommand->u.roamCmd.roamId)))
4358 {
4359 //Ok to roam this
4360 break;
4361 }
4362 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004363 else
4364 {
4365 eRoamState = eCsrStopRoamingDueToConcurrency;
4366 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004367 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4368 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4369 {
4370 //Done with all the BSSs
4371 fDone = eANI_BOOLEAN_TRUE;
4372 break;
4373 }
4374 }
4375 if(fDone)
4376 {
4377 break;
4378 }
4379 }
4380 }
4381 //We have something to roam, tell HDD when it is infra.
4382 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4383 //For WDS, the indication is eCSR_ROAM_WDS_IND
4384 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4385 {
4386 if(pRoamInfo)
4387 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004388 if(pSession->bRefAssocStartCnt)
4389 {
4390 pSession->bRefAssocStartCnt--;
4391 //Complete the last association attemp because a new one is about to be tried
4392 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4393 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004394 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004395 }
4396 }
4397 /* If the roaming has stopped, not to continue the roaming command*/
4398 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4399 {
4400 //No need to complete roaming here as it already completes
4401 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4402 pCommand->u.roamCmd.roamReason);
4403 eRoamState = eCsrStopRoaming;
4404 csrSetAbortRoamingCommand(pMac, pCommand);
4405 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304407 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004408 if(pScanResult)
4409 {
4410 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4412 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004413 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004414 fDone = eANI_BOOLEAN_TRUE;
4415 eRoamState = eCsrStopRoaming;
4416 break;
4417 }
4418 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4419 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4420 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4421 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4422 CSR_IS_QOS_BSS(pIesLocal) &&
4423 CSR_IS_UAPSD_BSS(pIesLocal) )
4424 {
4425#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004426 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4427 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004428#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004429 }
4430 else
4431 {
4432 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4433 }
4434 if( pIesLocal && !pScanResult->Result.pvIes)
4435 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304436 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 }
4438 }
4439 else
4440 {
4441 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4442 }
4443 roamInfo.pProfile = pProfile;
4444 pSession->bRefAssocStartCnt++;
4445 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4446 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004448 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4449 {
4450 // If this is a start IBSS profile, then we need to start the IBSS.
4451 if ( CSR_IS_START_IBSS(pProfile) )
4452 {
4453 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004454 // Attempt to start this IBSS...
4455 csrRoamAssignDefaultParam( pMac, pCommand );
4456 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4457 if(HAL_STATUS_SUCCESS(status))
4458 {
4459 if ( fSameIbss )
4460 {
4461 eRoamState = eCsrStartIbssSameIbss;
4462 }
4463 else
4464 {
4465 eRoamState = eCsrContinueRoaming;
4466 }
4467 }
4468 else
4469 {
4470 //it somehow fail need to stop
4471 eRoamState = eCsrStopRoaming;
4472 }
4473 break;
4474 }
4475 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004477 )
4478 {
4479 // Attempt to start this WDS...
4480 csrRoamAssignDefaultParam( pMac, pCommand );
4481 /* For AP WDS, we dont have any BSSDescription */
4482 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4483 if(HAL_STATUS_SUCCESS(status))
4484 {
4485 eRoamState = eCsrContinueRoaming;
4486 }
4487 else
4488 {
4489 //it somehow fail need to stop
4490 eRoamState = eCsrStopRoaming;
4491 }
4492 }
4493 else
4494 {
4495 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004496 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004497 eRoamState = eCsrStopRoaming;
4498 break;
4499 }
4500 }
4501 else //We have BSS
4502 {
4503 //Need to assign these value because they are used in csrIsSameProfile
4504 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004505 /* The OSEN IE doesn't provide the cipher suite.
4506 * Therefore set to constant value of AES */
4507 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4508 {
4509 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4510 eCSR_ENCRYPT_TYPE_AES;
4511 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4512 eCSR_ENCRYPT_TYPE_AES;
4513 }
4514 else
4515 {
4516 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4517 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4518 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4519 pScanResult->mcEncryptionType;
4520 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4522 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4523 {
4524 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4525 {
4526 eRoamState = eCsrStartIbssSameIbss;
4527 break;
4528 }
4529 }
4530 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4531 {
4532 //trying to connect to the one already connected
4533 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4534 eRoamState = eCsrReassocToSelfNoCapChange;
4535 break;
4536 }
4537 // Attempt to Join this Bss...
4538 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4539 break;
4540 }
4541
4542 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4544 {
4545 //Need to indicate association_completion if association_start has been done
4546 if(pSession->bRefAssocStartCnt > 0)
4547 {
4548 pSession->bRefAssocStartCnt--;
4549 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004550 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4552 eCSR_ROAM_ASSOCIATION_COMPLETION,
4553 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4554 }
4555 }
4556
4557 return( eRoamState );
4558}
4559
Jeff Johnson295189b2012-06-20 16:38:30 -07004560static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4561{
4562 eHalStatus status = eHAL_STATUS_SUCCESS;
4563 eCsrJoinState RoamState;
4564 tANI_U32 sessionId = pCommand->sessionId;
4565
Jeff Johnson295189b2012-06-20 16:38:30 -07004566 //***if( hddIsRadioStateOn( pAdapter ) )
4567 {
4568 // Attept to join a Bss...
4569 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004570
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004572 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 {
4574 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 // and if connected in Infrastructure mode...
4576 if ( csrIsConnStateInfra(pMac, sessionId) )
4577 {
4578 //... then we need to issue a disassociation
4579 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4580 if(!HAL_STATUS_SUCCESS(status))
4581 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004582 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004583 //roam command is completed by caller in the failed case
4584 fComplete = eANI_BOOLEAN_TRUE;
4585 }
4586 }
4587 else if( csrIsConnStateIbss(pMac, sessionId) )
4588 {
4589 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4590 if(!HAL_STATUS_SUCCESS(status))
4591 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004592 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 //roam command is completed by caller in the failed case
4594 fComplete = eANI_BOOLEAN_TRUE;
4595 }
4596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004597 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4598 {
4599 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4600 if(!HAL_STATUS_SUCCESS(status))
4601 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004602 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004603 //roam command is completed by caller in the failed case
4604 fComplete = eANI_BOOLEAN_TRUE;
4605 }
4606 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004607 else
4608 {
4609 fComplete = eANI_BOOLEAN_TRUE;
4610 }
4611 if(fComplete)
4612 {
4613 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004614 if(eCsrStopRoamingDueToConcurrency == RoamState)
4615 {
4616 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4617 }
4618 else
4619 {
4620 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4621 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 }
4623 }
4624 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4625 {
4626 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4627 }
4628 else if ( eCsrStartIbssSameIbss == RoamState )
4629 {
4630 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4631 }
4632 }//hddIsRadioStateOn
4633
4634 return status;
4635}
Jeff Johnson295189b2012-06-20 16:38:30 -07004636eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4637{
4638 tANI_U32 sessionId;
4639 tCsrRoamSession *pSession;
4640 tCsrScanResult *pScanResult = NULL;
4641 tSirBssDescription *pBssDesc = NULL;
4642 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004643 sessionId = pCommand->sessionId;
4644 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004645
4646 if(!pSession)
4647 {
4648 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4649 return eHAL_STATUS_FAILURE;
4650 }
4651
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4653 {
4654 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004655 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004656 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4657 return eHAL_STATUS_FAILURE;
4658 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004659 if (pCommand->u.roamCmd.pRoamBssEntry)
4660 {
4661 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4662 pBssDesc = &pScanResult->Result.BssDescriptor;
4663 }
4664 else
4665 {
4666 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004667 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004668 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4669 return eHAL_STATUS_FAILURE;
4670 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4672 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4673 return status;
4674}
4675
Jeff Johnson295189b2012-06-20 16:38:30 -07004676eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4677{
4678 eHalStatus status = eHAL_STATUS_SUCCESS;
4679 tCsrRoamInfo roamInfo;
4680 tANI_U32 sessionId = pCommand->sessionId;
4681 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004682
4683 if(!pSession)
4684 {
4685 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4686 return eHAL_STATUS_FAILURE;
4687 }
Abhishek Singhf4669da2014-05-26 15:07:49 +05304688
Jeff Johnson295189b2012-06-20 16:38:30 -07004689 switch ( pCommand->u.roamCmd.roamReason )
4690 {
4691 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004692 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004693 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004695 case eCsrSmeIssuedDisassocForHandoff:
4696 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4697#if 0 // TODO : Confirm this change
4698 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4699#else
4700 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4701#endif
4702
4703 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004704 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004706 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004707 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004710 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004711 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 case eCsrHddIssuedReassocToSameAP:
4713 case eCsrSmeIssuedReassocToSameAP:
4714 {
4715 tDot11fBeaconIEs *pIes = NULL;
4716
Jeff Johnson295189b2012-06-20 16:38:30 -07004717 if( pSession->pConnectBssDesc )
4718 {
4719 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4720 if(!HAL_STATUS_SUCCESS(status) )
4721 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004722 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004723 }
4724 else
4725 {
4726 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4727 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4728 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004729 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4730 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4731 pSession->bRefAssocStartCnt++;
4732 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4733 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4734
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004735 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004736 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4737 &pCommand->u.roamCmd.roamProfile );
4738 if(!HAL_STATUS_SUCCESS(status))
4739 {
4740 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004741 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004742 }
4743
Kiet Lam64c1b492013-07-12 13:56:44 +05304744 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004745 pIes = NULL;
4746 }
4747 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05304748 else
4749 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004750 break;
4751 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004752 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004753 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4755 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4756 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004757 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004758 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4760 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004761
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 case eCsrStopBss:
4763 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4764 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4765 break;
4766
4767 case eCsrForcedDisassocSta:
4768 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4769 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4770 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4771 pCommand->u.roamCmd.reason);
4772 break;
4773
4774 case eCsrForcedDeauthSta:
4775 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4776 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4777 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4778 pCommand->u.roamCmd.reason);
4779 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004780
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004781 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004782 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004783 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4784 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004785 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004786
4787 default:
4788 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4789
4790 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4791 {
4792 //Remember the roaming profile
4793 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304794 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4795 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004796 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304797 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004798 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4799 }
4800 }
4801
4802 //At this point, original uapsd_mask is saved in pCurRoamProfile
4803 //uapsd_mask in the pCommand may change from this point on.
4804
4805 // Attempt to roam with the new scan results (if we need to..)
4806 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004807 if(!HAL_STATUS_SUCCESS(status))
4808 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004809 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004810 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004811 break;
4812 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004813 return (status);
4814}
4815
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004816void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4817{
4818 pCommand->u.roamCmd.pLastRoamBss = NULL;
4819 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4820 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304821 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004822}
4823
Jeff Johnson295189b2012-06-20 16:38:30 -07004824void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4825{
4826 if(pCommand->u.roamCmd.fReleaseBssList)
4827 {
4828 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4829 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4830 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4831 }
4832 if(pCommand->u.roamCmd.fReleaseProfile)
4833 {
4834 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4835 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4836 }
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);
Jeff Johnson295189b2012-06-20 16:38:30 -07004840}
4841
Jeff Johnson295189b2012-06-20 16:38:30 -07004842void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4843{
Kiet Lam64c1b492013-07-12 13:56:44 +05304844 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004845}
Jeff Johnson295189b2012-06-20 16:38:30 -07004846void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4847{
4848 tListElem *pEntry;
4849 tSmeCmd *pCommand;
4850 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004851 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004852 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4853 if ( pEntry )
4854 {
4855 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004856 // If the head of the queue is Active and it is a ROAM command, remove
4857 // and put this on the Free queue.
4858 if ( eSmeCommandRoam == pCommand->command )
4859 {
4860 //we need to process the result first before removing it from active list because state changes
4861 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4862 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4863 if( fReleaseCommand )
4864 {
4865 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4866 {
4867 csrReleaseCommandRoam( pMac, pCommand );
4868 }
4869 else
4870 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004871 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004872 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004873 }
4874 }
4875 else
4876 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004877 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004878 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004879 }
4880 }
4881 else
4882 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004883 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004884 }
4885 }
4886 else
4887 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004888 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004889 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004890 if( fReleaseCommand )
4891 {
4892 smeProcessPendingQueue( pMac );
4893 }
4894}
4895
Jeff Johnson295189b2012-06-20 16:38:30 -07004896void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4897{
4898 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004899 if(!pSession)
4900 {
4901 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4902 return;
4903 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304904 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4905 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004906 pSession->NumPmkidCandidate = 0;
4907}
Jeff Johnson295189b2012-06-20 16:38:30 -07004908#ifdef FEATURE_WLAN_WAPI
4909void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4910{
4911 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004912 if(!pSession)
4913 {
4914 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4915 return;
4916 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304917 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4918 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004919 pSession->NumBkidCandidate = 0;
4920}
4921#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004922extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4923
Jeff Johnson295189b2012-06-20 16:38:30 -07004924static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4925 tSirBssDescription *pSirBssDesc,
4926 tDot11fBeaconIEs *pIes)
4927{
4928 eHalStatus status = eHAL_STATUS_SUCCESS;
4929 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4930 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004931
4932 if(!pSession)
4933 {
4934 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4935 return eHAL_STATUS_FAILURE;
4936 }
4937
Jeff Johnson295189b2012-06-20 16:38:30 -07004938 if((eCSR_AUTH_TYPE_WPA == authType) ||
4939 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4940 (eCSR_AUTH_TYPE_RSN == authType) ||
4941 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4942#if defined WLAN_FEATURE_VOWIFI_11R
4943 ||
4944 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4945 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4946#endif /* FEATURE_WLAN_WAPI */
4947#ifdef FEATURE_WLAN_WAPI
4948 ||
4949 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4950 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4951#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004952#ifdef WLAN_FEATURE_11W
4953 ||
Abhishek Singhae408032014-09-25 17:22:04 +05304954 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4955 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
Chet Lanctot186b5732013-03-18 10:26:30 -07004956#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 )
4958 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004959 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4960 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004961 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 }
4963 if( pIesLocal )
4964 {
4965 tANI_U32 nIeLen;
4966 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 if((eCSR_AUTH_TYPE_RSN == authType) ||
4968#if defined WLAN_FEATURE_VOWIFI_11R
4969 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4970 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4971#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004972#if defined WLAN_FEATURE_11W
4973 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
Abhishek Singhae408032014-09-25 17:22:04 +05304974 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType) ||
Chet Lanctot186b5732013-03-18 10:26:30 -07004975#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004976 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4977 {
4978 if(pIesLocal->RSN.present)
4979 {
4980 //Calculate the actual length
4981 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4982 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4983 + 2 //akm_suite_count
4984 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4985 + 2; //reserved
4986 if( pIesLocal->RSN.pmkid_count )
4987 {
4988 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4989 }
4990 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304991 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4992 if (NULL == pSession->pWpaRsnRspIE)
4993 status = eHAL_STATUS_FAILURE;
4994 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004995 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304996 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004997 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4998 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4999 //copy upto akm_suites
5000 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05305001 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
5002 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005003 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05305004 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
5005 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005006 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05305007 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
5008 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005009 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07005010 if( pIesLocal->RSN.pwise_cipher_suite_count )
5011 {
5012 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305013 vos_mem_copy(pIeBuf,
5014 pIesLocal->RSN.pwise_cipher_suites,
5015 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005016 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
5017 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305018 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005019 pIeBuf += 2;
5020 if( pIesLocal->RSN.akm_suite_count )
5021 {
5022 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305023 vos_mem_copy(pIeBuf,
5024 pIesLocal->RSN.akm_suites,
5025 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005026 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
5027 }
5028 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05305029 vos_mem_copy(pIeBuf,
5030 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
5031 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005032 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5033 }
5034 }
5035 }
5036 else if((eCSR_AUTH_TYPE_WPA == authType) ||
5037 (eCSR_AUTH_TYPE_WPA_PSK == authType))
5038 {
5039 if(pIesLocal->WPA.present)
5040 {
5041 //Calculate the actual length
5042 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
5043 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
5044 + 2 //auth_suite_count
5045 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
5046 // The WPA capabilities follows the Auth Suite (two octects)--
5047 // this field is optional, and we always "send" zero, so just
5048 // remove it. This is consistent with our assumptions in the
5049 // frames compiler; c.f. bug 15234:
5050 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305051
5052 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5053 if ( NULL == pSession->pWpaRsnRspIE )
5054 status = eHAL_STATUS_FAILURE;
5055 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005056 {
5057 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5058 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5059 pIeBuf = pSession->pWpaRsnRspIE + 2;
5060 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305061 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005062 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305063 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5064 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005065 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305066 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5067 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005068 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5069 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5070 }
5071 }
5072 }
5073#ifdef FEATURE_WLAN_WAPI
5074 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5075 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5076 {
5077 if(pIesLocal->WAPI.present)
5078 {
5079 //Calculate the actual length
5080 nIeLen = 4 //version + akm_suite_count
5081 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5082 + 2 //pwise_cipher_suite_count
5083 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5084 + 6; //gp_cipher_suite + preauth + reserved
5085 if( pIesLocal->WAPI.bkid_count )
5086 {
5087 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5088 }
5089
5090 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305091 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5092 if ( NULL == pSession->pWapiRspIE )
5093 status = eHAL_STATUS_FAILURE;
5094 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005095 {
5096 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5097 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5098 pIeBuf = pSession->pWapiRspIE + 2;
5099 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305100 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005101 pIeBuf += 4;
5102 if( pIesLocal->WAPI.akm_suite_count )
5103 {
5104 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305105 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5106 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005107 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305108 }
5109 vos_mem_copy(pIeBuf,
5110 &pIesLocal->WAPI.unicast_cipher_suite_count,
5111 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005112 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005113 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5114 {
5115 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305116 vos_mem_copy( pIeBuf,
5117 pIesLocal->WAPI.unicast_cipher_suites,
5118 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005119 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5120 }
lukez3c809222013-05-03 10:23:02 -07005121 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305122 vos_mem_copy(pIeBuf,
5123 pIesLocal->WAPI.multicast_cipher_suite,
5124 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005125 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305126 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305127 vos_mem_copy(pIeBuf,
5128 pIesLocal->WAPI.multicast_cipher_suite + 4,
5129 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005130 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305131 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305132 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5133
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005134 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005135 if( pIesLocal->WAPI.bkid_count )
5136 {
5137 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305138 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5139 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005140 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5141 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305142 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005143 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005144 }
5145 }
5146#endif /* FEATURE_WLAN_WAPI */
5147 if( !pIes )
5148 {
5149 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305150 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005151 }
5152 }
5153 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005154 return (status);
5155}
5156
Jeff Johnson295189b2012-06-20 16:38:30 -07005157static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5158{
5159 v_U8_t bACWeights[WLANTL_MAX_AC];
5160 v_U8_t paramBk, paramBe, paramVi, paramVo;
5161 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005162 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5163 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5164 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5165 //This doesn't address the case where the lower AC needs a real higher weight
5166 if( pIEs->WMMParams.present )
5167 {
5168 //no change to the lowest ones
5169 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5170 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5171 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5172 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5173 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5174 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5175 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5176 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5177 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5178 {
5179 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5180 fWeightChange = VOS_TRUE;
5181 }
5182 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5183 {
5184 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5185 fWeightChange = VOS_TRUE;
5186 }
5187 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5188 {
5189 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5190 fWeightChange = VOS_TRUE;
5191 }
5192 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5193 {
5194 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5195 fWeightChange = VOS_TRUE;
5196 }
5197 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5198 {
5199 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5200 fWeightChange = VOS_TRUE;
5201 }
5202 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5203 {
5204 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5205 fWeightChange = VOS_TRUE;
5206 }
5207 if(fWeightChange)
5208 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005209 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005210 bACWeights[2], bACWeights[3]);
5211 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5212 }
5213 }
5214}
Jeff Johnson295189b2012-06-20 16:38:30 -07005215#ifdef WLAN_FEATURE_VOWIFI_11R
5216//Returns whether the current association is a 11r assoc or not
5217tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5218{
5219#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5220 return csrNeighborRoamIs11rAssoc(pMac);
5221#else
5222 return eANI_BOOLEAN_FALSE;
5223#endif
5224}
5225#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005226#ifdef FEATURE_WLAN_ESE
5227//Returns whether the current association is a ESE assoc or not
5228tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005229{
5230#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005231 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005232#else
5233 return eANI_BOOLEAN_FALSE;
5234#endif
5235}
5236#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005237#ifdef FEATURE_WLAN_LFR
5238//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305239tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005240{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305241 tCsrRoamSession *pSession = NULL;
5242
5243 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5244 {
5245 pSession = CSR_GET_SESSION( pMac, sessionId );
5246 if (NULL != pSession->pCurRoamProfile)
5247 {
5248 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5249 {
5250 return eANI_BOOLEAN_FALSE;
5251 }
5252 }
5253 }
5254
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005255#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5256 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5257 {
5258 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5259 }
5260 else
5261#endif
5262 {
5263 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005264 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005265 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005266}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005267
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005268#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005269/* ---------------------------------------------------------------------------
5270
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005271 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005272
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005273 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005274
5275 \param pMac - The handle returned by macOpen.
5276
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005277 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005278
5279---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005280tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005281{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005282 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005283}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005284#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005285
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005286#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5287//Returns whether "FW based BG scan" is currently enabled...or not
5288tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5289{
5290 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5291}
5292#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005293#endif
5294
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005295#if defined(FEATURE_WLAN_ESE)
5296tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005297{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005298 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005299}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005300#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005301
Jeff Johnson295189b2012-06-20 16:38:30 -07005302//Return true means the command can be release, else not
5303static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5304 eCsrRoamCompleteResult Result, void *Context )
5305{
5306 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5307 tSirBssDescription *pSirBssDesc = NULL;
5308 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5309 tCsrScanResult *pScanResult = NULL;
5310 tCsrRoamInfo roamInfo;
5311 sme_QosAssocInfo assocInfo;
5312 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5313 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5314 tDot11fBeaconIEs *pIes = NULL;
5315 tANI_U32 sessionId = pCommand->sessionId;
5316 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5317 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5318 eRoamCmdStatus roamStatus;
5319 eCsrRoamResult roamResult;
5320 eHalStatus status;
5321 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005322 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005323
Jeff Johnson32d95a32012-09-10 13:15:23 -07005324 if(!pSession)
5325 {
5326 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5327 return eANI_BOOLEAN_FALSE;
5328 }
5329
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005330 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005331 switch( Result )
5332 {
5333 case eCsrJoinSuccess:
5334 // reset the IDLE timer
5335 // !!
5336 // !! fall through to the next CASE statement here is intentional !!
5337 // !!
5338 case eCsrReassocSuccess:
5339 if(eCsrReassocSuccess == Result)
5340 {
5341 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5342 }
5343 else
5344 {
5345 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5346 }
5347 // Success Join Response from LIM. Tell NDIS we are connected and save the
5348 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005349 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305350 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005351 //always free the memory here
5352 if(pSession->pWpaRsnRspIE)
5353 {
5354 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305355 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005356 pSession->pWpaRsnRspIE = NULL;
5357 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005358#ifdef FEATURE_WLAN_WAPI
5359 if(pSession->pWapiRspIE)
5360 {
5361 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305362 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005363 pSession->pWapiRspIE = NULL;
5364 }
5365#endif /* FEATURE_WLAN_WAPI */
5366#ifdef FEATURE_WLAN_BTAMP_UT_RF
5367 //Reset counter so no join retry is needed.
5368 pSession->maxRetryCount = 0;
5369 csrRoamStopJoinRetryTimer(pMac, sessionId);
5370#endif
5371 /* This creates problem since we have not saved the connected profile.
5372 So moving this after saving the profile
5373 */
5374 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305375
5376 /* Reset remainInPowerActiveTillDHCP as it might have been set
5377 * by last failed secured connection.
5378 * It should be set only for secured connection.
5379 */
5380 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005381 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5382 {
5383 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5384 }
5385 else
5386 {
5387 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5388 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 //Use the last connected bssdesc for reassoc-ing to the same AP.
5390 //NOTE: What to do when reassoc to a different AP???
5391 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5392 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5393 {
5394 pSirBssDesc = pSession->pConnectBssDesc;
5395 if(pSirBssDesc)
5396 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305397 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5398 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005399 }
5400 }
5401 else
5402 {
5403
5404 if(pCommand->u.roamCmd.pRoamBssEntry)
5405 {
5406 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5407 if(pScanResult != NULL)
5408 {
5409 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5410 //this can be NULL
5411 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305412 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5413 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005414 }
5415 }
5416 }
5417 if( pSirBssDesc )
5418 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005419 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005420 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5421 //Save WPA/RSN IE
5422 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005423#ifdef FEATURE_WLAN_ESE
5424 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005425#endif
Mukul Sharma9ca96b22014-11-15 19:40:04 +05305426#ifdef WLAN_FEATURE_VOWIFI_11R
5427 if (pSirBssDesc->mdiePresent)
5428 {
5429 if(csrIsAuthType11r(pProfile->negotiatedAuthType, VOS_TRUE)
5430#ifdef FEATURE_WLAN_ESE
5431 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
5432 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
5433#endif
5434 )
5435 {
5436 // is11Rconnection;
5437 roamInfo.is11rAssoc = VOS_TRUE;
5438 }
5439 else
5440 {
5441 // is11Rconnection;
5442 roamInfo.is11rAssoc = VOS_FALSE;
5443 }
5444 }
5445#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005446 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5447 // substate change.
5448 // Moving even save profile above so that below mentioned conditon is also met.
5449 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5450 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005451 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5452 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5453 // will be dropped for the security context may not be set properly.
5454 //
5455 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5456 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5457 //
5458 // this reordering was done on titan_prod_usb branch and is being replicated here.
5459 //
5460
5461 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5462 !pProfile->bWPSAssociation)
5463 {
5464 // Issue the set Context request to LIM to establish the Unicast STA context
5465 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5466 pProfile->negotiatedUCEncryptionType,
5467 pSirBssDesc, &(pSirBssDesc->bssId),
5468 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5469 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005470 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005471 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5472 }
5473 // Issue the set Context request to LIM to establish the Broadcast STA context
5474 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5475 pSirBssDesc, &BroadcastMac,
5476 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5477 }
5478 else
5479 {
5480 //Need to wait for supplicant authtication
5481 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005482 //Set the subestate to WaitForKey in case authentiation is needed
5483 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5484
Jeff Johnson295189b2012-06-20 16:38:30 -07005485 if(pProfile->bWPSAssociation)
5486 {
5487 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5488 }
5489 else
5490 {
5491 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5492 }
5493
5494 //Save sessionId in case of timeout
5495 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5496 //This time should be long enough for the rest of the process plus setting key
5497 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5498 {
5499 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005500 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005501 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5502 }
5503 }
5504
5505 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5506 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005507 if(Context)
5508 {
5509 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5510 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005511 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5512 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5513#ifdef WLAN_FEATURE_VOWIFI_11R
5514 len += pJoinRsp->parsedRicRspLen;
5515#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005516#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005517 len += pJoinRsp->tspecIeLen;
5518#endif
5519 if(len)
5520 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305521 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5522 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005523 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305524 vos_mem_copy(pSession->connectedInfo.pbFrames,
5525 pJoinRsp->frames, len);
5526 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5527 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5528 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005529#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305530 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005531#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005532#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305533 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005534#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305535 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5536 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5537 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5538 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005539 }
5540 }
5541 if(pCommand->u.roamCmd.fReassoc)
5542 {
5543 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5544 }
5545 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5546 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5547 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5548 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305549 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005550 }
5551 else
5552 {
5553 if(pCommand->u.roamCmd.fReassoc)
5554 {
5555 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5556 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5557 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5558 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5559 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5560 }
5561 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305562 /* Update the staId from the previous connected profile info
5563 as the reassociation is triggred at SME/HDD */
5564 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5565 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5566 {
5567 roamInfo.staId = pSession->connectedInfo.staId;
5568 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005569#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5570 // Indicate SME-QOS with reassoc success event, only after
5571 // copying the frames
5572 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5573#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005574 roamInfo.pBssDesc = pSirBssDesc;
5575 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5576 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5577#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5578 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5579#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5580 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005581 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5582 //It may be better to let QoS do this????
5583 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5584 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005585 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005586 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5587 pmcStartUapsd( pMac, NULL, NULL );
5588 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305589 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005590 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5591 if( pSession->bRefAssocStartCnt > 0 )
5592 {
5593 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005594 //Remove this code once SLM_Sessionization is supported
5595 //BMPS_WORKAROUND_NOT_NEEDED
5596 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005597 {
5598 pMac->roam.configParam.doBMPSWorkaround = 1;
5599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005600 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5601 }
5602
5603 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005604 // reset the PMKID candidate list
5605 csrResetPMKIDCandidateList( pMac, sessionId );
5606 //Update TL's AC weight base on the current EDCA parameters
5607 //These parameters may change in the course of the connection, that sictuation
5608 //is not taken care here. This change is mainly to address a WIFI WMM test where
5609 //BE has a equal or higher TX priority than VI.
5610 //We only do this for infra link
5611 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5612 {
5613 csrCheckAndUpdateACWeight(pMac, pIes);
5614 }
5615#ifdef FEATURE_WLAN_WAPI
5616 // reset the BKID candidate list
5617 csrResetBKIDCandidateList( pMac, sessionId );
5618#endif /* FEATURE_WLAN_WAPI */
5619 }
5620 else
5621 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005622 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005623 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005624 csrScanCancelIdleScan(pMac);
5625 //Not to signal link up because keys are yet to be set.
5626 //The linkup function will overwrite the sub-state that we need to keep at this point.
5627 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5628 {
5629 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005631 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5632 //enough to let security and DHCP handshake succeed before entry into BMPS
5633 if (pmcShouldBmpsTimerRun(pMac))
5634 {
Abhishek Singh65d939e2014-04-25 13:33:07 +05305635 /* Set remainInPowerActiveTillDHCP to make sure we wait for
5636 * until keys are set before going into BMPS.
5637 */
5638 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5639 {
5640 pMac->pmc.remainInPowerActiveTillDHCP = TRUE;
5641 smsLog(pMac, LOG1, FL("Set remainInPowerActiveTillDHCP "
5642 "to make sure we wait until keys are set before"
5643 " going to BMPS"));
5644 }
5645
Jeff Johnson295189b2012-06-20 16:38:30 -07005646 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5647 != eHAL_STATUS_SUCCESS)
5648 {
5649 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5650 }
5651 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5652 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005653 break;
5654
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 case eCsrStartBssSuccess:
5656 // on the StartBss Response, LIM is returning the Bss Description that we
5657 // are beaconing. Add this Bss Description to our scan results and
5658 // chain the Profile to this Bss Description. On a Start BSS, there was no
5659 // detected Bss description (no partner) so we issued the Start Bss to
5660 // start the Ibss without any Bss description. Lim was kind enough to return
5661 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005662 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005663 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305665 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005666 if( CSR_IS_IBSS( pProfile ) )
5667 {
5668 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5669 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005670 else if (CSR_IS_INFRA_AP(pProfile))
5671 {
5672 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5673 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005674 else
5675 {
5676 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5677 }
5678 if( !CSR_IS_WDS_STA( pProfile ) )
5679 {
5680 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005681 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005682 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5683 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305684 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005685 roamInfo.pBssDesc = pSirBssDesc;
5686 //We need to associate_complete it first, becasue Associate_start already indicated.
5687 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5688 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5689 break;
5690 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005691 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005693 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 }
5695 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5696 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5697 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5698 if(pSirBssDesc)
5699 {
5700 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305701 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5702 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005703 }
5704 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305705 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005706#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5707 {
5708 vos_log_ibss_pkt_type *pIbssLog;
5709 tANI_U32 bi;
5710
5711 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5712 if(pIbssLog)
5713 {
5714 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5715 {
5716 //We start the IBSS (didn't find any matched IBSS out there)
5717 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5718 }
5719 else
5720 {
5721 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5722 }
5723 if(pSirBssDesc)
5724 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305725 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005726 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5727 }
5728 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5729 {
5730 //***U8 is not enough for beacon interval
5731 pIbssLog->beaconInterval = (v_U8_t)bi;
5732 }
5733 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5734 }
5735 }
5736#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5737 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5738 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005739 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5740 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005741 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5742 csrRoamIssueSetContextReq( pMac, sessionId,
5743 pProfile->negotiatedMCEncryptionType,
5744 pSirBssDesc, &BroadcastMac,
5745 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5746 }
5747 }
5748 else
5749 {
5750 //Keep the state to eCSR_ROAMING_STATE_JOINING
5751 //Need to send join_req.
5752 if(pCommand->u.roamCmd.pRoamBssEntry)
5753 {
5754 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5755 {
5756 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5757 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5758 // Set the roaming substate to 'join attempt'...
5759 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005760 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005761 }
5762 }
5763 else
5764 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005765 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005766 VOS_ASSERT( 0 );
5767 }
5768 }
5769 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5770 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5771 //trigger the connection start indication in Vista
5772 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5773 {
5774 roamStatus = eCSR_ROAM_IBSS_IND;
5775 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5776 if( CSR_IS_WDS( pProfile ) )
5777 {
5778 roamStatus = eCSR_ROAM_WDS_IND;
5779 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5780 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005781 if( CSR_IS_INFRA_AP( pProfile ) )
5782 {
5783 roamStatus = eCSR_ROAM_INFRA_IND;
5784 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5785 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005786
5787 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5788 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5789 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305790 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005791 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5792 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005793 //We start the IBSS (didn't find any matched IBSS out there)
5794 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005795 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305796 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5797 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005798 //Remove this code once SLM_Sessionization is supported
5799 //BMPS_WORKAROUND_NOT_NEEDED
5800 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005801 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005802 {
5803 pMac->roam.configParam.doBMPSWorkaround = 1;
5804 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005805
Jeff Johnson295189b2012-06-20 16:38:30 -07005806 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5807 }
5808
5809 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005810
5811 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005812 {
5813 //need to send stop BSS because we fail to send join_req
5814 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5815 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5816 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5817 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005818 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 case eCsrStartBssFailure:
5820#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5821 {
5822 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5824 if(pIbssLog)
5825 {
5826 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5827 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5828 }
5829 }
5830#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005831 roamStatus = eCSR_ROAM_IBSS_IND;
5832 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5833 if( CSR_IS_WDS( pProfile ) )
5834 {
5835 roamStatus = eCSR_ROAM_WDS_IND;
5836 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5837 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005838 if( CSR_IS_INFRA_AP( pProfile ) )
5839 {
5840 roamStatus = eCSR_ROAM_INFRA_IND;
5841 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5842 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005843 if(Context)
5844 {
5845 pSirBssDesc = (tSirBssDescription *)Context;
5846 }
5847 else
5848 {
5849 pSirBssDesc = NULL;
5850 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305851 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005852 roamInfo.pBssDesc = pSirBssDesc;
5853 //We need to associate_complete it first, becasue Associate_start already indicated.
5854 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5855 csrSetDefaultDot11Mode( pMac );
5856 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005857 case eCsrSilentlyStopRoaming:
5858 // We are here because we try to start the same IBSS
5859 //No message to PE
5860 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005861 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005862 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5863 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305864 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005865 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5866 if( roamInfo.pBssDesc )
5867 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305868 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5869 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 }
5871 //Since there is no change in the current state, simply pass back no result otherwise
5872 //HDD may be mistakenly mark to disconnected state.
5873 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5874 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005875 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005876 case eCsrSilentlyStopRoamingSaveState:
5877 //We are here because we try to connect to the same AP
5878 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005879 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305880 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005881
5882 //to aviod resetting the substate to NONE
5883 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5884 //No need to change substate to wai_for_key because there is no state change
5885 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5886 if( roamInfo.pBssDesc )
5887 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305888 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5889 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005890 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005891 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5892 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5893 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5894 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5895 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5896 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5897 roamInfo.staId = pSession->connectedInfo.staId;
5898 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005899 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005900 pSession->bRefAssocStartCnt--;
5901 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5902 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5903 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5904 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005905 case eCsrReassocFailure:
5906#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5907 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5908#endif
5909 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005910 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005911 csrFreeConnectBssDesc(pMac, sessionId);
5912 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5913 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305914 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005915 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5916 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5917 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5918 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5919 eCSR_ROAM_WDS_IND,
5920 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5921 //Need to issue stop_bss
5922 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005923 case eCsrJoinFailure:
5924 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005925 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005926 default:
5927 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005928 smsLog(pMac, LOGW, FL("receives no association indication"));
5929 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005930 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005931 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5932 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5933 {
5934 //do not free for the other profiles as we need to send down stop BSS later
5935 csrFreeConnectBssDesc(pMac, sessionId);
5936 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5937 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5938 csrSetDefaultDot11Mode( pMac );
5939 }
5940
5941 switch( pCommand->u.roamCmd.roamReason )
5942 {
5943 // If this transition is because of an 802.11 OID, then we transition
5944 // back to INIT state so we sit waiting for more OIDs to be issued and
5945 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005946 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005947 case eCsrSmeIssuedAssocToSimilarAP:
5948 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005949 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305951 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5953 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5954 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305955 vos_mem_copy(&roamInfo.bssid,
5956 &pSession->joinFailStatusCode.bssId,
5957 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005958
Jeff Johnson295189b2012-06-20 16:38:30 -07005959 /* Defeaturize this later if needed */
5960#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5961 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5962 if (csrRoamIsHandoffInProgress(pMac))
5963 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005964 /* Should indicate neighbor roam algorithm about the connect failure here */
5965 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5966 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005967#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005968 if(pSession->bRefAssocStartCnt > 0)
5969 {
5970 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005971 if(eCsrJoinFailureDueToConcurrency == Result)
5972 {
5973 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5974 eCSR_ROAM_ASSOCIATION_COMPLETION,
5975 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5976 }
5977 else
5978 {
5979 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005980 eCSR_ROAM_ASSOCIATION_COMPLETION,
5981 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005983 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005984 else
5985 {
5986 /* bRefAssocStartCnt is not incremented when
5987 * eRoamState == eCsrStopRoamingDueToConcurrency
5988 * in csrRoamJoinNextBss API. so handle this in
5989 * else case by sending assoc failure
5990 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005991 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005992 pCommand->u.scanCmd.roamId,
5993 eCSR_ROAM_ASSOCIATION_FAILURE,
5994 eCSR_ROAM_RESULT_FAILURE);
5995 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005996 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005997#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05305998 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005999 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6000#endif
6001 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6002 csrScanStartIdleScan(pMac);
6003#ifdef FEATURE_WLAN_BTAMP_UT_RF
6004 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
6005 //BT activity and not able to recevie WLAN traffic. Retry the join
6006 if( CSR_IS_WDS_STA(pProfile) )
6007 {
6008 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
6009 }
6010#endif
6011 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006012 case eCsrHddIssuedReassocToSameAP:
6013 case eCsrSmeIssuedReassocToSameAP:
6014 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6015
6016 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6017#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6018 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6019#endif
6020 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6021 csrScanStartIdleScan(pMac);
6022 break;
6023 case eCsrForcedDisassoc:
6024 case eCsrForcedDeauth:
6025 case eCsrSmeIssuedIbssJoinFailure:
6026 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6027
6028 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
6029 {
6030 // Notify HDD that IBSS join failed
6031 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
6032 }
6033 else
6034 {
6035 csrRoamCallCallback(pMac, sessionId, NULL,
6036 pCommand->u.roamCmd.roamId,
6037 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6038 }
6039#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6040 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6041#endif
6042 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006043 /*
6044 *DelSta not done FW still in conneced state so dont
6045 *issue IMPS req
6046 */
6047 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
6048 {
6049 smsLog(pMac, LOGW, FL("FW still in connected state "));
6050 break;
6051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006052 csrScanStartIdleScan(pMac);
6053 break;
6054 case eCsrForcedIbssLeave:
6055 csrRoamCallCallback(pMac, sessionId, NULL,
6056 pCommand->u.roamCmd.roamId,
6057 eCSR_ROAM_IBSS_LEAVE,
6058 eCSR_ROAM_RESULT_IBSS_STOP);
6059 break;
6060 case eCsrForcedDisassocMICFailure:
6061 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6062
6063 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
6064#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6065 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
6066#endif
6067 csrScanStartIdleScan(pMac);
6068 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006069 case eCsrStopBss:
6070 csrRoamCallCallback(pMac, sessionId, NULL,
6071 pCommand->u.roamCmd.roamId,
6072 eCSR_ROAM_INFRA_IND,
6073 eCSR_ROAM_RESULT_INFRA_STOPPED);
6074 break;
6075 case eCsrForcedDisassocSta:
6076 case eCsrForcedDeauthSta:
6077 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
6078 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
6079 {
6080 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006081
6082 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6083 {
6084 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05306085 vos_mem_copy(roamInfo.peerMac,
6086 pCommand->u.roamCmd.peerMac,
6087 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07006088 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6089 roamInfo.statusCode = eSIR_SME_SUCCESS;
6090 status = csrRoamCallCallback(pMac, sessionId,
6091 &roamInfo, pCommand->u.roamCmd.roamId,
6092 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
6093 }
6094 }
6095 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006096 case eCsrLostLink1:
6097 // if lost link roam1 failed, then issue lost link Scan2 ...
6098 csrScanRequestLostLink2(pMac, sessionId);
6099 break;
6100 case eCsrLostLink2:
6101 // if lost link roam2 failed, then issue lost link scan3 ...
6102 csrScanRequestLostLink3(pMac, sessionId);
6103 break;
6104 case eCsrLostLink3:
6105 default:
6106 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6107
6108 //We are done with one round of lostlink roaming here
6109 csrScanHandleFailedLostlink3(pMac, sessionId);
6110 break;
6111 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006112 break;
6113 }
6114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006115 return ( fReleaseCommand );
6116}
6117
Jeff Johnson295189b2012-06-20 16:38:30 -07006118eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6119{
6120 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006121 return (status);
6122}
6123
Jeff Johnson295189b2012-06-20 16:38:30 -07006124eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6125{
6126 eHalStatus status = eHAL_STATUS_SUCCESS;
6127 tANI_U32 size = 0;
6128
6129 do
6130 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306131 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006132 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6133 {
6134 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306135 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6136 if ( NULL == pDstProfile->BSSIDs.bssid )
6137 status = eHAL_STATUS_FAILURE;
6138 else
6139 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006140 if(!HAL_STATUS_SUCCESS(status))
6141 {
6142 break;
6143 }
6144 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306145 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6146 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006147 }
6148 if(pSrcProfile->SSIDs.numOfSSIDs)
6149 {
6150 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306151 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6152 if ( NULL == pDstProfile->SSIDs.SSIDList )
6153 status = eHAL_STATUS_FAILURE;
6154 else
6155 status = eHAL_STATUS_SUCCESS;
6156 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006157 {
6158 break;
6159 }
6160 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306161 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6162 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006163 }
6164 if(pSrcProfile->nWPAReqIELength)
6165 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306166 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6167 if ( NULL == pDstProfile->pWPAReqIE )
6168 status = eHAL_STATUS_FAILURE;
6169 else
6170 status = eHAL_STATUS_SUCCESS;
6171
6172 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006173 {
6174 break;
6175 }
6176 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306177 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6178 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006179 }
6180 if(pSrcProfile->nRSNReqIELength)
6181 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306182 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6183 if ( NULL == pDstProfile->pRSNReqIE )
6184 status = eHAL_STATUS_FAILURE;
6185 else
6186 status = eHAL_STATUS_SUCCESS;
6187
6188 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006189 {
6190 break;
6191 }
6192 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306193 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6194 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006195 }
6196#ifdef FEATURE_WLAN_WAPI
6197 if(pSrcProfile->nWAPIReqIELength)
6198 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306199 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6200 if ( NULL == pDstProfile->pWAPIReqIE )
6201 status = eHAL_STATUS_FAILURE;
6202 else
6203 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006204 if(!HAL_STATUS_SUCCESS(status))
6205 {
6206 break;
6207 }
6208 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306209 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6210 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006211 }
6212#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 if(pSrcProfile->nAddIEScanLength)
6214 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306215 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6216 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006217 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306218 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306219 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306220 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6221 }
6222 else
6223 {
6224 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6225 FL(" AddIEScanLength is not valid %u"),
6226 pSrcProfile->nAddIEScanLength);
6227 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006228 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006229 if(pSrcProfile->nAddIEAssocLength)
6230 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306231 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6232 if ( NULL == pDstProfile->pAddIEAssoc )
6233 status = eHAL_STATUS_FAILURE;
6234 else
6235 status = eHAL_STATUS_SUCCESS;
6236
Jeff Johnson295189b2012-06-20 16:38:30 -07006237 if(!HAL_STATUS_SUCCESS(status))
6238 {
6239 break;
6240 }
6241 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306242 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6243 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006244 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006245 if(pSrcProfile->ChannelInfo.ChannelList)
6246 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306247 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6248 pSrcProfile->ChannelInfo.numOfChannels);
6249 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6250 status = eHAL_STATUS_FAILURE;
6251 else
6252 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006253 if(!HAL_STATUS_SUCCESS(status))
6254 {
6255 break;
6256 }
6257 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306258 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6259 pSrcProfile->ChannelInfo.ChannelList,
6260 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 pDstProfile->AuthType = pSrcProfile->AuthType;
6263 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6264 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6265 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6266 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6267 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006268#ifdef WLAN_FEATURE_11W
6269 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6270 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6271 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6272#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006273 pDstProfile->BSSType = pSrcProfile->BSSType;
6274 pDstProfile->phyMode = pSrcProfile->phyMode;
6275 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6276
6277#ifdef FEATURE_WLAN_WAPI
6278 if(csrIsProfileWapi(pSrcProfile))
6279 {
6280 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6281 {
6282 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6283 }
6284 }
6285#endif /* FEATURE_WLAN_WAPI */
6286 pDstProfile->CBMode = pSrcProfile->CBMode;
6287 /*Save the WPS info*/
6288 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006289 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006290 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006291 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006292 pDstProfile->privacy = pSrcProfile->privacy;
6293 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6294 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6295 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6296 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6297 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6298 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6299 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6300 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6301 pDstProfile->wps_state = pSrcProfile->wps_state;
6302 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306303 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6304 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006305#ifdef WLAN_FEATURE_VOWIFI_11R
6306 if (pSrcProfile->MDID.mdiePresent)
6307 {
6308 pDstProfile->MDID.mdiePresent = 1;
6309 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6310 }
6311#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006312 }while(0);
6313
6314 if(!HAL_STATUS_SUCCESS(status))
6315 {
6316 csrReleaseProfile(pMac, pDstProfile);
6317 pDstProfile = NULL;
6318 }
6319
6320 return (status);
6321}
Jeff Johnson295189b2012-06-20 16:38:30 -07006322eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6323{
6324 eHalStatus status = eHAL_STATUS_SUCCESS;
6325 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6326 do
6327 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306328 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006329 if(pSrcProfile->bssid)
6330 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306331 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6332 if ( NULL == pDstProfile->BSSIDs.bssid )
6333 status = eHAL_STATUS_FAILURE;
6334 else
6335 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006336 if(!HAL_STATUS_SUCCESS(status))
6337 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306338 smsLog( pMac, LOGE,
6339 FL("failed to allocate memory for BSSID"
6340 "%02x:%02x:%02x:%02x:%02x:%02x"),
6341 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6342 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006343 break;
6344 }
6345 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306346 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6347 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006348 }
6349 if(pSrcProfile->SSID.ssId)
6350 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306351 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6352 if ( NULL == pDstProfile->SSIDs.SSIDList )
6353 status = eHAL_STATUS_FAILURE;
6354 else
6355 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006356 if(!HAL_STATUS_SUCCESS(status))
6357 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306358 smsLog( pMac, LOGE,
6359 FL("failed to allocate memory for SSIDList"
6360 "%02x:%02x:%02x:%02x:%02x:%02x"),
6361 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6362 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006363 break;
6364 }
6365 pDstProfile->SSIDs.numOfSSIDs = 1;
6366 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6367 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306368 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6369 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006370 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006371 if(pSrcProfile->nAddIEAssocLength)
6372 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306373 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6374 if ( NULL == pDstProfile->pAddIEAssoc)
6375 status = eHAL_STATUS_FAILURE;
6376 else
6377 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006378 if(!HAL_STATUS_SUCCESS(status))
6379 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006380 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006381 break;
6382 }
6383 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306384 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6385 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006386 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306387 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6388 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6389 status = eHAL_STATUS_FAILURE;
6390 else
6391 status = eHAL_STATUS_SUCCESS;
6392
Jeff Johnson295189b2012-06-20 16:38:30 -07006393 if(!HAL_STATUS_SUCCESS(status))
6394 {
6395 break;
6396 }
6397 pDstProfile->ChannelInfo.numOfChannels = 1;
6398 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006399 pDstProfile->AuthType.numEntries = 1;
6400 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6401 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6402 pDstProfile->EncryptionType.numEntries = 1;
6403 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6404 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6405 pDstProfile->mcEncryptionType.numEntries = 1;
6406 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6407 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6408 pDstProfile->BSSType = pSrcProfile->BSSType;
6409 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306410 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6411 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006412#ifdef WLAN_FEATURE_VOWIFI_11R
6413 if (pSrcProfile->MDID.mdiePresent)
6414 {
6415 pDstProfile->MDID.mdiePresent = 1;
6416 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6417 }
6418#endif
6419
6420 }while(0);
6421
6422 if(!HAL_STATUS_SUCCESS(status))
6423 {
6424 csrReleaseProfile(pMac, pDstProfile);
6425 pDstProfile = NULL;
6426 }
6427
6428 return (status);
6429}
6430
Jeff Johnson295189b2012-06-20 16:38:30 -07006431eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6432 tScanResultHandle hBSSList,
6433 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6434 tANI_BOOLEAN fClearScan)
6435{
6436 eHalStatus status = eHAL_STATUS_SUCCESS;
6437 tSmeCmd *pCommand;
6438
6439 pCommand = csrGetCommandBuffer(pMac);
6440 if(NULL == pCommand)
6441 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006442 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006443 status = eHAL_STATUS_RESOURCES;
6444 }
6445 else
6446 {
6447 if( fClearScan )
6448 {
6449 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306450 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006451 }
6452 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6453 if(NULL == pProfile)
6454 {
6455 //We can roam now
6456 //Since pProfile is NULL, we need to build our own profile, set everything to default
6457 //We can only support open and no encryption
6458 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6459 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6460 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6461 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6462 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6463 }
6464 else
6465 {
6466 //make a copy of the profile
6467 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6468 if(HAL_STATUS_SUCCESS(status))
6469 {
6470 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6471 }
6472 }
6473 pCommand->command = eSmeCommandRoam;
6474 pCommand->sessionId = (tANI_U8)sessionId;
6475 pCommand->u.roamCmd.hBSSList = hBSSList;
6476 pCommand->u.roamCmd.roamId = roamId;
6477 pCommand->u.roamCmd.roamReason = reason;
6478 //We need to free the BssList when the command is done
6479 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6480 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006481 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6482 FL("CSR PERSONA=%d"),
6483 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006484 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6485 if( !HAL_STATUS_SUCCESS( status ) )
6486 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006487 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006488 csrReleaseCommandRoam( pMac, pCommand );
6489 }
6490 }
6491
6492 return (status);
6493}
Jeff Johnson295189b2012-06-20 16:38:30 -07006494eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6495 tCsrRoamModifyProfileFields *pMmodProfileFields,
6496 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6497{
6498 eHalStatus status = eHAL_STATUS_SUCCESS;
6499 tSmeCmd *pCommand;
6500
6501 pCommand = csrGetCommandBuffer(pMac);
6502 if(NULL == pCommand)
6503 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006504 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006505 status = eHAL_STATUS_RESOURCES;
6506 }
6507 else
6508 {
6509 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306510 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006511 if(pProfile)
6512 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006513 //This is likely trying to reassoc to different profile
6514 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6515 //make a copy of the profile
6516 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6517 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006518 }
6519 else
6520 {
6521 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6522 //how to update WPA/WPA2 info in roamProfile??
6523 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006524 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006525 if(HAL_STATUS_SUCCESS(status))
6526 {
6527 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6528 }
6529 pCommand->command = eSmeCommandRoam;
6530 pCommand->sessionId = (tANI_U8)sessionId;
6531 pCommand->u.roamCmd.roamId = roamId;
6532 pCommand->u.roamCmd.roamReason = reason;
6533 //We need to free the BssList when the command is done
6534 //For reassoc there is no BSS list, so the boolean set to false
6535 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6536 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6537 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006538 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6539 if( !HAL_STATUS_SUCCESS( status ) )
6540 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006541 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006542 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6543 csrReleaseCommandRoam( pMac, pCommand );
6544 }
6545 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006546 return (status);
6547}
6548
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006549eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6550 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306551// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006552{
6553 eHalStatus status = eHAL_STATUS_SUCCESS;
6554 tSmeCmd *pCommand;
6555
6556 pCommand = csrGetCommandBuffer(pMac);
6557 if(NULL == pCommand)
6558 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006559 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006560 status = eHAL_STATUS_RESOURCES;
6561 }
6562 else
6563 {
6564 if(pBssDescription)
6565 {
6566 //copy over the parameters we need later
6567 pCommand->command = eSmeCommandRoam;
6568 pCommand->sessionId = (tANI_U8)sessionId;
6569 pCommand->u.roamCmd.roamReason = reason;
6570 //this is the important parameter
6571 //in this case we are using this field for the "next" BSS
6572 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6573 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6574 if( !HAL_STATUS_SUCCESS( status ) )
6575 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006576 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006577 csrReleaseCommandPreauth( pMac, pCommand );
6578 }
6579 }
6580 else
6581 {
6582 //Return failure
6583 status = eHAL_STATUS_RESOURCES;
6584 }
6585 }
6586 return (status);
6587}
6588
6589eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6590{
6591 tListElem *pEntry;
6592 tSmeCmd *pCommand;
6593 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6594 if ( pEntry )
6595 {
6596 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6597 if ( (eSmeCommandRoam == pCommand->command) &&
6598 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6599 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006600 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006601 pCommand->command, pCommand->u.roamCmd.roamReason);
6602 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6603 csrReleaseCommandPreauth( pMac, pCommand );
6604 }
6605 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006606 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006607 pCommand->command, pCommand->u.roamCmd.roamReason);
6608 }
6609 }
6610 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006611 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006612 }
6613 smeProcessPendingQueue( pMac );
6614 return eHAL_STATUS_SUCCESS;
6615}
6616
Jeff Johnson295189b2012-06-20 16:38:30 -07006617eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6618 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6619{
6620 eHalStatus status = eHAL_STATUS_FAILURE;
6621 tScanResultHandle hBSSList;
6622 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006623 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6624 if(HAL_STATUS_SUCCESS(status))
6625 {
6626 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6627 if(pRoamId)
6628 {
6629 *pRoamId = roamId;
6630 }
6631 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6632 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6633 if(!HAL_STATUS_SUCCESS(status))
6634 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006635 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006636 csrScanResultPurge(pMac, hBSSList);
6637 }
6638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006639 return (status);
6640}
6641
Jeff Johnson295189b2012-06-20 16:38:30 -07006642eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6643 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6644{
6645 eHalStatus status = eHAL_STATUS_SUCCESS;
6646 tScanResultHandle hBSSList;
6647 tCsrScanResultFilter *pScanFilter;
6648 tANI_U32 roamId = 0;
6649 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6650 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006651 if (NULL == pProfile)
6652 {
6653 smsLog(pMac, LOGP, FL("No profile specified"));
6654 return eHAL_STATUS_FAILURE;
6655 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306656 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6657 "encryType = %d"),
6658 lim_BssTypetoString(pProfile->BSSType),
6659 pProfile->BSSType,
6660 pProfile->AuthType.authType[0],
6661 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006662 if( CSR_IS_WDS( pProfile ) &&
6663 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6664 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006665 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006666 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006667 return status;
6668 }
6669 csrRoamCancelRoaming(pMac, sessionId);
6670 csrScanRemoveFreshScanCommand(pMac, sessionId);
6671 csrScanCancelIdleScan(pMac);
6672 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306673 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306674
6675 if (!vos_concurrent_open_sessions_running() &&
6676 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07006677 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306678 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 csrScanDisable(pMac);
6680 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306681
Jeff Johnson295189b2012-06-20 16:38:30 -07006682 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6683 //Check whether ssid changes
6684 if(csrIsConnStateConnected(pMac, sessionId))
6685 {
6686 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6687 {
6688 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6689 }
6690 }
6691#ifdef FEATURE_WLAN_BTAMP_UT_RF
6692 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6693#endif
6694 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6695 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006696 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006697 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6698 if(pRoamId)
6699 {
6700 roamId = *pRoamId;
6701 }
6702 if(!HAL_STATUS_SUCCESS(status))
6703 {
6704 fCallCallback = eANI_BOOLEAN_TRUE;
6705 }
6706 }
6707 else
6708 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306709 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6710 if ( NULL == pScanFilter )
6711 status = eHAL_STATUS_FAILURE;
6712 else
6713 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006714 if(HAL_STATUS_SUCCESS(status))
6715 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306716 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006717 //Try to connect to any BSS
6718 if(NULL == pProfile)
6719 {
6720 //No encryption
6721 pScanFilter->EncryptionType.numEntries = 1;
6722 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6723 }//we don't have a profile
6724 else
6725 {
6726 //Here is the profile we need to connect to
6727 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6728 }//We have a profile
6729 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6730 if(pRoamId)
6731 {
6732 *pRoamId = roamId;
6733 }
6734
6735 if(HAL_STATUS_SUCCESS(status))
6736 {
6737 /*Save the WPS info*/
6738 if(NULL != pProfile)
6739 {
6740 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006741 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006742 }
6743 else
6744 {
6745 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006746 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006747 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006748 do
6749 {
6750 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006751 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006752 )
6753 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006754 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006755 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6756 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6757 if(!HAL_STATUS_SUCCESS(status))
6758 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006759 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006760 fCallCallback = eANI_BOOLEAN_TRUE;
6761 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006762 else
6763 {
6764 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6765 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006766 break;
6767 }
6768 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006769 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006770 if(HAL_STATUS_SUCCESS(status))
6771 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6773 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6774 if(!HAL_STATUS_SUCCESS(status))
6775 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006776 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006777 csrScanResultPurge(pMac, hBSSList);
6778 fCallCallback = eANI_BOOLEAN_TRUE;
6779 }
6780 }//Have scan result
6781 else if(NULL != pProfile)
6782 {
6783 //Check whether it is for start ibss
6784 if(CSR_IS_START_IBSS(pProfile))
6785 {
6786 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6787 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6788 if(!HAL_STATUS_SUCCESS(status))
6789 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006790 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006791 fCallCallback = eANI_BOOLEAN_TRUE;
6792 }
6793 }
6794 else
6795 {
6796 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006797 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006798 if(!HAL_STATUS_SUCCESS(status))
6799 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006800 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006801 fCallCallback = eANI_BOOLEAN_TRUE;
6802 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006803 else
6804 {
6805 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6806 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006807 }
6808 }
6809 else
6810 {
6811 fCallCallback = eANI_BOOLEAN_TRUE;
6812 }
6813 } while (0);
6814 if(NULL != pProfile)
6815 {
6816 //we need to free memory for filter if profile exists
6817 csrFreeScanFilter(pMac, pScanFilter);
6818 }
6819 }//Got the scan filter from profile
6820
Kiet Lam64c1b492013-07-12 13:56:44 +05306821 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006822 }//allocated memory for pScanFilter
6823 }//No Bsslist coming in
6824 //tell the caller if we fail to trigger a join request
6825 if( fCallCallback )
6826 {
6827 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6828 }
6829
6830 return (status);
6831}
Jeff Johnson295189b2012-06-20 16:38:30 -07006832eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6833 tCsrRoamModifyProfileFields modProfileFields,
6834 tANI_U32 *pRoamId)
6835{
6836 eHalStatus status = eHAL_STATUS_SUCCESS;
6837 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6838 tANI_U32 roamId = 0;
6839 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006840 if (NULL == pProfile)
6841 {
6842 smsLog(pMac, LOGP, FL("No profile specified"));
6843 return eHAL_STATUS_FAILURE;
6844 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306845 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6846 "encryType = %d"),
6847 lim_BssTypetoString(pProfile->BSSType),
6848 pProfile->BSSType,
6849 pProfile->AuthType.authType[0],
6850 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006851 csrRoamCancelRoaming(pMac, sessionId);
6852 csrScanRemoveFreshScanCommand(pMac, sessionId);
6853 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306854 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006855 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006856 if(csrIsConnStateConnected(pMac, sessionId))
6857 {
6858 if(pProfile)
6859 {
6860 if(pProfile->SSIDs.numOfSSIDs &&
6861 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6862 {
6863 fCallCallback = eANI_BOOLEAN_FALSE;
6864 }
6865 else
6866 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006867 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006868 }
6869 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306870 else if (!vos_mem_compare(&modProfileFields,
6871 &pSession->connectedProfile.modifyProfileFields,
6872 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006873 {
6874 fCallCallback = eANI_BOOLEAN_FALSE;
6875 }
6876 else
6877 {
6878 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006879 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006880 }
6881 }
6882 else
6883 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006884 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006885 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006886 if(!fCallCallback)
6887 {
6888 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6889 if(pRoamId)
6890 {
6891 *pRoamId = roamId;
6892 }
6893
Jeff Johnson295189b2012-06-20 16:38:30 -07006894 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6895 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006896 }
6897 else
6898 {
6899 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6900 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6901 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006902 return status;
6903}
Jeff Johnson295189b2012-06-20 16:38:30 -07006904eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6905{
6906 eHalStatus status = eHAL_STATUS_FAILURE;
6907 tScanResultHandle hBSSList = NULL;
6908 tCsrScanResultFilter *pScanFilter = NULL;
6909 tANI_U32 roamId;
6910 tCsrRoamProfile *pProfile = NULL;
6911 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006912
6913 if(!pSession)
6914 {
6915 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6916 return eHAL_STATUS_FAILURE;
6917 }
6918
Jeff Johnson295189b2012-06-20 16:38:30 -07006919 do
6920 {
6921 if(pSession->pCurRoamProfile)
6922 {
6923 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306924 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006925 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306926 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6927 if ( NULL == pProfile )
6928 status = eHAL_STATUS_FAILURE;
6929 else
6930 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006931 if(!HAL_STATUS_SUCCESS(status))
6932 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306933 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006934 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306935 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006936 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306937 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6938 if ( NULL == pScanFilter )
6939 status = eHAL_STATUS_FAILURE;
6940 else
6941 status = eHAL_STATUS_SUCCESS;
6942
Jeff Johnson295189b2012-06-20 16:38:30 -07006943 if(!HAL_STATUS_SUCCESS(status))
6944 {
6945 break;
6946 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306947 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006948 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6949 if(!HAL_STATUS_SUCCESS(status))
6950 {
6951 break;
6952 }
6953 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6954 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6955 if(HAL_STATUS_SUCCESS(status))
6956 {
6957 //we want to put the last connected BSS to the very beginning, if possible
6958 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6959 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6960 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6961 if(!HAL_STATUS_SUCCESS(status))
6962 {
6963 csrScanResultPurge(pMac, hBSSList);
6964 break;
6965 }
6966 }
6967 else
6968 {
6969 //Do a scan on this profile
6970 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006971 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006972 if(!HAL_STATUS_SUCCESS(status))
6973 {
6974 break;
6975 }
6976 }
6977 }//We have a profile
6978 else
6979 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006980 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006981 break;
6982 }
6983 }while(0);
6984 if(pScanFilter)
6985 {
6986 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306987 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006988 }
6989 if(NULL != pProfile)
6990 {
6991 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306992 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006993 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006994 return (status);
6995}
Jeff Johnson295189b2012-06-20 16:38:30 -07006996eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6997{
6998 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006999 if(csrIsConnStateConnected(pMac, sessionId))
7000 {
7001 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7002 if(HAL_STATUS_SUCCESS(status))
7003 {
7004 status = csrRoamJoinLastProfile(pMac, sessionId);
7005 }
7006 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007007 return (status);
7008}
7009
Jeff Johnson295189b2012-06-20 16:38:30 -07007010eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7011{
7012 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007013 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007014 csrRoamCancelRoaming(pMac, sessionId);
7015 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7016 if(csrIsConnStateDisconnected(pMac, sessionId))
7017 {
7018 status = csrRoamJoinLastProfile(pMac, sessionId);
7019 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007020 return (status);
7021}
7022
Jeff Johnson295189b2012-06-20 16:38:30 -07007023eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
7024{
7025 eHalStatus status = eHAL_STATUS_SUCCESS;
7026 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
7027 eCsrRoamSubState NewSubstate;
7028 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05307029
7030 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7031 {
7032 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
7033 " eCSR_ROAM_SUBSTATE_NONE"));
7034 csrRoamStopWaitForKeyTimer( pMac );
7035 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7036 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007037 // change state to 'Roaming'...
7038 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
7039
7040 if ( csrIsConnStateIbss( pMac, sessionId ) )
7041 {
7042 // If we are in an IBSS, then stop the IBSS...
7043 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7044 fComplete = (!HAL_STATUS_SUCCESS(status));
7045 }
7046 else if ( csrIsConnStateInfra( pMac, sessionId ) )
7047 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007048 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 -07007049 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
7050 //Restore AC weight in case we change it
7051 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
7052 // in Infrasturcture, we need to disassociate from the Infrastructure network...
7053 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7054 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
7055 {
7056 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7057 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307058 else
7059 {
7060 // If we are in neighbor preauth done state then on receiving
7061 // disassoc or deauth we dont roam instead we just disassoc
7062 // from current ap and then go to disconnected state
7063 // This happens for ESE and 11r FT connections ONLY.
7064#ifdef WLAN_FEATURE_VOWIFI_11R
7065 if (csrRoamIs11rAssoc(pMac) &&
7066 (csrNeighborRoamStatePreauthDone(pMac)))
7067 {
7068 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7069 }
7070#endif
7071#ifdef FEATURE_WLAN_ESE
7072 if (csrRoamIsESEAssoc(pMac) &&
7073 (csrNeighborRoamStatePreauthDone(pMac)))
7074 {
7075 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7076 }
7077#endif
7078#ifdef FEATURE_WLAN_LFR
7079 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7080 (csrNeighborRoamStatePreauthDone(pMac)))
7081 {
7082 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7083 }
7084#endif
7085 }
7086
Jeff Johnson295189b2012-06-20 16:38:30 -07007087 if( fDisassoc )
7088 {
7089 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05307090#ifdef DEBUG_ROAM_DELAY
7091 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7092#endif /* DEBUG_ROAM_DELAY */
Jeff Johnson295189b2012-06-20 16:38:30 -07007093 }
7094 else
7095 {
7096 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7097 }
7098 fComplete = (!HAL_STATUS_SUCCESS(status));
7099 }
7100 else if ( csrIsConnStateWds( pMac, sessionId ) )
7101 {
7102 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7103 {
7104 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7105 fComplete = (!HAL_STATUS_SUCCESS(status));
7106 }
7107 //This has to be WDS station
7108 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7109 {
7110
7111 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7112 if( fDisassoc )
7113 {
7114 status = csrRoamIssueDisassociate( pMac, sessionId,
7115 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7116 fComplete = (!HAL_STATUS_SUCCESS(status));
7117 }
7118 }
7119 } else {
7120 // we got a dis-assoc request while not connected to any peer
7121 // just complete the command
7122 fComplete = eANI_BOOLEAN_TRUE;
7123 status = eHAL_STATUS_FAILURE;
7124 }
7125 if(fComplete)
7126 {
7127 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7128 }
7129
7130 if(HAL_STATUS_SUCCESS(status))
7131 {
7132 if ( csrIsConnStateInfra( pMac, sessionId ) )
7133 {
7134 //Set the state to disconnect here
7135 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7136 }
7137 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007138 else
7139 {
7140 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007142 return (status);
7143}
7144
Jeff Johnson295189b2012-06-20 16:38:30 -07007145/* This is been removed from latest code base */
7146/*
7147static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7148{
7149 eHalStatus status;
7150 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007151 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7152 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 return ( status );
7154}
7155*/
7156
Jeff Johnson295189b2012-06-20 16:38:30 -07007157eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7158{
7159 eHalStatus status = eHAL_STATUS_SUCCESS;
7160 tSmeCmd *pCommand;
7161 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007162 do
7163 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08007164 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007165 pCommand = csrGetCommandBuffer( pMac );
7166 if ( !pCommand )
7167 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007168 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007169 status = eHAL_STATUS_RESOURCES;
7170 break;
7171 }
7172 //Change the substate in case it is wait-for-key
7173 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7174 {
7175 csrRoamStopWaitForKeyTimer( pMac );
7176 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7177 }
7178 pCommand->command = eSmeCommandRoam;
7179 pCommand->sessionId = (tANI_U8)sessionId;
7180 switch ( reason )
7181 {
7182 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7183 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7184 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007185 case eCSR_DISCONNECT_REASON_DEAUTH:
7186 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7187 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007188 case eCSR_DISCONNECT_REASON_HANDOFF:
7189 fHighPriority = eANI_BOOLEAN_TRUE;
7190 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7191 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007192 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7193 case eCSR_DISCONNECT_REASON_DISASSOC:
7194 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7195 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007196 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7197 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7198 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007199 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7200 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7201 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007202 default:
7203 break;
7204 }
7205 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7206 if( !HAL_STATUS_SUCCESS( status ) )
7207 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007208 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007209 csrReleaseCommandRoam( pMac, pCommand );
7210 }
7211 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007212 return( status );
7213}
7214
Jeff Johnson295189b2012-06-20 16:38:30 -07007215eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7216{
7217 eHalStatus status = eHAL_STATUS_SUCCESS;
7218 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007219 pCommand = csrGetCommandBuffer( pMac );
7220 if ( NULL != pCommand )
7221 {
7222 //Change the substate in case it is wait-for-key
7223 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7224 {
7225 csrRoamStopWaitForKeyTimer( pMac );
7226 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7227 }
7228 pCommand->command = eSmeCommandRoam;
7229 pCommand->sessionId = (tANI_U8)sessionId;
7230 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7231 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7232 if( !HAL_STATUS_SUCCESS( status ) )
7233 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007234 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007235 csrReleaseCommandRoam( pMac, pCommand );
7236 }
7237 }
7238 else
7239 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007240 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007241 status = eHAL_STATUS_RESOURCES;
7242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007243 return ( status );
7244}
7245
Jeff Johnson295189b2012-06-20 16:38:30 -07007246eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7247{
7248 eHalStatus status = eHAL_STATUS_SUCCESS;
7249 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007250
7251 if(!pSession)
7252 {
7253 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7254 return eHAL_STATUS_FAILURE;
7255 }
7256
Jeff Johnson295189b2012-06-20 16:38:30 -07007257#ifdef FEATURE_WLAN_BTAMP_UT_RF
7258 //Stop te retry
7259 pSession->maxRetryCount = 0;
7260 csrRoamStopJoinRetryTimer(pMac, sessionId);
7261#endif
7262 //Not to call cancel roaming here
7263 //Only issue disconnect when necessary
7264 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7265 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7266 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7267
7268 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007269 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007270 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7271 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307272 else
7273 {
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307274 csrScanAbortScanForSSID(pMac, sessionId);
7275 status = eHAL_STATUS_CMD_NOT_QUEUED;
7276 smsLog( pMac, LOG1, FL(" Disconnect cmd not queued, Roam command is not present"
7277 " return with status %d"), status);
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007279 return (status);
7280}
7281
Jeff Johnson295189b2012-06-20 16:38:30 -07007282eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7283{
7284 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007285
7286 if(!pSession)
7287 {
7288 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7289 return eHAL_STATUS_FAILURE;
7290 }
7291
Jeff Johnson295189b2012-06-20 16:38:30 -07007292 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007293 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7294
7295 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7296}
7297
Jeff Johnson295189b2012-06-20 16:38:30 -07007298eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7299 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7300{
7301 eHalStatus status = eHAL_STATUS_SUCCESS;
7302 tDot11fBeaconIEs *pIesTemp = pIes;
7303 tANI_U8 index;
7304 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7305 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007306
7307 if(!pSession)
7308 {
7309 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7310 return eHAL_STATUS_FAILURE;
7311 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007312 if(pConnectProfile->pAddIEAssoc)
7313 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307314 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007315 pConnectProfile->pAddIEAssoc = NULL;
7316 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307317 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007318 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7319 pConnectProfile->AuthInfo = pProfile->AuthType;
7320 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7321 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7322 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7323 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7324 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7325 pConnectProfile->BSSType = pProfile->BSSType;
7326 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7327 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007328 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307329 if (!pConnectProfile->beaconInterval)
7330 {
7331 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7332 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307333 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007334 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7335 if(pProfile->nAddIEAssocLength)
7336 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307337 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7338 if ( NULL == pConnectProfile->pAddIEAssoc )
7339 status = eHAL_STATUS_FAILURE;
7340 else
7341 status = eHAL_STATUS_SUCCESS;
7342 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007343 {
7344 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7345 return eHAL_STATUS_FAILURE;
7346 }
7347 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307348 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7349 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007350 }
7351
Jeff Johnson295189b2012-06-20 16:38:30 -07007352 //Save bssid
7353 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7354#ifdef WLAN_FEATURE_VOWIFI_11R
7355 if (pSirBssDesc->mdiePresent)
7356 {
7357 pConnectProfile->MDID.mdiePresent = 1;
7358 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7359 }
7360#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007361 if( NULL == pIesTemp )
7362 {
7363 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7364 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007365#ifdef FEATURE_WLAN_ESE
7366 if ((csrIsProfileESE(pProfile) ||
7367 ((pIesTemp->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307368 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7369 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7370 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7371 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
7372#ifdef WLAN_FEATURE_11W
7373 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +05307374 || (pProfile->negotiatedAuthType ==
7375 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307376#endif
7377 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007378 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007379 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007380 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007381 }
7382#endif
7383 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007384 if(HAL_STATUS_SUCCESS(status))
7385 {
7386 if(pIesTemp->SSID.present)
7387 {
7388 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307389 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7390 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007391 }
7392
7393 //Save the bss desc
7394 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307395
7396 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007397 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307398 //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 -07007399 pConnectProfile->qap = TRUE;
7400 }
7401 else
7402 {
7403 pConnectProfile->qap = FALSE;
7404 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007405 if ( NULL == pIes )
7406 {
7407 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307408 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007409 }
7410 }
7411 //Save Qos connection
7412 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7413
7414 if(!HAL_STATUS_SUCCESS(status))
7415 {
7416 csrFreeConnectBssDesc(pMac, sessionId);
7417 }
7418 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7419 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307420 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7421 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7422 pConnectProfile->SSID.ssId,
7423 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007424 {
7425 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7426 break;
7427 }
7428 pConnectProfile->handoffPermitted = FALSE;
7429 }
7430
7431 return (status);
7432}
7433
Jeff Johnson295189b2012-06-20 16:38:30 -07007434static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7435{
7436 tListElem *pEntry = NULL;
7437 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007438 //The head of the active list is the request we sent
7439 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7440 if(pEntry)
7441 {
7442 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007444 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7445 {
7446 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7447 {
7448#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7449 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7450#endif
7451 }
7452 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7453 }
7454 else
7455 {
7456 tANI_U32 roamId = 0;
7457 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007458 if(!pSession)
7459 {
7460 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7461 return;
7462 }
7463
Jeff Johnson295189b2012-06-20 16:38:30 -07007464
7465 //The head of the active list is the request we sent
7466 //Try to get back the same profile and roam again
7467 if(pCommand)
7468 {
7469 roamId = pCommand->u.roamCmd.roamId;
7470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007471 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7472 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007473 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007474#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7475 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7476 if (csrRoamIsHandoffInProgress(pMac))
7477 {
7478 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7479 /* Should indicate neighbor roam algorithm about the connect failure here */
7480 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7481 }
7482#endif
7483 if (pCommand)
7484 {
7485 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7486 {
7487 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7488 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7489 csrRoamReissueRoamCommand(pMac);
7490 }
7491 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7492 {
7493 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7494 }
7495 else
7496 {
7497 csrRoam(pMac, pCommand);
7498 }
7499 }
7500 else
7501 {
7502 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7503 }
7504 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7505}
7506
Jeff Johnson295189b2012-06-20 16:38:30 -07007507eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7508 tDot11fBeaconIEs *pIes,
7509 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7510{
7511 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007512 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7513 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007514
7515 // Set the roaming substate to 'join attempt'...
7516 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007517 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007518 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007519 return (status);
7520}
7521
Jeff Johnson295189b2012-06-20 16:38:30 -07007522static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7523 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7524{
7525 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007526 // Set the roaming substate to 'join attempt'...
7527 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7528
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307529 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7530 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05307531#ifdef DEBUG_ROAM_DELAY
7532 //HACK usign buff len as Auth type
7533 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
7534 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
7535#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007536 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007537 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007538}
7539
Jeff Johnson295189b2012-06-20 16:38:30 -07007540void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7541{
7542 tListElem *pEntry;
7543 tSmeCmd *pCommand;
7544 tCsrRoamInfo roamInfo;
7545 tANI_U32 sessionId;
7546 tCsrRoamSession *pSession;
7547
7548 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7549 if(pEntry)
7550 {
7551 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7552 if ( eSmeCommandRoam == pCommand->command )
7553 {
7554 sessionId = pCommand->sessionId;
7555 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007556
7557 if(!pSession)
7558 {
7559 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7560 return;
7561 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307562 /* While switching between two AP, csr will reissue roam command again
7563 to the nextbss if it was interrupted by the dissconnect req for the
7564 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7565 so reset the bRefAssocStartCnt.
7566 */
7567 if(pSession->bRefAssocStartCnt > 0)
7568 {
7569 pSession->bRefAssocStartCnt--;
7570 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007571 if( pCommand->u.roamCmd.fStopWds )
7572 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307573 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007574 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7575 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7576 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007577 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007578 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7579 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7580 eCSR_ROAM_WDS_IND,
7581 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007582 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7583 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7584 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7585 eCSR_ROAM_INFRA_IND,
7586 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7587 }
7588
Jeff Johnson295189b2012-06-20 16:38:30 -07007589
Jeff Johnson295189b2012-06-20 16:38:30 -07007590 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7591 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007592 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007593 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7594 }
7595 }
7596 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7597 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007598 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007599 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7600 }
7601 }
7602 else
7603 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007604 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007605 }
7606 }
7607 else
7608 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007609 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007610 }
7611}
7612
Jeff Johnson295189b2012-06-20 16:38:30 -07007613tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7614{
7615 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7616 tListElem *pEntry;
7617 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007618 //alwasy lock active list before locking pending list
7619 csrLLLock( &pMac->sme.smeCmdActiveList );
7620 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7621 if(pEntry)
7622 {
7623 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7624 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7625 {
7626 fRet = eANI_BOOLEAN_TRUE;
7627 }
7628 }
7629 if(eANI_BOOLEAN_FALSE == fRet)
7630 {
7631 csrLLLock(&pMac->sme.smeCmdPendingList);
7632 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7633 while(pEntry)
7634 {
7635 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7636 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7637 {
7638 fRet = eANI_BOOLEAN_TRUE;
7639 break;
7640 }
7641 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7642 }
7643 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7644 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307645 if (eANI_BOOLEAN_FALSE == fRet)
7646 {
7647 csrLLLock(&pMac->roam.roamCmdPendingList);
7648 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7649 while (pEntry)
7650 {
7651 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7652 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7653 {
7654 fRet = eANI_BOOLEAN_TRUE;
7655 break;
7656 }
7657 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7658 }
7659 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7660 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007661 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007662 return (fRet);
7663}
7664
Jeff Johnson295189b2012-06-20 16:38:30 -07007665tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7666{
7667 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7668 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007669 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7670 {
7671 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7672 {
7673 break;
7674 }
7675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007676 return ( fRet );
7677}
7678
Jeff Johnson295189b2012-06-20 16:38:30 -07007679tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7680{
7681 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007682 //alwasy lock active list before locking pending list
7683 csrLLLock( &pMac->sme.smeCmdActiveList );
7684 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7685 if(eANI_BOOLEAN_FALSE == fRet)
7686 {
7687 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7688 }
7689 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007690 return (fRet);
7691}
7692
Jeff Johnson295189b2012-06-20 16:38:30 -07007693tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7694{
7695 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7696 tListElem *pEntry;
7697 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007698 //alwasy lock active list before locking pending list
7699 csrLLLock( &pMac->sme.smeCmdActiveList );
7700 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7701 if( pEntry )
7702 {
7703 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7704 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7705 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7706 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7707 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7708 {
7709 fRet = eANI_BOOLEAN_TRUE;
7710 }
7711 }
7712 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007713 return (fRet);
7714}
Jeff Johnson295189b2012-06-20 16:38:30 -07007715eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7716{
7717 eHalStatus status = eHAL_STATUS_SUCCESS;
7718 tSmeCmd *pCommand = NULL;
7719 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7720 tANI_BOOLEAN fRemoveCmd = FALSE;
7721 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007722 // Delete the old assoc command. All is setup for reassoc to be serialized
7723 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7724 if ( pEntry )
7725 {
7726 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7727 if ( !pCommand )
7728 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007729 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007730 return eHAL_STATUS_RESOURCES;
7731 }
7732 if ( eSmeCommandRoam == pCommand->command )
7733 {
7734 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7735 {
7736 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7737 }
7738 else
7739 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007740 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007741 }
7742 if (fRemoveCmd == FALSE)
7743 {
7744 // Implies we did not get the serialized assoc command we
7745 // were expecting
7746 pCommand = NULL;
7747 }
7748 }
7749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007750 if(NULL == pCommand)
7751 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007752 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007753 return eHAL_STATUS_RESOURCES;
7754 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007755 do
7756 {
7757 //Change the substate in case it is wait-for-key
7758 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7759 {
7760 csrRoamStopWaitForKeyTimer( pMac );
7761 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7762 }
7763 pCommand->command = eSmeCommandRoam;
7764 pCommand->sessionId = (tANI_U8)sessionId;
7765 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007766 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7767 if( !HAL_STATUS_SUCCESS( status ) )
7768 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007769 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007770 csrReleaseCommandRoam( pMac, pCommand );
7771 }
7772 } while( 0 );
7773
Jeff Johnson295189b2012-06-20 16:38:30 -07007774 return( status );
7775}
7776static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7777{
7778 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7779 tCsrScanResult *pScanResult = NULL;
7780 tSirBssDescription *pBssDesc = NULL;
7781 tSmeCmd *pCommand = NULL;
7782 tANI_U32 sessionId;
7783 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007784 if(NULL == pEntry)
7785 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307786 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007787 return;
7788 }
7789 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7790 sessionId = pCommand->sessionId;
7791 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007792
7793 if(!pSession)
7794 {
7795 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7796 return;
7797 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307798 smsLog(pMac, LOG1, FL("CFG return value is %d "
7799 " current state is : %d substate is : %d "),
7800 result, pMac->roam.curState[sessionId],
7801 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007802 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7803 {
7804 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007805 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007806 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7807 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007808 /* If the roaming has stopped, not to continue the roaming command*/
7809 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7810 {
7811 //No need to complete roaming here as it already completes
7812 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7813 pCommand->u.roamCmd.roamReason);
7814 csrSetAbortRoamingCommand( pMac, pCommand );
7815 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7816 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007817 else
7818 {
7819 if ( CCM_IS_RESULT_SUCCESS(result) )
7820 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307821 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007822 // Successfully set the configuration parameters for the new Bss. Attempt to
7823 // join the roaming Bss.
7824 if(pCommand->u.roamCmd.pRoamBssEntry)
7825 {
7826 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7827 pBssDesc = &pScanResult->Result.BssDescriptor;
7828 }
7829 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7830 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007831 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007832 )
7833 {
7834 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7835 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7836 pBssDesc, pCommand->u.roamCmd.roamId )))
7837 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307838 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007839 //We need to complete the command
7840 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7841 }
7842 }
7843 else
7844 {
7845 if (!pCommand->u.roamCmd.pRoamBssEntry)
7846 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307847 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007848 //We need to complete the command
7849 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7850 return;
7851 }
7852 // If we are roaming TO an Infrastructure BSS...
7853 VOS_ASSERT(pScanResult != NULL);
7854 if ( csrIsInfraBssDesc( pBssDesc ) )
7855 {
7856 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307857 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007858 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7859 {
7860 // ..and currently in an Infrastructure connection....
7861 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7862 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307863 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007864 // ...and the SSIDs are equal, then we Reassoc.
7865 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7866 pIesLocal ) )
7867 // ..and currently in an infrastructure connection
7868 {
7869 // then issue a Reassoc.
7870 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7871 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7872 &pCommand->u.roamCmd.roamProfile );
7873 }
7874 else
7875 {
7876
7877 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7878 // previously associated AP.
7879 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7880 pIesLocal,
7881 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7882 {
7883 //try something else
7884 csrRoam( pMac, pCommand );
7885 }
7886 }
7887 }
7888 else
7889 {
7890 eHalStatus status = eHAL_STATUS_SUCCESS;
7891
7892 /* We need to come with other way to figure out that this is because of HO in BMP
7893 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007894 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07007895 * use join request */
7896#ifdef WLAN_FEATURE_VOWIFI_11R
7897 if (csrRoamIsHandoffInProgress(pMac) &&
7898 csrRoamIs11rAssoc(pMac))
7899 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307900 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07007901 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7902 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7903 }
7904 else
7905#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007906#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007907 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007908 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07007909 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307910 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07007911 // Now serialize the reassoc command.
7912 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7913 }
7914 else
7915#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007916#ifdef FEATURE_WLAN_LFR
7917 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307918 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007919 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307920 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007921 // Now serialize the reassoc command.
7922 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7923 }
7924 else
7925#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007926 // else we are not connected and attempting to Join. Issue the
7927 // Join request.
7928 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307929 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07007930 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7931 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7932 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7933 }
7934 if(!HAL_STATUS_SUCCESS(status))
7935 {
7936 //try something else
7937 csrRoam( pMac, pCommand );
7938 }
7939 }
7940 if( !pScanResult->Result.pvIes )
7941 {
7942 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307943 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007944 }
7945 }
7946 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7947 else
7948 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007949 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007950 }
7951 }//else
7952 }//if ( WNI_CFG_SUCCESS == result )
7953 else
7954 {
7955 // In the event the configuration failed, for infra let the roam processor
7956 //attempt to join something else...
7957 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7958 {
7959 csrRoam(pMac, pCommand);
7960 }
7961 else
7962 {
7963 //We need to complete the command
7964 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7965 {
7966 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7967 }
7968 else
7969 {
7970 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7971 }
7972 }
7973 }
7974 }//we have active entry
7975}
7976
Jeff Johnson295189b2012-06-20 16:38:30 -07007977static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7978{
7979 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007980 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007981 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7982 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007983 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007984 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7985 // join the new one...
7986 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007987 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7988 }
7989 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007990 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007991 /***profHandleLostLinkAfterReset(pAdapter);
7992 // In the event the authenticate fails, let the roam processor attempt to join something else...
7993 roamRoam( pAdapter );***/
7994 }
7995}
7996
Jeff Johnson295189b2012-06-20 16:38:30 -07007997static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7998{
7999 eCsrRoamCompleteResult result;
8000 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8001 tCsrRoamInfo roamInfo;
8002 tANI_U32 roamId = 0;
8003
8004 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
8005 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008006 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008007 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07008008 /* Defeaturize this part later if needed */
8009#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
8010 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
8011 * we need the response contents while processing the result in csrRoamProcessResults() */
8012 if (csrRoamIsHandoffInProgress(pMac))
8013 {
8014 /* Need to dig more on indicating events to SME QoS module */
8015 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8016 csrRoamComplete( pMac, result, pSmeJoinRsp);
8017 }
8018 else
8019#endif
8020 {
8021 csrRoamComplete( pMac, result, NULL );
8022 }
8023 }
8024 /* Should we handle this similar to handling the join failure? Is it ok
8025 * to call csrRoamComplete() with state as CsrJoinFailure */
8026 else
8027 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008028 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008029 result = eCsrReassocFailure;
8030#ifdef WLAN_FEATURE_VOWIFI_11R
8031 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +05308032 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode) ||
8033 (eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA == pSmeJoinRsp->statusCode))
Jeff Johnson295189b2012-06-20 16:38:30 -07008034 {
8035 // Inform HDD to turn off FT flag in HDD
8036 if (pNeighborRoamInfo)
8037 {
8038 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8039 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
8040 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07008041 /*
8042 * Since the above callback sends a disconnect
8043 * to HDD, we should clean-up our state
8044 * machine as well to be in sync with the upper
8045 * layers. There is no need to send a disassoc
8046 * since: 1) we will never reassoc to the current
8047 * AP in LFR, and 2) there is no need to issue a
8048 * disassoc to the AP with which we were trying
8049 * to reassoc.
8050 */
8051 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8052 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008053 }
8054 }
8055#endif
8056 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
8057 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
8058 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
8059 //The disassoc rsp message will remove the command from active list
8060 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
8061 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
8062 {
8063 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8064 }
8065 }
8066}
8067
Jeff Johnson295189b2012-06-20 16:38:30 -07008068static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
8069{
Jeff Johnson295189b2012-06-20 16:38:30 -07008070#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8071 {
8072 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008073 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8074 if(pIbssLog)
8075 {
8076 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8077 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
8078 {
8079 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8080 }
8081 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8082 }
8083 }
8084#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008085 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8086 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8087 {
8088 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8089 }
8090 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8091 {
8092 csrRoamReissueRoamCommand(pMac);
8093 }
8094}
8095
Jeff Johnson295189b2012-06-20 16:38:30 -07008096void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8097{
8098 tSirResultCodes statusCode;
8099#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8100 tScanResultHandle hBSSList;
8101 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8102 eHalStatus status;
8103 tCsrRoamInfo roamInfo;
8104 tCsrScanResultFilter *pScanFilter = NULL;
8105 tANI_U32 roamId = 0;
8106 tCsrRoamProfile *pCurRoamProfile = NULL;
8107 tListElem *pEntry = NULL;
8108 tSmeCmd *pCommand = NULL;
8109#endif
8110 tANI_U32 sessionId;
8111 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07008112
Jeff Johnson295189b2012-06-20 16:38:30 -07008113 tSirSmeDisassocRsp SmeDisassocRsp;
8114
8115 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8116 sessionId = SmeDisassocRsp.sessionId;
8117 statusCode = SmeDisassocRsp.statusCode;
8118
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008119 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008120
8121 if ( csrIsConnStateInfra( pMac, sessionId ) )
8122 {
8123 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8124 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008125 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008126
8127 if(!pSession)
8128 {
8129 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8130 return;
8131 }
8132
Jeff Johnson295189b2012-06-20 16:38:30 -07008133 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8134 {
8135 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8136 }
8137 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8138 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8139 {
8140 if ( eSIR_SME_SUCCESS == statusCode )
8141 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008142 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008143 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8144 }
8145 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8146 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008147 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8148 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308149 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8150 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008151#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008152 /*
8153 * First ensure if the roam profile is in the scan cache.
8154 * If not, post a reassoc failure and disconnect.
8155 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308156 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8157 if ( NULL == pScanFilter )
8158 status = eHAL_STATUS_FAILURE;
8159 else
8160 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008161 if(HAL_STATUS_SUCCESS(status))
8162 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308163 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008164 status = csrRoamPrepareFilterFromProfile(pMac,
8165 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8166 if(!HAL_STATUS_SUCCESS(status))
8167 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008168 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008169 __func__, status);
8170 goto POST_ROAM_FAILURE;
8171 }
8172 else
8173 {
8174 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8175 if (!HAL_STATUS_SUCCESS(status))
8176 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008177 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008178 __func__, status);
8179 goto POST_ROAM_FAILURE;
8180 }
8181 }
8182 }
8183 else
8184 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008185 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008186 __func__, status);
8187 goto POST_ROAM_FAILURE;
8188 }
8189
8190 /*
8191 * After ensuring that the roam profile is in the scan result list,
8192 * dequeue the command from the active list.
8193 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008194 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8195 if ( pEntry )
8196 {
8197 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008198 /* If the head of the queue is Active and it is a ROAM command, remove
8199 * and put this on the Free queue.
8200 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008201 if ( eSmeCommandRoam == pCommand->command )
8202 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008203
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008204 /*
8205 * we need to process the result first before removing it from active list
8206 * because state changes still happening insides roamQProcessRoamResults so
8207 * no other roam command should be issued.
8208 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008209 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8210 if(pCommand->u.roamCmd.fReleaseProfile)
8211 {
8212 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8213 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8214 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008215 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008216 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008217 else
8218 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008219 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008220 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008221 }
8222 }
8223 else
8224 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008225 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008226 }
8227 }
8228 else
8229 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008230 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008231 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008232
8233 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008234 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8235
Kiet Lam64c1b492013-07-12 13:56:44 +05308236 vos_mem_copy(roamInfo.bssid,
8237 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8238 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008239
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008240 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8241 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008242
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008243 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308244 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8245 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008246 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308247 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008248 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8249 //make sure to put it at the head of the cmd queue
8250 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8251 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8252 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8253
Jeff Johnson295189b2012-06-20 16:38:30 -07008254 if(!HAL_STATUS_SUCCESS(status))
8255 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008256 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008257 __func__, status);
8258 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008259 }
8260
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008261 /* Notify sub-modules like QoS etc. that handoff happening */
8262 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008263 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308264 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008265 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308266 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008267 return;
8268 }
8269
8270POST_ROAM_FAILURE:
8271 if (pScanFilter)
8272 {
8273 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308274 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008275 }
8276 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308277 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008278
8279 /* Inform the upper layers that the reassoc failed */
8280 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8281 csrRoamCallCallback(pMac, sessionId,
8282 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8283
8284 /*
8285 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8286 * Upon success, we would re-enter this routine after receiving the disassoc
8287 * response and will fall into the reassoc fail sub-state. And, eventually
8288 * call csrRoamComplete which would remove the roam command from SME active
8289 * queue.
8290 */
8291 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8292 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8293 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008294 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008295 __func__, status);
8296 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008297 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008298#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008299
Jeff Johnson295189b2012-06-20 16:38:30 -07008300 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8301 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8302 {
8303 // Disassoc due to Reassoc failure falls into this codepath....
8304 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8305 }
8306 else
8307 {
8308 if ( eSIR_SME_SUCCESS == statusCode )
8309 {
8310 // Successfully disassociated from the 'old' Bss...
8311 //
8312 // We get Disassociate response in three conditions.
8313 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8314 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8315 // Infrastructure network.
8316 // - Third is where we are doing an Infra to Infra roam between networks with different
8317 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8318
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008319 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008320 }
8321 else
8322 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008323 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008324 }
8325 //We are not done yet. Get the data and continue roaming
8326 csrRoamReissueRoamCommand(pMac);
8327 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008328}
8329
Jeff Johnson295189b2012-06-20 16:38:30 -07008330static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8331{
8332 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008333 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008334 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008335 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008336 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008337 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8338 {
8339 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8340 }
8341 else
8342 {
8343 if ( eSIR_SME_SUCCESS == statusCode )
8344 {
8345 // Successfully deauth from the 'old' Bss...
8346 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008347 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008348 }
8349 else
8350 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008351 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008352 }
8353 //We are not done yet. Get the data and continue roaming
8354 csrRoamReissueRoamCommand(pMac);
8355 }
8356}
8357
Jeff Johnson295189b2012-06-20 16:38:30 -07008358static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8359{
8360 eCsrRoamCompleteResult result;
8361
8362 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8363 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008364 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008365 result = eCsrStartBssSuccess;
8366 }
8367 else
8368 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008369 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008370 //Let csrRoamComplete decide what to do
8371 result = eCsrStartBssFailure;
8372 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008373 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008374}
8375
Jeff Johnson295189b2012-06-20 16:38:30 -07008376/*
8377 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8378 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8379 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8380 For the messages where sender allocates memory for specific structures, then it can be
8381 cast accordingly.
8382*/
8383void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8384{
8385 tSirSmeRsp *pSmeRsp;
8386 tSmeIbssPeerInd *pIbssPeerInd;
8387 tCsrRoamInfo roamInfo;
8388 // TODO Session Id need to be acquired in this function
8389 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008390 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308391 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8392 pSmeRsp->messageType, pSmeRsp->messageType,
8393 macTraceGetcsrRoamSubState(
8394 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008395 pSmeRsp->messageType = (pSmeRsp->messageType);
8396 pSmeRsp->length = (pSmeRsp->length);
8397 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008398 switch (pSmeRsp->messageType)
8399 {
8400
8401 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8402 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8403 {
8404 //We sent a JOIN_REQ
8405 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8406 }
8407 break;
8408
8409 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8410 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8411 {
8412 //We sent a AUTH_REQ
8413 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8414 }
8415 break;
8416
8417 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8418 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8419 {
8420 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8421 }
8422 break;
8423
8424 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8425 {
8426 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8427 }
8428 break;
8429
8430 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8431 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8432 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8433 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8434 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8435 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8436//HO
8437 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8438 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308439 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8440 macTraceGetcsrRoamSubState(
8441 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008442 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05308443#ifdef DEBUG_ROAM_DELAY
8444 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
8445#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008446 }
8447 break;
8448
8449 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8450 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8451 {
8452 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8453 }
8454 break;
8455
8456 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8457 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8458 {
8459 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8460 }
8461 break;
8462
8463 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8464 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8465 {
8466 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008468 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008469 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8470 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8471 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008472 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308473 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8474 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008475 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8476 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308477 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8478 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008479 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8480 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8481 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8482 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008483 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308484 smsLog(pMac, LOG1,
8485 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8486 pSmeRsp->messageType, pSmeRsp->messageType,
8487 macTraceGetcsrRoamSubState(
8488 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008489
8490 //If we are connected, check the link status change
8491 if(!csrIsConnStateDisconnected(pMac, sessionId))
8492 {
8493 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8494 }
8495 break;
8496 }
8497}
8498
Jeff Johnson295189b2012-06-20 16:38:30 -07008499void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8500{
8501 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008502 switch (pSirMsg->messageType)
8503 {
8504 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008505 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008506 csrRoamStatsRspProcessor( pMac, pSirMsg );
8507 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008508 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8509 {
8510 tCsrRoamSession *pSession;
8511 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8512 tCsrRoamInfo roamInfo;
8513 tCsrRoamInfo *pRoamInfo = NULL;
8514 tANI_U32 sessionId;
8515 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008516 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308517 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008518 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008519 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8520 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8521 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008522
8523 if(!pSession)
8524 {
8525 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8526 return;
8527 }
8528
Jeff Johnson295189b2012-06-20 16:38:30 -07008529 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8530 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008531 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8532 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8533 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008534 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8535 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308536 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8537 sizeof(tSirMacAddr));
8538 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8539 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008540 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05308541#ifdef WLAN_FEATURE_AP_HT40_24G
8542 pRoamInfo->HT40MHzIntoEnabledSta =
8543 pUpperLayerAssocCnf->HT40MHzIntoEnabledSta;
8544 smsLog( pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
8545 pRoamInfo->HT40MHzIntoEnabledSta);
8546#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008547 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8548 {
8549 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8550 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8551 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8552 }
8553 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8554 {
8555 vos_sleep( 100 );
8556 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8557 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8558 }
8559
Jeff Johnson295189b2012-06-20 16:38:30 -07008560 }
8561 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008562 default:
8563 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8564 break;
8565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008566}
8567
Jeff Johnson295189b2012-06-20 16:38:30 -07008568eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8569 tSirBssDescription *pBssDescription,
8570 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8571 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8572 tANI_U8 keyId, tANI_U16 keyLength,
8573 tANI_U8 *pKey, tANI_U8 paeRole )
8574{
8575 eHalStatus status = eHAL_STATUS_SUCCESS;
8576 tAniEdType edType;
8577
8578 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8579 {
8580 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8581 }
8582
8583 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8584
8585 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8586 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8587 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8588 addKey )
8589 {
8590 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008591 setKey.encType = EncryptType;
8592 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308593 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008594 setKey.paeRole = paeRole; //0 for supplicant
8595 setKey.keyId = keyId; // Kye index
8596 setKey.keyLength = keyLength;
8597 if( keyLength )
8598 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308599 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008600 }
8601 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8602 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008603 return (status);
8604}
8605
Jeff Johnson295189b2012-06-20 16:38:30 -07008606static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8607 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8608{
8609 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8610 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008611#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008612 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008613#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07008614
8615 do
8616 {
8617 pCommand = csrGetCommandBuffer(pMac);
8618 if(NULL == pCommand)
8619 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008620 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008621 status = eHAL_STATUS_RESOURCES;
8622 break;
8623 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05308624 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07008625 pCommand->command = eSmeCommandSetKey;
8626 pCommand->sessionId = (tANI_U8)sessionId;
8627 // validate the key length, Adjust if too long...
8628 // for static WEP the keys are not set thru' SetContextReq
8629 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8630 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8631 {
8632 //KeyLength maybe 0 for static WEP
8633 if( pSetKey->keyLength )
8634 {
8635 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8636 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008637 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008638 break;
8639 }
8640
8641 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308642 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8643 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008644 }
8645 }
8646 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8647 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8648 {
8649 //KeyLength maybe 0 for static WEP
8650 if( pSetKey->keyLength )
8651 {
8652 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8653 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008654 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008655 break;
8656 }
8657
8658 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308659 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8660 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008661 }
8662 }
8663 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8664 {
8665 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8666 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008667 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008668 break;
8669 }
8670 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308671 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8672 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008673 }
8674 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8675 {
8676 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8677 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008678 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008679 break;
8680 }
8681 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308682 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8683 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008684 }
8685#ifdef FEATURE_WLAN_WAPI
8686 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8687 {
8688 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8689 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008690 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008691 break;
8692 }
8693 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308694 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8695 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008696 }
8697#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008698#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008699 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8700 {
8701 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8702 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008703 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008704 break;
8705 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008706 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05308707 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008708 pSession->eseCckmInfo.reassoc_req_num=1;
8709 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008710 status = eHAL_STATUS_SUCCESS;
8711 break;
8712 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008713#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07008714
Jeff Johnson295189b2012-06-20 16:38:30 -07008715#ifdef WLAN_FEATURE_11W
8716 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008717 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008718 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008719 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008720 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008721 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008722 break;
8723 }
8724 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308725 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008726 }
8727#endif
8728 status = eHAL_STATUS_SUCCESS;
8729 pCommand->u.setKeyCmd.roamId = roamId;
8730 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8731 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308732 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8733 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008734 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8735 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308736 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008737 //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
8738
8739 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8740 if( !HAL_STATUS_SUCCESS( status ) )
8741 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008742 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008743 }
8744 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008745 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008746 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008747 if ( ( NULL != pCommand ) &&
8748 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008749#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008750 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008751#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008752 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008753 {
8754 csrReleaseCommandSetKey( pMac, pCommand );
8755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008756 return( status );
8757}
8758
Jeff Johnson295189b2012-06-20 16:38:30 -07008759eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8760 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8761{
8762 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8763 tSmeCmd *pCommand = NULL;
8764 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008765 do
8766 {
8767 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8768 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008769 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008770 status = eHAL_STATUS_CSR_WRONG_STATE;
8771 break;
8772 }
8773 pCommand = csrGetCommandBuffer(pMac);
8774 if(NULL == pCommand)
8775 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008776 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008777 status = eHAL_STATUS_RESOURCES;
8778 break;
8779 }
8780 pCommand->command = eSmeCommandRemoveKey;
8781 pCommand->sessionId = (tANI_U8)sessionId;
8782 pCommand->u.removeKeyCmd.roamId = roamId;
8783 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308784 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8785 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008786 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8787 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8788 {
8789 //in this case, put it to the end of the Q incase there is a set key pending.
8790 fImediate = eANI_BOOLEAN_FALSE;
8791 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008792 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008793 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008794 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008795 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8796 if( !HAL_STATUS_SUCCESS( status ) )
8797 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008798 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008799 break;
8800 }
8801 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008802 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8803 {
8804 csrReleaseCommandRemoveKey( pMac, pCommand );
8805 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008806 return (status );
8807}
8808
Jeff Johnson295189b2012-06-20 16:38:30 -07008809eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8810{
8811 eHalStatus status;
8812 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8813 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8814 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8815 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008816#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8817 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8818 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05308819 if(!pSession)
8820 {
8821 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8822 return eHAL_STATUS_FAILURE;
8823 }
lukez3c809222013-05-03 10:23:02 -07008824 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008825 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308826 vos_mem_set(&setKeyEvent,
8827 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008828 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8829 {
8830 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8831 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8832 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8833 }
8834 else
8835 {
8836 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8837 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8838 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8839 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308840 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008841 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008842 {
8843 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008844 //It has to be static WEP here
8845 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8846 {
8847 setKeyEvent.keyId = (v_U8_t)defKeyId;
8848 }
8849 }
8850 else
8851 {
8852 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8853 }
8854 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8855 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8856 }
8857#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008858 if( csrIsSetKeyAllowed(pMac, sessionId) )
8859 {
8860 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8861 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8862 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8863 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8864 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8865 pCommand->u.setKeyCmd.keyRsc);
8866 }
8867 else
8868 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008869 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008870 //Set this status so the error handling take care of the case.
8871 status = eHAL_STATUS_CSR_WRONG_STATE;
8872 }
8873 if( !HAL_STATUS_SUCCESS(status) )
8874 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008875 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008876 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008877#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008878 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 {
8880 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8881 {
8882 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8883 }
8884 else
8885 {
8886 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8887 }
8888 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8889 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8890 }
8891#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008892 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008893 return ( status );
8894}
8895
Jeff Johnson295189b2012-06-20 16:38:30 -07008896eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8897{
8898 eHalStatus status;
8899 tpSirSmeRemoveKeyReq pMsg = NULL;
8900 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8901 tANI_U8 *p;
8902 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008903#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8904 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8905 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05308906 if(!pSession)
8907 {
8908 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8909 return eHAL_STATUS_FAILURE;
8910 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308911 vos_mem_set(&removeKeyEvent,
8912 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008913 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8914 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8915 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308916 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008917 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8918 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8919 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8920#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008921 if( csrIsSetKeyAllowed(pMac, sessionId) )
8922 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308923 pMsg = vos_mem_malloc(wMsgLen);
8924 if ( NULL == pMsg )
8925 status = eHAL_STATUS_FAILURE;
8926 else
8927 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008928 }
8929 else
8930 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008931 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008932 //Set the error status so error handling kicks in below
8933 status = eHAL_STATUS_CSR_WRONG_STATE;
8934 }
8935 if( HAL_STATUS_SUCCESS( status ) )
8936 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308937 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008938 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8939 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008940 pMsg->sessionId = (tANI_U8)sessionId;
8941 pMsg->transactionId = 0;
8942 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8943 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8944 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308945 vos_mem_copy(p,
8946 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8947 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008948 p += sizeof(tSirMacAddr);
8949 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308950 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008951 p += sizeof(tSirMacAddr);
8952 // edType
8953 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8954 p++;
8955 // weptype
8956 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8957 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8958 {
8959 *p = (tANI_U8)eSIR_WEP_STATIC;
8960 }
8961 else
8962 {
8963 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8964 }
8965 p++;
8966 //keyid
8967 *p = pCommand->u.removeKeyCmd.keyId;
8968 p++;
8969 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008970 status = palSendMBMessage(pMac->hHdd, pMsg);
8971 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008972 if( !HAL_STATUS_SUCCESS( status ) )
8973 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008974 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008975#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8976 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008977 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008978 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8979#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008980 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8981 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008982 return ( status );
8983}
8984
Jeff Johnson295189b2012-06-20 16:38:30 -07008985eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8986{
8987 eHalStatus status;
8988
8989 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8990 {
8991 status = eHAL_STATUS_CSR_WRONG_STATE;
8992 }
8993 else
8994 {
8995 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8996 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008997 return ( status );
8998}
8999
Jeff Johnson295189b2012-06-20 16:38:30 -07009000/*
9001 Prepare a filter base on a profile for parsing the scan results.
9002 Upon successful return, caller MUST call csrFreeScanFilter on
9003 pScanFilter when it is done with the filter.
9004*/
9005eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9006 tCsrScanResultFilter *pScanFilter)
9007{
9008 eHalStatus status = eHAL_STATUS_SUCCESS;
9009 tANI_U32 size = 0;
9010 tANI_U8 index = 0;
9011
9012 do
9013 {
9014 if(pProfile->BSSIDs.numOfBSSIDs)
9015 {
9016 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309017 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
9018 if ( NULL == pScanFilter->BSSIDs.bssid )
9019 status = eHAL_STATUS_FAILURE;
9020 else
9021 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009022 if(!HAL_STATUS_SUCCESS(status))
9023 {
9024 break;
9025 }
9026 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309027 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009028 }
9029 if(pProfile->SSIDs.numOfSSIDs)
9030 {
9031 if( !CSR_IS_WDS_STA( pProfile ) )
9032 {
9033 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
9034 }
9035 else
9036 {
9037 //For WDS station
9038 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
9039 pScanFilter->SSIDs.numOfSSIDs = 1;
9040 }
9041 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309042 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
9043 if ( NULL == pScanFilter->SSIDs.SSIDList )
9044 status = eHAL_STATUS_FAILURE;
9045 else
9046 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009047 if(!HAL_STATUS_SUCCESS(status))
9048 {
9049 break;
9050 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309051 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
9052 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009053 }
9054 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
9055 {
9056 pScanFilter->ChannelInfo.numOfChannels = 0;
9057 pScanFilter->ChannelInfo.ChannelList = NULL;
9058 }
9059 else if(pProfile->ChannelInfo.numOfChannels)
9060 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309061 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
9062 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
9063 pProfile->ChannelInfo.numOfChannels);
9064 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
9065 status = eHAL_STATUS_FAILURE;
9066 else
9067 status = eHAL_STATUS_SUCCESS;
9068
Jeff Johnson295189b2012-06-20 16:38:30 -07009069 pScanFilter->ChannelInfo.numOfChannels = 0;
9070 if(HAL_STATUS_SUCCESS(status))
9071 {
9072 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
9073 {
9074 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
9075 {
9076 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
9077 = pProfile->ChannelInfo.ChannelList[index];
9078 pScanFilter->ChannelInfo.numOfChannels++;
9079 }
9080 else
9081 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009082 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009083 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009084 }
9085 }
9086 else
9087 {
9088 break;
9089 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009090 }
9091 else
9092 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05309093 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009094 status = eHAL_STATUS_FAILURE;
9095 break;
9096 }
9097 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
9098 pScanFilter->authType = pProfile->AuthType;
9099 pScanFilter->EncryptionType = pProfile->EncryptionType;
9100 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9101 pScanFilter->BSSType = pProfile->BSSType;
9102 pScanFilter->phyMode = pProfile->phyMode;
9103#ifdef FEATURE_WLAN_WAPI
9104 //check if user asked for WAPI with 11n or auto mode, in that case modify
9105 //the phymode to 11g
9106 if(csrIsProfileWapi(pProfile))
9107 {
9108 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9109 {
9110 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9111 }
9112 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9113 {
9114 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9115 }
9116 if(!pScanFilter->phyMode)
9117 {
9118 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9119 }
9120 }
9121#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009122 /*Save the WPS info*/
9123 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009124 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009125 if( pProfile->countryCode[0] )
9126 {
9127 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309128 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9129 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009130 }
9131#ifdef WLAN_FEATURE_VOWIFI_11R
9132 if (pProfile->MDID.mdiePresent)
9133 {
9134 pScanFilter->MDID.mdiePresent = 1;
9135 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9136 }
9137#endif
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309138
9139#ifdef WLAN_FEATURE_11W
9140 // Management Frame Protection
9141 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9142 pScanFilter->MFPRequired = pProfile->MFPRequired;
9143 pScanFilter->MFPCapable = pProfile->MFPCapable;
9144#endif
9145
Jeff Johnson295189b2012-06-20 16:38:30 -07009146 }while(0);
9147
9148 if(!HAL_STATUS_SUCCESS(status))
9149 {
9150 csrFreeScanFilter(pMac, pScanFilter);
9151 }
9152
9153 return(status);
9154}
9155
Jeff Johnson295189b2012-06-20 16:38:30 -07009156tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9157 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9158{
9159 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9160 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 do
9162 {
9163 // Validate the type is ok...
9164 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9165 pCommand = csrGetCommandBuffer( pMac );
9166 if ( !pCommand )
9167 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009168 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009169 break;
9170 }
9171 //Change the substate in case it is waiting for key
9172 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9173 {
9174 csrRoamStopWaitForKeyTimer( pMac );
9175 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9176 }
9177 pCommand->command = eSmeCommandWmStatusChange;
9178 pCommand->sessionId = (tANI_U8)sessionId;
9179 pCommand->u.wmStatusChangeCmd.Type = Type;
9180 if ( eCsrDisassociated == Type )
9181 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309182 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9183 pSmeRsp,
9184 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009185 }
9186 else
9187 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309188 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9189 pSmeRsp,
9190 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009191 }
9192 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9193 {
9194 fCommandQueued = eANI_BOOLEAN_TRUE;
9195 }
9196 else
9197 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009198 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009199 csrReleaseCommandWmStatusChange( pMac, pCommand );
9200 }
9201
Jeff Johnson295189b2012-06-20 16:38:30 -07009202 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9203 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009204 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009205 return( fCommandQueued );
9206}
9207
Jeff Johnson295189b2012-06-20 16:38:30 -07009208static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9209{
9210 v_S7_t rssi = 0;
9211 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9212 if(pGetRssiReq)
9213 {
9214 if(NULL != pGetRssiReq->pVosContext)
9215 {
9216 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9217 }
9218 else
9219 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009220 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009221 return;
9222 }
9223
9224 if(NULL != pGetRssiReq->rssiCallback)
9225 {
9226 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9227 }
9228 else
9229 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009230 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009231 return;
9232 }
9233 }
9234 else
9235 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009236 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009237 }
9238 return;
9239}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309240
9241static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9242{
9243 tANI_S8 snr = 0;
9244 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9245
9246 if (pGetSnrReq)
9247 {
9248 if (VOS_STATUS_SUCCESS !=
9249 WDA_GetSnr(pGetSnrReq->staId, &snr))
9250 {
9251 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9252 return;
9253 }
9254
9255 if (pGetSnrReq->snrCallback)
9256 {
9257 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9258 pGetSnrReq->pDevContext);
9259 }
9260 else
9261 {
9262 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9263 return;
9264 }
9265 }
9266 else
9267 {
9268 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9269 }
9270 return;
9271}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009272#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009273void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9274{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009275 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9276
Jeff Johnson36d483b2013-04-08 11:08:53 -07009277 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009278 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009279 /* Get roam Rssi request is backed up and passed back to the response,
9280 Extract the request message to fetch callback */
9281 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9282 v_S7_t rssi = pRoamRssiRsp->rssi;
9283
9284 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009285 {
9286 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9287 reqBkp->rssiCallback = NULL;
9288 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009289 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009290 }
9291 else
9292 {
9293 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9294 if (NULL != reqBkp)
9295 {
9296 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009297 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009298 }
9299 }
9300 }
9301 else
9302 {
9303 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9304 }
9305 return;
9306}
9307#endif
9308
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009309
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009310#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009311void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9312{
9313 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9314
9315 if (NULL != pTsmStatsRsp)
9316 {
9317 /* Get roam Rssi request is backed up and passed back to the response,
9318 Extract the request message to fetch callback */
9319 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9320
9321 if (NULL != reqBkp)
9322 {
9323 if (NULL != reqBkp->tsmStatsCallback)
9324 {
9325 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9326 pTsmStatsRsp->staId, reqBkp->pDevContext);
9327 reqBkp->tsmStatsCallback = NULL;
9328 }
9329 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009330 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009331 }
9332 else
9333 {
9334 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9335 if (NULL != reqBkp)
9336 {
9337 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009338 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009339 }
9340 }
9341 }
9342 else
9343 {
9344 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9345 }
9346 return;
9347}
9348
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009349void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009350{
9351 tANI_U32 roamTS2 = 0;
9352 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009353 tpPESession pSessionEntry = NULL;
9354 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009355
9356 if (NULL == pSession)
9357 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009358 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009359 return;
9360 }
9361
9362 roamTS2 = vos_timer_get_system_time();
9363 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009364 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9365 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009366 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009367
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009368 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9369 if (NULL == pSessionEntry)
9370 {
9371 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9372 return;
9373 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009374 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009375 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009376 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009377}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009378#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009379
Jeff Johnsone7245742012-09-05 17:12:55 -07009380static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9381{
9382 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9383 if(pTlRssiInd)
9384 {
9385 if(NULL != pTlRssiInd->tlCallback)
9386 {
9387 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009388 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009389 }
9390 else
9391 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009392 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009393 }
9394 }
9395 else
9396 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009397 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009398 }
9399 return;
9400}
Jeff Johnson295189b2012-06-20 16:38:30 -07009401
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309402eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9403{
9404 tpSirResetAPCapsChange pMsg;
9405 tANI_U16 len;
9406 eHalStatus status = eHAL_STATUS_SUCCESS;
9407
9408 /* Create the message and send to lim */
9409 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309410 pMsg = vos_mem_malloc(len);
9411 if ( NULL == pMsg )
9412 status = eHAL_STATUS_FAILURE;
9413 else
9414 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309415 if (HAL_STATUS_SUCCESS(status))
9416 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309417 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309418 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9419 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309420 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009421 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9422 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309423 status = palSendMBMessage(pMac->hHdd, pMsg);
9424 }
9425 else
9426 {
9427 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9428 }
9429 return status;
9430}
9431
Jeff Johnson295189b2012-06-20 16:38:30 -07009432void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9433{
9434 tSirSmeAssocInd *pAssocInd;
9435 tSirSmeDisassocInd *pDisassocInd;
9436 tSirSmeDeauthInd *pDeauthInd;
9437 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9438 tSirSmeNewBssInfo *pNewBss;
9439 tSmeIbssPeerInd *pIbssPeerInd;
9440 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9441 tSirSmeApNewCaps *pApNewCaps;
9442 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9443 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9444 tCsrRoamInfo *pRoamInfo = NULL;
9445 tCsrRoamInfo roamInfo;
9446 eHalStatus status;
9447 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9448 tCsrRoamSession *pSession = NULL;
9449 tpSirSmeSwitchChannelInd pSwitchChnInd;
9450 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309451 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009452
9453
9454 if (NULL == pSirMsg)
9455 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9456 return;
9457 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009458 switch( pSirMsg->messageType )
9459 {
9460 case eWNI_SME_ASSOC_IND:
9461 {
9462 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009463 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009464 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9465 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9466 if( HAL_STATUS_SUCCESS( status ) )
9467 {
9468 pSession = CSR_GET_SESSION(pMac, sessionId);
9469
Jeff Johnson32d95a32012-09-10 13:15:23 -07009470 if(!pSession)
9471 {
9472 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9473 return;
9474 }
9475
Jeff Johnson295189b2012-06-20 16:38:30 -07009476 pRoamInfo = &roamInfo;
9477
9478 // Required for indicating the frames to upper layer
9479 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9480 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9481
9482 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9483 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9484 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9485 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9486
9487 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9488 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9489 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9490
9491 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9492 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309493 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9494 sizeof(tSirMacAddr));
9495 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9496 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009497 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05309498#ifdef WLAN_FEATURE_AP_HT40_24G
9499 pRoamInfo->HT40MHzIntoEnabledSta =
9500 pAssocInd->HT40MHzIntoEnabledSta;
9501 smsLog(pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
9502 pRoamInfo->HT40MHzIntoEnabledSta);
9503#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009504 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009505 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009506 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9507 {
9508 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9509 {
9510 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9511 pSession->pConnectBssDesc,
9512 &(pRoamInfo->peerMac),
9513 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9514 pRoamInfo->fAuthRequired = FALSE;
9515 }
9516 else
9517 {
9518 pRoamInfo->fAuthRequired = TRUE;
9519 }
9520 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9521 if (!HAL_STATUS_SUCCESS(status))
9522 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9523 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009524 /* Send Association completion message to PE */
9525 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9526
9527 /* send a message to CSR itself just to avoid the EAPOL frames going
9528 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009529 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9530 {
9531 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009533 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9534 {
9535 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9536 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9537 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009539 }
9540 }
9541 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009542 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009543 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309544 // Check if AP dis-associated us because of MIC failure. If so,
9545 // then we need to take action immediately and not wait till the
9546 // the WmStatusChange requests is pushed and processed
9547 tSmeCmd *pCommand;
9548
9549 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9550 status = csrRoamGetSessionIdFromBSSID( pMac,
9551 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9552 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009553 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309554 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9555 " for session %d "), sessionId);
9556 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9557 MAC_ADDRESS_STR " "
9558 " reason = %d status = %d "),
9559 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9560 pDisassocInd->reasonCode,
9561 pDisassocInd->statusCode);
9562 // If we are in neighbor preauth done state then on receiving
9563 // disassoc or deauth we dont roam instead we just disassoc
9564 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009565 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309566#ifdef WLAN_FEATURE_VOWIFI_11R
9567 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9568 {
9569 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9570 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009571#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009572#ifdef FEATURE_WLAN_ESE
9573 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309574 {
9575 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9576 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009577#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009578#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309579 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9580 {
9581 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9582 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009583#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309584 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009585
Agarwal Ashish4f616132013-12-30 23:32:50 +05309586 if (!pSession)
9587 {
9588 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9589 return;
9590 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009591
Agarwal Ashish4f616132013-12-30 23:32:50 +05309592 if ( csrIsConnStateInfra( pMac, sessionId ) )
9593 {
9594 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009596#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309597 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009598#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309599 csrRoamLinkDown(pMac, sessionId);
9600 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9601 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9602 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309603 pRoamInfo = &roamInfo;
9604 pRoamInfo->statusCode = pDisassocInd->statusCode;
9605 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9606 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009607
Agarwal Ashish4f616132013-12-30 23:32:50 +05309608 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9609 sizeof(tSirMacAddr));
9610 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9611 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009612
Agarwal Ashish4f616132013-12-30 23:32:50 +05309613 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9614 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009615
Agarwal Ashish4f616132013-12-30 23:32:50 +05309616 /*
9617 * STA/P2P client got disassociated so remove any pending deauth
9618 * commands in sme pending list
9619 */
Kaushik, Sushant488df382014-03-05 11:43:47 +05309620 pCommand = csrGetCommandBuffer(pMac);
9621 if (NULL == pCommand)
9622 {
9623 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9624 status = eHAL_STATUS_RESOURCES;
9625 return;
9626 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309627 pCommand->command = eSmeCommandRoam;
9628 pCommand->sessionId = (tANI_U8)sessionId;
9629 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9630 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9631 pDisassocInd->peerMacAddr,
9632 sizeof(tSirMacAddr));
9633 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9634 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009635
Agarwal Ashish4f616132013-12-30 23:32:50 +05309636 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009637 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309638 else
9639 {
9640 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9641 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9642 }
Kiet Lam82004c62013-11-11 13:24:28 +05309643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009644 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009645 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009646 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009647 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9648 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9649 if( HAL_STATUS_SUCCESS( status ) )
9650 {
9651 // If we are in neighbor preauth done state then on receiving
9652 // disassoc or deauth we dont roam instead we just disassoc
9653 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009654 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -07009655#ifdef WLAN_FEATURE_VOWIFI_11R
9656 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9657 {
9658 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9659 }
9660#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009661#ifdef FEATURE_WLAN_ESE
9662 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009663 {
9664 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9665 }
9666#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009667#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309668 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009669 {
9670 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9671 }
9672#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009673 pSession = CSR_GET_SESSION( pMac, sessionId );
9674
Jeff Johnson32d95a32012-09-10 13:15:23 -07009675 if(!pSession)
9676 {
9677 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9678 return;
9679 }
9680
Jeff Johnson295189b2012-06-20 16:38:30 -07009681 if ( csrIsConnStateInfra( pMac, sessionId ) )
9682 {
9683 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9684 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009685#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9686 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9687#endif
9688 csrRoamLinkDown(pMac, sessionId);
9689 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009690 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9691 {
9692
9693 pRoamInfo = &roamInfo;
9694
9695 pRoamInfo->statusCode = pDeauthInd->statusCode;
9696 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9697
9698 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9699
Kiet Lam64c1b492013-07-12 13:56:44 +05309700 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9701 sizeof(tSirMacAddr));
9702 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9703 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009704
9705 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9706 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009707 }
9708 break;
9709
9710 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 -08009711 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009712 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9713 //Update with the new channel id.
9714 //The channel id is hidden in the statusCode.
9715 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9716 if( HAL_STATUS_SUCCESS( status ) )
9717 {
9718 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009719 if(!pSession)
9720 {
9721 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9722 return;
9723 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009724 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9725 if(pSession->pConnectBssDesc)
9726 {
9727 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9728 }
9729 }
9730 break;
9731
9732 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009733 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009734 {
9735 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9736 sessionId = pDeauthRsp->sessionId;
9737 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9738 {
9739 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009740 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9741 {
9742 pRoamInfo = &roamInfo;
9743 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309744 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9745 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009746 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9747 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9748 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9749 }
9750 }
9751 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009752 break;
9753
9754 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009755 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009756 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009757 {
9758 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9759 sessionId = pDisassocRsp->sessionId;
9760 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9761 {
9762 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009763 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9764 {
9765 pRoamInfo = &roamInfo;
9766 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309767 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9768 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009769 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9770 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9771 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9772 }
9773 }
9774 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009775 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009776 case eWNI_SME_MIC_FAILURE_IND:
9777 {
9778 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9779 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9780 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009781
9782 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9783 if( HAL_STATUS_SUCCESS( status ) )
9784 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309785 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009786 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9787 pRoamInfo = &roamInfo;
9788 if(pMicInd->info.multicast)
9789 {
9790 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9791 }
9792 else
9793 {
9794 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9795 }
9796 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9797 }
9798
Jeff Johnson295189b2012-06-20 16:38:30 -07009799#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9800 {
lukez3c809222013-05-03 10:23:02 -07009801 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009802 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009803 if(!pSession)
9804 {
9805 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9806 return;
9807 }
lukez3c809222013-05-03 10:23:02 -07009808
Kiet Lam64c1b492013-07-12 13:56:44 +05309809 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009810 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9811 secEvent.encryptionModeMulticast =
9812 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9813 secEvent.encryptionModeUnicast =
9814 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9815 secEvent.authMode =
9816 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309817 vos_mem_copy(secEvent.bssid,
9818 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009819 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9820 }
9821#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009822 }
9823 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009824 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9825 {
9826 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9827 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009828 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009829
9830 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9831 if( HAL_STATUS_SUCCESS( status ) )
9832 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309833 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009834 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9835 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9836 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9837 }
9838 }
9839 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009840
Jeff Johnson295189b2012-06-20 16:38:30 -07009841 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9842 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9843 switch( pStatusChangeMsg->statusChangeCode )
9844 {
9845 case eSIR_SME_IBSS_ACTIVE:
9846 sessionId = csrFindIbssSession( pMac );
9847 if( CSR_SESSION_ID_INVALID != sessionId )
9848 {
9849 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009850 if(!pSession)
9851 {
9852 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9853 return;
9854 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009855 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9856 if(pSession->pConnectBssDesc)
9857 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309858 vos_mem_copy(&roamInfo.bssid,
9859 pSession->pConnectBssDesc->bssId,
9860 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009861 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9862 pRoamInfo = &roamInfo;
9863 }
9864 else
9865 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009866 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009867 }
9868 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9869 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9870 }
9871 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009872 case eSIR_SME_IBSS_INACTIVE:
9873 sessionId = csrFindIbssSession( pMac );
9874 if( CSR_SESSION_ID_INVALID != sessionId )
9875 {
9876 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009877 if(!pSession)
9878 {
9879 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9880 return;
9881 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9883 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9884 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9885 }
9886 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009887 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9888 sessionId = csrFindIbssSession( pMac );
9889 if( CSR_SESSION_ID_INVALID != sessionId )
9890 {
9891 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009892 if(!pSession)
9893 {
9894 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9895 return;
9896 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009897 // update the connection state information
9898 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009899#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9900 {
9901 vos_log_ibss_pkt_type *pIbssLog;
9902 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009903 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9904 if(pIbssLog)
9905 {
9906 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9907 if(pNewBss)
9908 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309909 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009910 if(pNewBss->ssId.length)
9911 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309912 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9913 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009914 }
9915 pIbssLog->operatingChannel = pNewBss->channelNumber;
9916 }
9917 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9918 {
9919 //***U8 is not enough for beacon interval
9920 pIbssLog->beaconInterval = (v_U8_t)bi;
9921 }
9922 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9923 }
9924 }
9925#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009926 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009927
9928 if ((eCSR_ENCRYPT_TYPE_NONE ==
9929 pSession->connectedProfile.EncryptionType ))
9930 {
9931 csrRoamIssueSetContextReq( pMac, sessionId,
9932 pSession->connectedProfile.EncryptionType,
9933 pSession->pConnectBssDesc,
9934 &Broadcastaddr,
9935 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009937 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9938 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309939 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9940 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009941 pRoamInfo = &roamInfo;
9942 //This BSSID is th ereal BSSID, let's save it
9943 if(pSession->pConnectBssDesc)
9944 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309945 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9946 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009947 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009948 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009949 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009950 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009951 // detection by LIM that the capabilities of the associated AP have changed.
9952 case eSIR_SME_AP_CAPS_CHANGED:
9953 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009954 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009955 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9956 if( HAL_STATUS_SUCCESS( status ) )
9957 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009958 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9959 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309960 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009961 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9962 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9963 )
9964 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309965 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9966 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009967 }
9968 else
9969 {
9970 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309971 FL("Skipping csrScanForCapabilityChange as "
9972 "CSR is in state %s and sub-state %s"),
9973 macTraceGetcsrRoamState(
9974 pMac->roam.curState[sessionId]),
9975 macTraceGetcsrRoamSubState(
9976 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309977 /* We ignore the caps change event if CSR is not in full connected state.
9978 * Send one event to PE to reset limSentCapsChangeNtf
9979 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9980 * otherwise lim cannot send any CAPS change events to SME */
9981 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009982 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009983 }
9984 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309985
Jeff Johnson295189b2012-06-20 16:38:30 -07009986 default:
9987 roamStatus = eCSR_ROAM_FAILED;
9988 result = eCSR_ROAM_RESULT_NONE;
9989 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009990 } // end switch on statusChangeCode
9991 if(eCSR_ROAM_RESULT_NONE != result)
9992 {
9993 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9994 }
9995 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009996 case eWNI_SME_IBSS_NEW_PEER_IND:
9997 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009998#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9999 {
10000 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010001 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10002 if(pIbssLog)
10003 {
10004 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +053010005 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010006 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10007 }
10008 }
10009#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010010 sessionId = csrFindIbssSession( pMac );
10011 if( CSR_SESSION_ID_INVALID != sessionId )
10012 {
10013 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010014
10015 if(!pSession)
10016 {
10017 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10018 return;
10019 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010020 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
10021 if(pSession->pConnectBssDesc)
10022 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010023 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10024 sizeof(tCsrBssid));
10025 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
10026 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010027 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
10028 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010029 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
10030 - sizeof(tSmeIbssPeerInd)));
10031 if ( NULL == roamInfo.pbFrames )
10032 status = eHAL_STATUS_FAILURE;
10033 else
10034 status = eHAL_STATUS_SUCCESS;
10035 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010036 {
10037 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +053010038 vos_mem_copy(roamInfo.pbFrames,
10039 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
10040 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070010041 }
10042 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10043 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10044 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010045 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
10046 if ( NULL == roamInfo.pBssDesc )
10047 status = eHAL_STATUS_FAILURE;
10048 else
10049 status = eHAL_STATUS_SUCCESS;
10050 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010051 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010052 vos_mem_copy(roamInfo.pBssDesc,
10053 pSession->pConnectBssDesc,
10054 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010055 }
10056 if(HAL_STATUS_SUCCESS(status))
10057 {
10058 pRoamInfo = &roamInfo;
10059 }
10060 else
10061 {
10062 if(roamInfo.pbFrames)
10063 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010064 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010065 }
10066 if(roamInfo.pBssDesc)
10067 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010068 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010069 }
10070 }
10071 }
10072 else
10073 {
10074 pRoamInfo = &roamInfo;
10075 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010076 if ((eCSR_ENCRYPT_TYPE_NONE ==
10077 pSession->connectedProfile.EncryptionType ))
10078 {
10079 csrRoamIssueSetContextReq( pMac, sessionId,
10080 pSession->connectedProfile.EncryptionType,
10081 pSession->pConnectBssDesc,
10082 &(pIbssPeerInd->peerAddr),
10083 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10084 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010085 }
10086 else
10087 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010088 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010089 }
10090 //send up the sec type for the new peer
10091 if (pRoamInfo)
10092 {
10093 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10094 }
10095 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10096 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10097 if(pRoamInfo)
10098 {
10099 if(roamInfo.pbFrames)
10100 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010101 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010102 }
10103 if(roamInfo.pBssDesc)
10104 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010105 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010106 }
10107 }
10108 }
10109 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010110 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10111 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10112 sessionId = csrFindIbssSession( pMac );
10113 if( CSR_SESSION_ID_INVALID != sessionId )
10114 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010115#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10116 {
10117 vos_log_ibss_pkt_type *pIbssLog;
10118
10119 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10120 if(pIbssLog)
10121 {
10122 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10123 if(pIbssPeerInd)
10124 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010125 vos_mem_copy(pIbssLog->peerMacAddr,
10126 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010127 }
10128 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10129 }
10130 }
10131#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010132 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010133 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10134 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10135 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010136 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10137 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010138 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10139 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10140 }
10141 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010142 case eWNI_SME_SETCONTEXT_RSP:
10143 {
10144 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10145 tListElem *pEntry;
10146 tSmeCmd *pCommand;
10147
10148 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10149 if ( pEntry )
10150 {
10151 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10152 if ( eSmeCommandSetKey == pCommand->command )
10153 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010154 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010155 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010156
10157 if(!pSession)
10158 {
10159 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10160 return;
10161 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010162
10163#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10164 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10165 {
10166 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010167 vos_mem_set(&setKeyEvent,
10168 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010169 if( pRsp->peerMacAddr[0] & 0x01 )
10170 {
10171 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
10172 }
10173 else
10174 {
10175 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
10176 }
10177 setKeyEvent.encryptionModeMulticast =
10178 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10179 setKeyEvent.encryptionModeUnicast =
10180 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010181 vos_mem_copy(setKeyEvent.bssid,
10182 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010183 setKeyEvent.authMode =
10184 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010185 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010186 {
10187 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10188 }
10189 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10190 }
10191#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10192 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10193 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010194 csrRoamStopWaitForKeyTimer( pMac );
10195
Jeff Johnson295189b2012-06-20 16:38:30 -070010196 //We are done with authentication, whethere succeed or not
10197 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010198 //We do it here because this linkup function is not called after association
10199 //when a key needs to be set.
10200 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10201 {
10202 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10203 }
10204 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010205 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010206 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010207 vos_mem_copy(&roamInfo.peerMac,
10208 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010209 //Make sure we install the GTK before indicating to HDD as authenticated
10210 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010211 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10212 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010213 {
Yathish9f22e662012-12-10 14:21:35 -080010214#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10215 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10216 {
10217 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010218 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010219 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
10220 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
10221 pMsg->seesionId = sessionId;
10222 status = palSendMBMessage(pMac->hHdd, pMsg );
10223 }
10224#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010225 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010226 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
10227 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE )
10228 {
10229 tpSirSmeHT40OBSSScanInd pMsg;
10230 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
10231 pMsg->messageType =
10232 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10233 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010234 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10235 vos_mem_copy(pMsg->peerMacAddr,
10236 pSession->connectedProfile.bssid,
10237 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010238 status = palSendMBMessage(pMac->hHdd,
10239 pMsg );
10240 }
10241 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010242 }
10243 else
10244 {
10245 result = eCSR_ROAM_RESULT_NONE;
10246 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010247 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010248 }
10249 else
10250 {
10251 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010252 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10253 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10254 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010255 }
10256 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10257 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010258 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10259 // can go ahead and initiate the TSPEC if any are pending
10260 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010261#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010262 //Send Adjacent AP repot to new AP.
10263 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10264 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010265 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010266 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010267#ifdef FEATURE_WLAN_ESE_UPLOAD
10268 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010269#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010270 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010271#endif
10272 pSession->isPrevApInfoValid = FALSE;
10273 }
10274#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010275 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10276 {
10277 csrReleaseCommandSetKey( pMac, pCommand );
10278 }
10279 }
10280 else
10281 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010282 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010283 }
10284 }
10285 else
10286 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010287 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010288 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010289 smeProcessPendingQueue( pMac );
10290 }
10291 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010292 case eWNI_SME_REMOVEKEY_RSP:
10293 {
10294 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10295 tListElem *pEntry;
10296 tSmeCmd *pCommand;
10297
10298 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10299 if ( pEntry )
10300 {
10301 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10302 if ( eSmeCommandRemoveKey == pCommand->command )
10303 {
10304 sessionId = pCommand->sessionId;
10305 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010306
10307 if(!pSession)
10308 {
10309 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10310 return;
10311 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010312#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10313 {
10314 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010315 vos_mem_set(&removeKeyEvent,
10316 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010317 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10318 removeKeyEvent.encryptionModeMulticast =
10319 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10320 removeKeyEvent.encryptionModeUnicast =
10321 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010322 vos_mem_copy( removeKeyEvent.bssid,
10323 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010324 removeKeyEvent.authMode =
10325 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010326 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010327 {
10328 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10329 }
10330 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10331 }
10332#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010333 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010334 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010335 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10336 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010337 result = eCSR_ROAM_RESULT_NONE;
10338 pRoamInfo = &roamInfo;
10339 }
10340 else
10341 {
10342 result = eCSR_ROAM_RESULT_FAILURE;
10343 }
10344 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10345 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10346 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10347 {
10348 csrReleaseCommandRemoveKey( pMac, pCommand );
10349 }
10350 }
10351 else
10352 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010353 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010354 }
10355 }
10356 else
10357 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010358 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010359 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010360 smeProcessPendingQueue( pMac );
10361 }
10362 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010363 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010364 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010365 csrRoamStatsRspProcessor( pMac, pSirMsg );
10366 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010367#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010368 case eWNI_SME_GET_ROAM_RSSI_RSP:
10369 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10370 csrRoamRssiRspProcessor( pMac, pSirMsg );
10371 break;
10372#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010373#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010374 case eWNI_SME_GET_TSM_STATS_RSP:
10375 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10376 csrTsmStatsRspProcessor( pMac, pSirMsg );
10377 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010378#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010379 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010380 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010381 csrUpdateRssi( pMac, pSirMsg );
10382 break;
10383
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010384 case eWNI_SME_GET_SNR_REQ:
10385 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10386 csrUpdateSnr(pMac, pSirMsg);
10387 break;
10388
Jeff Johnson295189b2012-06-20 16:38:30 -070010389#ifdef WLAN_FEATURE_VOWIFI_11R
10390 case eWNI_SME_FT_PRE_AUTH_RSP:
10391 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10392 break;
10393#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010394 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10395 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010396 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 -070010397 sessionId = pSmeMaxAssocInd->sessionId;
10398 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010399 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10400 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010401 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10402 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10403 break;
10404
10405 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010406 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010407 btampEstablishLogLinkHdlr( pSirMsg );
10408 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010409 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010410 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010411 csrRoamRssiIndHdlr( pMac, pSirMsg );
10412 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010413#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10414 case eWNI_SME_CANDIDATE_FOUND_IND:
10415 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10416 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10417 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010418 case eWNI_SME_HANDOFF_REQ:
10419 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10420 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10421 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010422#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010423
10424 default:
10425 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010426 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010427}
10428
Jeff Johnson295189b2012-06-20 16:38:30 -070010429void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10430 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10431{
10432 if(pSession)
10433 {
10434 if(pSession->bRefAssocStartCnt)
10435 {
10436 pSession->bRefAssocStartCnt--;
10437 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10438 //Need to call association_completion because there is an assoc_start pending.
10439 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10440 eCSR_ROAM_ASSOCIATION_COMPLETION,
10441 eCSR_ROAM_RESULT_FAILURE);
10442 }
10443 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10444 }
10445 else
10446 {
10447 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10448 }
10449}
10450
10451
10452eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10453{
10454 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010455 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10456 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10457 {
10458 status = csrScanRequestLostLink1( pMac, sessionId );
10459 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010460 return(status);
10461}
10462
Jeff Johnson295189b2012-06-20 16:38:30 -070010463//return a boolean to indicate whether roaming completed or continue.
10464tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10465 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10466{
10467 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10468 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10469 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10470 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010471 if(!pSession)
10472 {
10473 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10474 return eANI_BOOLEAN_FALSE;
10475 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010476 //Check whether time is up
10477 if(pSession->fCancelRoaming || fForce ||
10478 ((curTime - pSession->roamingStartTime) > roamTime) ||
10479 eCsrReassocRoaming == pSession->roamingReason ||
10480 eCsrDynamicRoaming == pSession->roamingReason)
10481 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010482 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010483 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10484 {
10485 //roaming is cancelled, tell HDD to indicate disconnect
10486 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10487 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10488 //to be eSIR_BEACON_MISSED
10489 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10490 {
10491 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10492 }
10493 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10494 {
10495 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10496 }
10497 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10498 {
10499 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10500 }
10501 else
10502 {
10503 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10504 }
10505 }
10506 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10507 pSession->roamingReason = eCsrNotRoaming;
10508 }
10509 else
10510 {
10511 pSession->roamResult = roamResult;
10512 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10513 {
10514 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10515 pSession->roamingReason = eCsrNotRoaming;
10516 }
10517 else
10518 {
10519 fCompleted = eANI_BOOLEAN_FALSE;
10520 }
10521 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010522 return(fCompleted);
10523}
10524
Jeff Johnson295189b2012-06-20 16:38:30 -070010525void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10526{
10527 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010528
10529 if(!pSession)
10530 {
10531 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10532 return;
10533 }
10534
Jeff Johnson295189b2012-06-20 16:38:30 -070010535 if(CSR_IS_ROAMING(pSession))
10536 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010537 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010538 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10539 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10540 {
10541 //No need to do anything in here because the handler takes care of it
10542 }
10543 else
10544 {
10545 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10546 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10547 //Roaming is stopped after here
10548 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10549 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010550 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010551 csrRoamStopRoamingTimer(pMac, sessionId);
10552 }
10553 }
10554}
10555
Jeff Johnson295189b2012-06-20 16:38:30 -070010556void csrRoamRoamingTimerHandler(void *pv)
10557{
10558 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10559 tpAniSirGlobal pMac = pInfo->pMac;
10560 tANI_U32 sessionId = pInfo->sessionId;
10561 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010562
10563 if(!pSession)
10564 {
10565 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10566 return;
10567 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010568
10569 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10570 {
10571 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10572 {
10573 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10574 pSession->roamingReason = eCsrNotRoaming;
10575 }
10576 }
10577}
10578
Jeff Johnson295189b2012-06-20 16:38:30 -070010579eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10580{
10581 eHalStatus status;
10582 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010583
10584 if(!pSession)
10585 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010586 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010587 return eHAL_STATUS_FAILURE;
10588 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010589
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010590 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010591 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010592 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010593
10594 return (status);
10595}
10596
Jeff Johnson295189b2012-06-20 16:38:30 -070010597eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10598{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010599 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010600}
10601
Jeff Johnson295189b2012-06-20 16:38:30 -070010602void csrRoamWaitForKeyTimeOutHandler(void *pv)
10603{
10604 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10605 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010606 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010607 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010608
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010609 smsLog(pMac, LOGW, FL("WaitForKey timer expired in state=%s sub-state=%s"),
10610 macTraceGetNeighbourRoamState(
10611 pMac->roam.neighborRoamInfo.neighborRoamState),
10612 macTraceGetcsrRoamSubState(
10613 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010614
Jeff Johnson295189b2012-06-20 16:38:30 -070010615 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10616 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010617#ifdef FEATURE_WLAN_LFR
10618 if (csrNeighborRoamIsHandoffInProgress(pMac))
10619 {
10620 /*
10621 * Enable heartbeat timer when hand-off is in progress
10622 * and Key Wait timer expired.
10623 */
10624 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010625 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010626 pMac->roam.configParam.HeartbeatThresh24);
10627 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10628 pMac->roam.configParam.HeartbeatThresh24,
10629 NULL, eANI_BOOLEAN_FALSE);
10630 }
10631#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010632 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010633
Jeff Johnson295189b2012-06-20 16:38:30 -070010634 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010635 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10636 {
10637 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10638 pInfo->sessionId);
10639 }
10640
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010641 if (pSession)
10642 {
10643 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10644 {
10645 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10646 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010647 if( (pSession->connectedProfile.AuthType ==
10648 eCSR_AUTH_TYPE_SHARED_KEY) &&
10649 ( (pSession->connectedProfile.EncryptionType ==
10650 eCSR_ENCRYPT_TYPE_WEP40) ||
10651 (pSession->connectedProfile.EncryptionType ==
10652 eCSR_ENCRYPT_TYPE_WEP104) ))
10653 {
10654 status = sme_AcquireGlobalLock( &pMac->sme );
10655 if ( HAL_STATUS_SUCCESS( status ) )
10656 {
10657 csrRoamDisconnect( pMac, pInfo->sessionId,
10658 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10659 sme_ReleaseGlobalLock( &pMac->sme );
10660 }
10661 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010662 }
10663 else
10664 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010665 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010666 __func__);
10667 }
10668 }
10669 else
10670 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010671 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010672 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010673 }
10674
10675}
10676
Jeff Johnson295189b2012-06-20 16:38:30 -070010677eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10678{
10679 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010680#ifdef FEATURE_WLAN_LFR
10681 if (csrNeighborRoamIsHandoffInProgress(pMac))
10682 {
10683 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010684 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
10685 macTraceGetNeighbourRoamState(
10686 pMac->roam.neighborRoamInfo.neighborRoamState),
10687 macTraceGetcsrRoamSubState(
10688 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
10689 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010690 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10691 }
10692#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010693 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010694 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010695
10696 return (status);
10697}
10698
Jeff Johnson295189b2012-06-20 16:38:30 -070010699eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10700{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010701 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
10702 macTraceGetNeighbourRoamState(
10703 pMac->roam.neighborRoamInfo.neighborRoamState),
10704 macTraceGetcsrRoamSubState(
10705 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010706#ifdef FEATURE_WLAN_LFR
10707 if (csrNeighborRoamIsHandoffInProgress(pMac))
10708 {
10709 /*
10710 * Enable heartbeat timer when hand-off is in progress
10711 * and Key Wait timer got stopped for some reason
10712 */
10713 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010714 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010715 pMac->roam.configParam.HeartbeatThresh24);
10716 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10717 pMac->roam.configParam.HeartbeatThresh24,
10718 NULL, eANI_BOOLEAN_FALSE);
10719 }
10720#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010721 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010722}
10723
Jeff Johnson295189b2012-06-20 16:38:30 -070010724void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10725 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10726{
10727 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10728 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010729 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10730 /* To silence the KW tool Null chaeck is added */
10731 if(!pSession)
10732 {
10733 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10734 return;
10735 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010736
10737 if(pCommand)
10738 {
10739 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010740 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010741 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010742 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10743 {
10744 //if success, force roaming completion
10745 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10746 }
10747 else
10748 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010749 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010750 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010751 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10752 }
10753}
10754
Jeff Johnson295189b2012-06-20 16:38:30 -070010755eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10756{
10757 eHalStatus status = eHAL_STATUS_SUCCESS;
10758 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10759 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10760 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10761 tCsrRoamInfo *pRoamInfo = NULL;
10762 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010763 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010764 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010765 /* To silence the KW tool Null chaeck is added */
10766 if(!pSession)
10767 {
10768 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10769 return eHAL_STATUS_FAILURE;
10770 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010771 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010772 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010773 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10774 if ( eWNI_SME_DISASSOC_IND == type )
10775 {
10776 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10777 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10778 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010779 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010780 }
10781 else if ( eWNI_SME_DEAUTH_IND == type )
10782 {
10783 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10784 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10785 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010786 /* Convert into proper reason code */
10787 pSession->joinFailStatusCode.reasonCode =
10788 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010789 0 : pDeauthIndMsg->reasonCode;
10790 /* cfg layer expects 0 as reason code if
10791 the driver dosent know the reason code
10792 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010793 }
10794 else
10795 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010796 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010797 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010798 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010799 }
10800
10801 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010802 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010803 {
10804 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10805 }
10806
10807 if ( eWNI_SME_DISASSOC_IND == type )
10808 {
10809 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10810 }
10811 else if ( eWNI_SME_DEAUTH_IND == type )
10812 {
10813 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10814 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010815 if(!HAL_STATUS_SUCCESS(status))
10816 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010817 //If fail to send confirmation to PE, not to trigger roaming
10818 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010819 }
10820
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010821 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010822 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010823 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10824 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010825 if( eWNI_SME_DISASSOC_IND == type)
10826 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010827 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010828 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10829 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010830 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10831 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010832 else if( eWNI_SME_DEAUTH_IND == type )
10833 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010834 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010835 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10836 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010837 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10838 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010839 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010840
10841 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10842 that we are roaming. But if we cannot possibly roam, or if we are unable to
10843 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010844 if(fToRoam)
10845 {
10846 //Only remove the connected BSS in infrastructure mode
10847 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10848 //Not to do anying for lostlink with WDS
10849 if( pMac->roam.configParam.nRoamingTime )
10850 {
10851 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10852 ( eWNI_SME_DEAUTH_IND == type ) ?
10853 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10854 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010855 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010856 //For IBSS, we need to give some more info to HDD
10857 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10858 {
10859 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10860 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10861 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10862 }
10863 else
10864 {
10865 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10866 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010867 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010868 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10869 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10870 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10871 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10872 }
10873 else
10874 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010875 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010876 fToRoam = eANI_BOOLEAN_FALSE;
10877 }
10878 }
10879 else
10880 {
10881 //We are told not to roam, indicate lostlink
10882 fToRoam = eANI_BOOLEAN_FALSE;
10883 }
10884 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010885 if(!fToRoam)
10886 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010887 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010888 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010889 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010890 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10891 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10892 * csrRoamCheckForLinkStatusChange API.
10893 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010894 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10895 }
10896
10897 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010898 Still enable idle scan for polling in case concurrent sessions are running */
10899 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10900 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010901 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010902 }
10903 }
10904
10905 return (status);
10906}
10907
Jeff Johnson295189b2012-06-20 16:38:30 -070010908eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10909{
10910 eHalStatus status = eHAL_STATUS_SUCCESS;
10911 tListElem *pEntry = NULL;
10912 tSmeCmd *pCommand = NULL;
10913 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010914
10915 if(!pSession)
10916 {
10917 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10918 return eHAL_STATUS_FAILURE;
10919 }
10920
Jeff Johnson295189b2012-06-20 16:38:30 -070010921 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010922 //Only remove the connected BSS in infrastructure mode
10923 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10924 if(pMac->roam.configParam.nRoamingTime)
10925 {
10926 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10927 {
10928 //before starting the lost link logic release the roam command for handoff
10929 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10930 if(pEntry)
10931 {
10932 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10933 }
10934 if(pCommand)
10935 {
10936 if (( eSmeCommandRoam == pCommand->command ) &&
10937 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10938 {
10939 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10940 {
10941 csrReleaseCommandRoam( pMac, pCommand );
10942 }
10943 }
10944 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010945 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010946 }
10947 }
10948 else
10949 {
10950 //We are told not to roam, indicate lostlink
10951 status = eHAL_STATUS_FAILURE;
10952 }
10953
10954 return (status);
10955}
Jeff Johnson295189b2012-06-20 16:38:30 -070010956void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10957{
10958 tListElem *pEntry;
10959 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010960 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10961 if ( pEntry )
10962 {
10963 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10964 if ( eSmeCommandWmStatusChange == pCommand->command )
10965 {
10966 // Nothing to process in a Lost Link completion.... It just kicks off a
10967 // roaming sequence.
10968 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10969 {
10970 csrReleaseCommandWmStatusChange( pMac, pCommand );
10971 }
10972 else
10973 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010974 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010975 }
10976
10977 }
10978 else
10979 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010980 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010981 }
10982 }
10983 else
10984 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010985 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010986 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010987 smeProcessPendingQueue( pMac );
10988}
10989
Jeff Johnson295189b2012-06-20 16:38:30 -070010990void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10991{
10992 eHalStatus status = eHAL_STATUS_FAILURE;
10993 tSirSmeRsp *pSirSmeMsg;
10994 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010995
10996 if(!pSession)
10997 {
10998 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10999 return;
11000 }
11001
Jeff Johnson295189b2012-06-20 16:38:30 -070011002 switch ( pCommand->u.wmStatusChangeCmd.Type )
11003 {
11004 case eCsrDisassociated:
11005 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
11006 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
11007 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011008 case eCsrDeauthenticated:
11009 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
11010 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
11011 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011012 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011013 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011014 break;
11015 }
11016 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
11017 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
11018 {
11019 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
11020 {
11021 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011022 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011023 }
11024 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011025 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
11026 // command here since there is nothing else to do.
11027 csrRoamWmStatusChangeComplete( pMac );
11028}
11029
Jeff Johnson295189b2012-06-20 16:38:30 -070011030//This function returns band and mode information.
11031//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
11032//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070011033static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11034 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070011035{
Jeff Johnson295189b2012-06-20 16:38:30 -070011036 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
11037 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
11038 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070011039 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070011040
Jeff Johnson295189b2012-06-20 16:38:30 -070011041 //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 -070011042 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
11043 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
11044 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
11045 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011046 {
11047 switch( pMac->roam.configParam.uCfgDot11Mode )
11048 {
11049 case eCSR_CFG_DOT11_MODE_11A:
11050 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11051 eBand = eCSR_BAND_5G;
11052 break;
11053 case eCSR_CFG_DOT11_MODE_11B:
11054 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11055 eBand = eCSR_BAND_24;
11056 break;
11057 case eCSR_CFG_DOT11_MODE_11G:
11058 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11059 eBand = eCSR_BAND_24;
11060 break;
11061 case eCSR_CFG_DOT11_MODE_11N:
11062 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011063 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11064 break;
11065#ifdef WLAN_FEATURE_11AC
11066 case eCSR_CFG_DOT11_MODE_11AC:
11067 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11068 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011069 /* If the operating channel is in 2.4 GHz band, check for
11070 * INI item to disable VHT operation in 2.4 GHz band
11071 */
11072 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11073 !pMac->roam.configParam.enableVhtFor24GHz)
11074 {
11075 /* Disable 11AC operation */
11076 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11077 }
11078 else
11079 {
11080 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11081 }
11082 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011083 }
11084 else
11085 {
11086 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11087 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11088 }
11089 break;
11090 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11091 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11092 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011093 /* If the operating channel is in 2.4 GHz band, check for
11094 * INI item to disable VHT operation in 2.4 GHz band
11095 */
11096 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11097 !pMac->roam.configParam.enableVhtFor24GHz)
11098 {
11099 /* Disable 11AC operation */
11100 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11101 }
11102 else
11103 {
11104 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11105 }
11106 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011107 }
11108 else
11109 {
11110 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11111 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11112 }
11113 break;
11114#endif
11115 case eCSR_CFG_DOT11_MODE_AUTO:
Ravi Joshia96ceb42013-05-20 18:52:39 -070011116#ifdef WLAN_FEATURE_11AC
Abhishek Singh03c39422014-09-24 10:52:30 +053011117 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11118 {
11119 /* If the operating channel is in 2.4 GHz band, check for
11120 * INI item to disable VHT operation in 2.4 GHz band
11121 */
11122 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11123 !pMac->roam.configParam.enableVhtFor24GHz)
Ravi Joshia96ceb42013-05-20 18:52:39 -070011124 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011125 /* Disable 11AC operation */
11126 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011127 }
11128 else
11129 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011130 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11131 }
11132 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11133 }
11134 else
11135 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011136 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11137 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011138 }
Abhishek Singh03c39422014-09-24 10:52:30 +053011139#else
11140 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11141 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11142#endif
Ravi Joshia96ceb42013-05-20 18:52:39 -070011143 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011144 default:
11145 // Global dot11 Mode setting is 11a/b/g.
11146 // use the channel number to determine the Mode setting.
11147 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11148 {
11149 eBand = pMac->roam.configParam.eBand;
11150 if(eCSR_BAND_24 == eBand)
11151 {
11152 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11153 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11154 }
11155 else
11156 {
11157 //prefer 5GHz
11158 eBand = eCSR_BAND_5G;
11159 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11160 }
11161 }
11162 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11163 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011164 // WiFi tests require IBSS networks to start in 11b mode
11165 // without any change to the default parameter settings
11166 // on the adapter. We use ACU to start an IBSS through
11167 // creation of a startIBSS profile. This startIBSS profile
11168 // has Auto MACProtocol and the adapter property setting
11169 // for dot11Mode is also AUTO. So in this case, let's
11170 // start the IBSS network in 11b mode instead of 11g mode.
11171 // So this is for Auto=profile->MacProtocol && Auto=Global.
11172 // dot11Mode && profile->channel is < 14, then start the IBSS
11173 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011174 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011175 // Note: we used to have this start as an 11g IBSS for best
11176 // performance... now to specify that the user will have to
11177 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011178 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11179 eBand = eCSR_BAND_24;
11180 }
11181 else
11182 {
11183 // else, it's a 5.0GHz channel. Set mode to 11a.
11184 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11185 eBand = eCSR_BAND_5G;
11186 }
11187 break;
11188 }//switch
11189 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11190 else
11191 {
11192 //dot11 mode is set, lets pick the band
11193 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11194 {
11195 // channel is Auto also.
11196 eBand = pMac->roam.configParam.eBand;
11197 if(eCSR_BAND_ALL == eBand)
11198 {
11199 //prefer 5GHz
11200 eBand = eCSR_BAND_5G;
11201 }
11202 }
11203 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11204 {
11205 eBand = eCSR_BAND_24;
11206 }
11207 else
11208 {
11209 eBand = eCSR_BAND_5G;
11210 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011211 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011212 if(pBand)
11213 {
11214 *pBand = eBand;
11215 }
11216
11217 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011218 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011219 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11220 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011221
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011222 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
11223 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 -070011224 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011225#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011226 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011227#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011228 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11229 {
11230 //We cannot do 11n here
11231 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11232 {
11233 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11234 }
11235 else
11236 {
11237 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11238 }
11239 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011240 return( cfgDot11Mode );
11241}
11242
Jeff Johnson295189b2012-06-20 16:38:30 -070011243eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11244{
11245 eHalStatus status;
11246 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011247
11248 if(!pSession)
11249 {
11250 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11251 return eHAL_STATUS_FAILURE;
11252 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011253
11254#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11255 {
11256 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011257 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11258 if(pIbssLog)
11259 {
11260 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11261 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11262 }
11263 }
11264#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011265 // Set the roaming substate to 'stop Bss request'...
11266 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11267
11268 // attempt to stop the Bss (reason code is ignored...)
11269 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011270 if(!HAL_STATUS_SUCCESS(status))
11271 {
11272 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11273 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011274 return (status);
11275}
11276
Jeff Johnson295189b2012-06-20 16:38:30 -070011277//pNumChan is a caller allocated space with the sizeof pChannels
11278eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11279{
11280
11281 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11282 (tANI_U8 *)pChannels,
11283 pNumChan));
11284}
11285
Kiran4a17ebe2013-01-31 10:43:43 -080011286tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11287{
11288 tANI_U32 cfgLength = 0;
11289 tANI_U16 cfgId = 0;
11290 tPowerdBm maxTxPwr = 0;
11291 tANI_U8 *pCountryInfo = NULL;
11292 eHalStatus status;
11293 tANI_U8 count = 0;
11294 tANI_U8 firstChannel;
11295 tANI_U8 maxChannels;
11296
11297 if (CSR_IS_CHANNEL_5GHZ(channel))
11298 {
11299 cfgId = WNI_CFG_MAX_TX_POWER_5;
11300 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11301 }
11302 else if (CSR_IS_CHANNEL_24GHZ(channel))
11303 {
11304 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11305 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11306 }
11307 else
11308 return maxTxPwr;
11309
Kiet Lam64c1b492013-07-12 13:56:44 +053011310 pCountryInfo = vos_mem_malloc(cfgLength);
11311 if ( NULL == pCountryInfo )
11312 status = eHAL_STATUS_FAILURE;
11313 else
11314 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011315 if (status != eHAL_STATUS_SUCCESS)
11316 {
11317 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011318 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011319 __FUNCTION__, status);
11320 goto error;
11321 }
11322 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11323 if (status != eHAL_STATUS_SUCCESS)
11324 {
11325 goto error;
11326 }
11327 /* Identify the channel and maxtxpower */
11328 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11329 {
11330 firstChannel = pCountryInfo[count++];
11331 maxChannels = pCountryInfo[count++];
11332 maxTxPwr = pCountryInfo[count++];
11333
11334 if ((channel >= firstChannel) &&
11335 (channel < (firstChannel + maxChannels)))
11336 {
11337 break;
11338 }
11339 }
11340
11341error:
11342 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011343 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011344
11345 return maxTxPwr;
11346}
11347
11348
Jeff Johnson295189b2012-06-20 16:38:30 -070011349tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11350{
11351 tANI_BOOLEAN fValid = FALSE;
11352 tANI_U32 idxValidChannels;
11353 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11354
11355 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11356 {
11357 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11358 {
11359 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11360 {
11361 fValid = TRUE;
11362 break;
11363 }
11364 }
11365 }
11366 pMac->roam.numValidChannels = len;
11367 return fValid;
11368}
11369
Jeff Johnson295189b2012-06-20 16:38:30 -070011370tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11371{
11372 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11373 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011374 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11375 {
11376 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11377 {
11378 fValid = eANI_BOOLEAN_TRUE;
11379 break;
11380 }
11381 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011382 return (fValid);
11383}
11384
Jeff Johnson295189b2012-06-20 16:38:30 -070011385//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011386 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011387{
Jeff Johnsone7245742012-09-05 17:12:55 -070011388 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011389 tANI_U8 centerChn;
11390 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011391
Jeff Johnson295189b2012-06-20 16:38:30 -070011392 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11393 {
11394 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11395 }
11396 else
11397 {
11398 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11399 }
11400 //Figure what the other side's CB mode
11401 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11402 {
11403 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11404 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011405 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11406 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11407 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11408 "\x00\x0f\xac\x02",4))
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011409 //In Case only WPA1 is supported and TKIP is the only one cipher suite in Unicast.
11410 ||( !pIes->RSN.present && (pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
Agrawal Ashishf187d512014-04-03 17:01:52 +053011411 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011412 "\x00\x50\xf2\x02",4))))
Agrawal Ashishf187d512014-04-03 17:01:52 +053011413
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011414 {
11415 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11416 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11417 }
11418
11419 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011420 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011421 /* This is called during INFRA STA/CLIENT and should use the merged value of
11422 * supported channel width and recommended tx width as per standard
11423 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011424 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011425 pIes->HTCaps.supportedChannelWidthSet,
11426 pIes->HTInfo.recommendedTxWidthSet,
11427 pIes->HTInfo.secondaryChannelOffset);
11428
11429 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11430 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011431 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011432 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11433 switch (eRet) {
11434 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11435 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11436 break;
11437 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11438 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11439 break;
11440 case PHY_SINGLE_CHANNEL_CENTERED:
11441 default:
11442 centerChn = primaryChn;
11443 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011444 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011445 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011446 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011447 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053011448 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011449 }
11450 }
11451 }
11452 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011453 return eRet;
11454}
Jeff Johnson295189b2012-06-20 16:38:30 -070011455tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11456{
11457 tANI_BOOLEAN fFound = FALSE;
11458 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011459 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11460 {
11461 if( pCipherList->encryptionType[idx] == encryptionType )
11462 {
11463 fFound = TRUE;
11464 break;
11465 }
11466 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011467 return fFound;
11468}
Jeff Johnson295189b2012-06-20 16:38:30 -070011469tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11470{
11471 tANI_BOOLEAN fFound = FALSE;
11472 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011473 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11474 {
11475 if( pAuthList->authType[idx] == authType )
11476 {
11477 fFound = TRUE;
11478 break;
11479 }
11480 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011481 return fFound;
11482}
Jeff Johnson295189b2012-06-20 16:38:30 -070011483tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11484{
11485 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11486 tCsrScanResultFilter *pScanFilter = NULL;
11487 eHalStatus status = eHAL_STATUS_SUCCESS;
11488
11489 if(pProfile1 && pProfile2)
11490 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011491 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11492 if ( NULL == pScanFilter )
11493 status = eHAL_STATUS_FAILURE;
11494 else
11495 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011496 if(HAL_STATUS_SUCCESS(status))
11497 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011498 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011499 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11500 if(HAL_STATUS_SUCCESS(status))
11501 {
11502 fCheck = eANI_BOOLEAN_FALSE;
11503 do
11504 {
11505 tANI_U32 i;
11506 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11507 {
11508 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11509 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11510 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11511 if ( fCheck ) break;
11512 }
11513 if(!fCheck)
11514 {
11515 break;
11516 }
11517 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11518 || pProfile2->BSSType != pProfile1->BSSType
11519 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11520 )
11521 {
11522 fCheck = eANI_BOOLEAN_FALSE;
11523 break;
11524 }
11525#ifdef WLAN_FEATURE_VOWIFI_11R
11526 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11527 {
11528 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11529 {
11530 fCheck = eANI_BOOLEAN_FALSE;
11531 break;
11532 }
11533 }
11534#endif
11535 //Match found
11536 fCheck = eANI_BOOLEAN_TRUE;
11537 }while(0);
11538 csrFreeScanFilter(pMac, pScanFilter);
11539 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011540 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011541 }
11542 }
11543
11544 return (fCheck);
11545}
11546
Jeff Johnson295189b2012-06-20 16:38:30 -070011547tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11548{
11549 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11550 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011551 do
11552 {
11553 //Only check for static WEP
11554 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11555 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11556 {
11557 fCheck = eANI_BOOLEAN_TRUE;
11558 break;
11559 }
11560 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11561 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11562 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11563 {
11564 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011565 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11566 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011567 {
11568 break;
11569 }
11570 }
11571 if( i == CSR_MAX_NUM_KEY)
11572 {
11573 fCheck = eANI_BOOLEAN_TRUE;
11574 }
11575 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011576 return (fCheck);
11577}
11578
Jeff Johnson295189b2012-06-20 16:38:30 -070011579//IBSS
11580
Jeff Johnson295189b2012-06-20 16:38:30 -070011581tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11582{
11583 tANI_U8 channel = 0;
11584 tANI_U32 idx;
11585 tANI_U32 idxValidChannels;
11586 tANI_BOOLEAN fFound = FALSE;
11587 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11588
11589 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11590 {
11591 channel = pMac->roam.configParam.AdHocChannel5G;
11592 if(!csrRoamIsChannelValid(pMac, channel))
11593 {
11594 channel = 0;
11595 }
11596 }
11597 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11598 {
11599 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11600 {
11601 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11602 {
11603 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11604 {
11605 fFound = TRUE;
11606 channel = csrStartIbssChannels50[ idx ];
11607 }
11608 }
11609 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011610 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11611 if (!fFound)
11612 {
11613 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11614 {
Girish Gowli386e76c2014-10-20 22:00:29 +053011615 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idxValidChannels ]) ) // the max channel# in 11g is 14
Jeff Johnson295189b2012-06-20 16:38:30 -070011616 {
Girish Gowli386e76c2014-10-20 22:00:29 +053011617 channel = pMac->roam.validChannelList[ idxValidChannels ];
Jeff Johnson295189b2012-06-20 16:38:30 -070011618 break;
11619 }
11620 }
11621 }
11622 }//if
11623
11624 return( channel );
11625}
11626
Jeff Johnson295189b2012-06-20 16:38:30 -070011627tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11628{
11629 tANI_U8 channel = 1;
11630 tANI_U32 idx;
11631 tANI_U32 idxValidChannels;
11632 tANI_BOOLEAN fFound = FALSE;
11633 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11634
11635 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11636 {
11637 channel = pMac->roam.configParam.AdHocChannel24;
11638 if(!csrRoamIsChannelValid(pMac, channel))
11639 {
11640 channel = 0;
11641 }
11642 }
11643
11644 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11645 {
11646 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11647 {
11648 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11649 {
11650 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11651 {
11652 fFound = TRUE;
11653 channel = csrStartIbssChannels24[ idx ];
11654 }
11655 }
11656 }
11657 }
11658
11659 return( channel );
11660}
11661
Jeff Johnson295189b2012-06-20 16:38:30 -070011662static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11663 tCsrRoamStartBssParams *pParam )
11664{
11665 eCsrCfgDot11Mode cfgDot11Mode;
11666 eCsrBand eBand;
11667 tANI_U8 channel = 0;
11668 tSirNwType nwType;
11669 tANI_U8 operationChannel = 0;
11670
11671 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11672 {
11673 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11674 }
11675
Jeff Johnson295189b2012-06-20 16:38:30 -070011676 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011677
Jeff Johnson295189b2012-06-20 16:38:30 -070011678 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11679 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11680 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11681 )
11682 {
11683 /* This should never happen */
11684 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011685 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011686 pProfile->csrPersona);
11687 VOS_ASSERT(0);
11688 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011689 switch( cfgDot11Mode )
11690 {
11691 case eCSR_CFG_DOT11_MODE_11G:
11692 nwType = eSIR_11G_NW_TYPE;
11693 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011694 case eCSR_CFG_DOT11_MODE_11B:
11695 nwType = eSIR_11B_NW_TYPE;
11696 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011697 case eCSR_CFG_DOT11_MODE_11A:
11698 nwType = eSIR_11A_NW_TYPE;
11699 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011700 default:
11701 case eCSR_CFG_DOT11_MODE_11N:
11702 case eCSR_CFG_DOT11_MODE_TAURUS:
11703 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11704 if(eCSR_BAND_24 == eBand)
11705 {
11706 nwType = eSIR_11G_NW_TYPE;
11707 }
11708 else
11709 {
11710 nwType = eSIR_11A_NW_TYPE;
11711 }
11712 break;
11713 }
11714
11715 pParam->extendedRateSet.numRates = 0;
11716
11717 switch ( nwType )
11718 {
11719 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011720 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011721 case eSIR_11A_NW_TYPE:
11722
11723 pParam->operationalRateSet.numRates = 8;
11724
11725 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11726 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11727 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11728 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11729 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11730 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11731 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11732 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11733
11734 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11735 {
11736 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11737 if( 0 == channel &&
11738 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11739 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11740 )
11741 {
11742 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11743 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11744 nwType = eSIR_11B_NW_TYPE;
11745 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11746 pParam->operationalRateSet.numRates = 4;
11747 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11748 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11749 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11750 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11751 }
11752 }
11753 else
11754 {
11755 channel = operationChannel;
11756 }
11757 break;
11758
11759 case eSIR_11B_NW_TYPE:
11760 pParam->operationalRateSet.numRates = 4;
11761 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11762 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11763 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11764 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011765 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11766 {
11767 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11768 }
11769 else
11770 {
11771 channel = operationChannel;
11772 }
11773
11774 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011775 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011776 /* For P2P Client and P2P GO, disable 11b rates */
11777 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11778 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11779 )
11780 {
11781 pParam->operationalRateSet.numRates = 8;
11782
11783 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11784 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11785 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11786 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11787 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11788 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11789 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11790 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11791 }
11792 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011793 {
11794 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011795 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11796 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11797 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11798 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11799
11800 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011801 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11802 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11803 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11804 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11805 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11806 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11807 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11808 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11809 }
11810
11811 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11812 {
11813 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11814 }
11815 else
11816 {
11817 channel = operationChannel;
11818 }
11819
11820 break;
11821 }
11822 pParam->operationChn = channel;
11823 pParam->sirNwType = nwType;
11824}
11825
Jeff Johnson295189b2012-06-20 16:38:30 -070011826static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11827 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11828{
11829
11830 if( pParam )
11831 {
11832 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011833 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011834 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011835 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011836
11837 if( pIes )
11838 {
11839 if(pIes->SuppRates.present)
11840 {
11841 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11842 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11843 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011844 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 -070011845 pIes->SuppRates.num_rates);
11846 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11847 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011848 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11849 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011850 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011851 if (pIes->ExtSuppRates.present)
11852 {
11853 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011854 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011855 {
11856 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11857 SIR_MAC_RATESET_EID_MAX, resetting to \
11858 SIR_MAC_RATESET_EID_MAX"),
11859 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011860 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011861 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011862 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011863 pIes->ExtSuppRates.rates,
11864 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11865 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011866 if( pIes->SSID.present )
11867 {
11868 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011869 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11870 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011871 }
11872 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011873 }
11874 else
11875 {
11876 pParam->ssId.length = 0;
11877 pParam->operationalRateSet.numRates = 0;
11878 }
11879 }
11880}
11881
Jeff Johnson295189b2012-06-20 16:38:30 -070011882static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11883{
11884 tANI_U8 MaxRate = 0;
11885 tANI_U32 i;
11886 tANI_U8 *pRate;
11887
11888 pRate = pSirRateSet->rate;
11889 for ( i = 0; i < pSirRateSet->numRates; i++ )
11890 {
11891 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11892 }
11893
11894 // Save the max rate in the connected state information...
11895
11896 // modify LastRates variable as well
11897
11898 return;
11899}
11900
Jeff Johnson295189b2012-06-20 16:38:30 -070011901eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11902 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11903{
11904 eHalStatus status = eHAL_STATUS_SUCCESS;
11905 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011906 // Set the roaming substate to 'Start BSS attempt'...
11907 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011908#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11909 //Need to figure out whether we need to log WDS???
11910 if( CSR_IS_IBSS( pProfile ) )
11911 {
11912 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011913 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11914 if(pIbssLog)
11915 {
11916 if(pBssDesc)
11917 {
11918 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011919 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011920 }
11921 else
11922 {
11923 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11924 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011925 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011926 if(pProfile->ChannelInfo.numOfChannels == 0)
11927 {
11928 pIbssLog->channelSetting = AUTO_PICK;
11929 }
11930 else
11931 {
11932 pIbssLog->channelSetting = SPECIFIED;
11933 }
11934 pIbssLog->operatingChannel = pParam->operationChn;
11935 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11936 }
11937 }
11938#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11939 //Put RSN information in for Starting BSS
Abhishek Singh00e46532014-11-13 05:34:55 -080011940 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11941 pParam->pRSNIE = pProfile->pRSNReqIE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011942
Jeff Johnson295189b2012-06-20 16:38:30 -070011943 pParam->privacy = pProfile->privacy;
11944 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11945 pParam->authType = pProfile->csr80211AuthType;
11946 pParam->beaconInterval = pProfile->beaconInterval;
11947 pParam->dtimPeriod = pProfile->dtimPeriod;
11948 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11949 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11950 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11951 {
11952 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11953 {
11954 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11955 }
11956 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011957 pParam->protEnabled = pProfile->protEnabled;
11958 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11959 pParam->ht_protection = pProfile->cfg_protection;
11960 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011961
Jeff Johnson295189b2012-06-20 16:38:30 -070011962 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11963 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011964 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080011965
11966#ifdef WLAN_FEATURE_11W
11967 pParam->mfpCapable = (0 != pProfile->MFPCapable);
11968 pParam->mfpRequired = (0 != pProfile->MFPRequired);
11969#endif
11970
Jeff Johnson295189b2012-06-20 16:38:30 -070011971 // When starting an IBSS, start on the channel from the Profile.
11972 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011973 return (status);
11974}
11975
Jeff Johnson295189b2012-06-20 16:38:30 -070011976static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011977 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011978{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011979 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011980 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011981 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011982
11983 if(!pSession)
11984 {
11985 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11986 return;
11987 }
11988
Jeff Johnson295189b2012-06-20 16:38:30 -070011989 if( pBssDesc )
11990 {
11991 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11992 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11993 //The following code has to be do after that.
11994 //For WDS station, use selfMac as the self BSSID
11995 if( CSR_IS_WDS_STA( pProfile ) )
11996 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011997 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11998 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011999 }
12000 }
12001 else
12002 {
12003 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070012004 //Use the first SSID
12005 if(pProfile->SSIDs.numOfSSIDs)
12006 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012007 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
12008 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012009 }
12010 //For WDS station, use selfMac as the self BSSID
12011 if( CSR_IS_WDS_STA( pProfile ) )
12012 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012013 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12014 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012015 }
12016 //Use the first BSSID
12017 else if( pProfile->BSSIDs.numOfBSSIDs )
12018 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012019 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
12020 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012021 }
12022 else
12023 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012024 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012025 }
12026 }
12027 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070012028 //Set operating channel in pProfile which will be used
12029 //in csrRoamSetBssConfigCfg() to determine channel bonding
12030 //mode and will be configured in CFG later
12031 pProfile->operationChannel = Channel;
12032
12033 if(Channel == 0)
12034 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053012035 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070012036 }
12037 else
12038 {
12039
12040 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012041 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012042 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012043 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012044 {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012045#ifdef WLAN_FEATURE_AP_HT40_24G
12046 if (CSR_IS_INFRA_AP(pProfile))
12047 cbMode = pMac->roam.configParam.channelBondingAPMode24GHz;
12048 else
12049 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12050#else
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053012051 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012052#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012053 }
12054 else
12055 {
12056 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
12057 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012058 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070012059 pBssConfig->cbMode = cbMode;
12060 pSession->bssParams.cbMode = cbMode;
12061 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012062 }
12063}
12064
Jeff Johnson295189b2012-06-20 16:38:30 -070012065static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
12066 tANI_BOOLEAN *pfSameIbss )
12067{
12068 eHalStatus status = eHAL_STATUS_SUCCESS;
12069 tANI_BOOLEAN fSameIbss = FALSE;
12070
12071 if ( csrIsConnStateIbss( pMac, sessionId ) )
12072 {
12073 // Check if any profile parameter has changed ? If any profile parameter
12074 // has changed then stop old BSS and start a new one with new parameters
12075 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
12076 {
12077 fSameIbss = TRUE;
12078 }
12079 else
12080 {
12081 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12082 }
12083 }
12084 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12085 {
12086 // Disassociate from the connected Infrastructure network...
12087 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12088 }
12089 else
12090 {
12091 tBssConfigParam *pBssConfig;
12092
Kiet Lam64c1b492013-07-12 13:56:44 +053012093 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12094 if ( NULL == pBssConfig )
12095 status = eHAL_STATUS_FAILURE;
12096 else
12097 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012098 if(HAL_STATUS_SUCCESS(status))
12099 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012100 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012101 // there is no Bss description before we start an IBSS so we need to adopt
12102 // all Bss configuration parameters from the Profile.
12103 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12104 if(HAL_STATUS_SUCCESS(status))
12105 {
12106 //save dotMode
12107 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12108 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012109 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012110 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12111 NULL, pBssConfig,
12112 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012113 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012114
12115 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012116 }//Allocate memory
12117 }
12118
12119 if(pfSameIbss)
12120 {
12121 *pfSameIbss = fSameIbss;
12122 }
12123 return( status );
12124}
12125
Jeff Johnson295189b2012-06-20 16:38:30 -070012126static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12127 tSirSmeNewBssInfo *pNewBss )
12128{
12129 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012130
12131 if(!pSession)
12132 {
12133 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12134 return;
12135 }
12136
Jeff Johnson295189b2012-06-20 16:38:30 -070012137 if( pNewBss )
12138 {
12139 // Set the operating channel.
12140 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12141 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012142 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12143 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012144 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012145 return;
12146}
12147
Jeff Johnson295189b2012-06-20 16:38:30 -070012148#ifdef FEATURE_WLAN_WAPI
12149eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12150 tANI_U32 numItems )
12151{
12152 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12153 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012154 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12155 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012156 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012157 return status;
12158 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012159 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012160 pSession = CSR_GET_SESSION( pMac, sessionId );
12161 if(numItems <= CSR_MAX_BKID_ALLOWED)
12162 {
12163 status = eHAL_STATUS_SUCCESS;
12164 //numItems may be 0 to clear the cache
12165 pSession->NumBkidCache = (tANI_U16)numItems;
12166 if(numItems && pBKIDCache)
12167 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012168 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12169 sizeof(tBkidCacheInfo) * numItems);
12170 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012171 }
12172 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012173 return (status);
12174}
Jeff Johnson295189b2012-06-20 16:38:30 -070012175eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12176 tBkidCacheInfo *pBkidCache)
12177{
12178 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12179 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012180 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12181 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012182 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012183 return status;
12184 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012185 pSession = CSR_GET_SESSION( pMac, sessionId );
12186 if(pNum && pBkidCache)
12187 {
12188 if(pSession->NumBkidCache == 0)
12189 {
12190 *pNum = 0;
12191 status = eHAL_STATUS_SUCCESS;
12192 }
12193 else if(*pNum >= pSession->NumBkidCache)
12194 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012195 if(pSession->NumBkidCache > CSR_MAX_BKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012196 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012197 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 -070012198 pSession->NumBkidCache);
Girish Gowli2c26e902014-10-20 22:18:17 +053012199 pSession->NumBkidCache = CSR_MAX_BKID_ALLOWED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012200 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012201 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12202 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012203 *pNum = pSession->NumBkidCache;
12204 status = eHAL_STATUS_SUCCESS;
12205 }
12206 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012207 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012208}
Jeff Johnson295189b2012-06-20 16:38:30 -070012209tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12210{
12211 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012212}
12213#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012214eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012215 tPmkidCacheInfo *pPMKIDCache,
12216 tANI_U32 numItems,
12217 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -070012218{
12219 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12220 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012221
12222 if (!pSession)
Jeff Johnson32d95a32012-09-10 13:15:23 -070012223 {
12224 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12225 return eHAL_STATUS_FAILURE;
12226 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012227
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012228 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012229
12230 if (numItems <= CSR_MAX_PMKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012231 {
12232#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12233 {
12234 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012235 vos_mem_set(&secEvent,
12236 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012237 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12238 secEvent.encryptionModeMulticast =
12239 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12240 secEvent.encryptionModeUnicast =
12241 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012242 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012243 secEvent.authMode =
12244 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12245 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12246 }
12247#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012248 status = eHAL_STATUS_SUCCESS;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012249 if (update_entire_cache) {
12250 pSession->NumPmkidCache = (tANI_U16)numItems;
12251 if (numItems && pPMKIDCache)
12252 {
12253 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12254 sizeof(tPmkidCacheInfo) * numItems);
12255 }
12256 } else {
12257 tANI_U32 i = 0, j = 0;
12258 tANI_U8 BSSIDMatched = 0;
12259 tPmkidCacheInfo *pmksa;
12260
12261 for (i = 0; i < numItems; i++) {
12262 pmksa = &pPMKIDCache[i];
12263 for (j = 0; j < CSR_MAX_PMKID_ALLOWED; j++) {
12264 if (vos_mem_compare(pSession->PmkidCacheInfo[j].BSSID,
12265 pmksa->BSSID, VOS_MAC_ADDR_SIZE)) {
12266 /* If a matching BSSID found, update it */
12267 BSSIDMatched = 1;
12268 vos_mem_copy(pSession->PmkidCacheInfo[j].PMKID,
12269 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12270 break;
12271 }
12272 }
12273
12274 if (!BSSIDMatched) {
12275 vos_mem_copy(
12276 pSession->PmkidCacheInfo[pSession->NumPmkidCache].BSSID,
12277 pmksa->BSSID, VOS_MAC_ADDR_SIZE);
12278 vos_mem_copy(
12279 pSession->PmkidCacheInfo[pSession->NumPmkidCache].PMKID,
12280 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12281 /* Increment the CSR local cache index */
12282 if (pSession->NumPmkidCache < (CSR_MAX_PMKID_ALLOWED - 1))
12283 pSession->NumPmkidCache++;
12284 else
12285 pSession->NumPmkidCache = 0;
12286 }
12287 BSSIDMatched = 0;
12288 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012289 }
12290 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012291 return (status);
12292}
12293
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012294eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012295 tANI_U8 *pBSSId,
12296 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012297{
12298 eHalStatus status = eHAL_STATUS_FAILURE;
12299 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12300 tANI_BOOLEAN fMatchFound = FALSE;
12301 tANI_U32 Index;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012302
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012303 if(!pSession)
12304 {
12305 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12306 return eHAL_STATUS_FAILURE;
12307 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012308
12309 /* Check if there are no entries to delete */
12310 if (0 == pSession->NumPmkidCache) {
12311 smsLog(pMac, LOG1, FL("No entries to delete/Flush"));
12312 return eHAL_STATUS_SUCCESS;
12313 }
12314
12315 if (!flush_cache) {
12316 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
12317 if (vos_mem_compare(pSession->PmkidCacheInfo[Index].BSSID,
12318 pBSSId, VOS_MAC_ADDR_SIZE)) {
12319 fMatchFound = 1;
12320
12321 /* Clear this - the matched entry */
12322 vos_mem_zero(&pSession->PmkidCacheInfo[Index],
12323 sizeof(tPmkidCacheInfo));
12324 status = eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012325 break;
12326 }
12327 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012328
12329 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
12330 smsLog(pMac, LOG1, FL("No such PMKSA entry exists "MAC_ADDRESS_STR),
12331 MAC_ADDR_ARRAY(pBSSId));
12332 return status;
12333 }
12334
12335 return status;
12336 } else {
12337 /* Flush the entire cache */
12338 vos_mem_zero(pSession->PmkidCacheInfo,
12339 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
12340 pSession->NumPmkidCache = 0;
12341 return eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012342 }
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012343}
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012344
Jeff Johnson295189b2012-06-20 16:38:30 -070012345tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12346{
12347 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12348}
12349
Jeff Johnson295189b2012-06-20 16:38:30 -070012350eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12351{
12352 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12353 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012354
12355 if(!pSession)
12356 {
12357 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12358 return eHAL_STATUS_FAILURE;
12359 }
12360
Jeff Johnson295189b2012-06-20 16:38:30 -070012361 if(pNum && pPmkidCache)
12362 {
12363 if(pSession->NumPmkidCache == 0)
12364 {
12365 *pNum = 0;
12366 status = eHAL_STATUS_SUCCESS;
12367 }
12368 else if(*pNum >= pSession->NumPmkidCache)
12369 {
12370 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12371 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012372 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 -070012373 pSession->NumPmkidCache);
12374 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12375 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012376 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
12377 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012378 *pNum = pSession->NumPmkidCache;
12379 status = eHAL_STATUS_SUCCESS;
12380 }
12381 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012382 return (status);
12383}
12384
Jeff Johnson295189b2012-06-20 16:38:30 -070012385eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12386{
12387 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12388 tANI_U32 len;
12389 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012390
12391 if(!pSession)
12392 {
12393 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12394 return eHAL_STATUS_FAILURE;
12395 }
12396
Jeff Johnson295189b2012-06-20 16:38:30 -070012397 if(pLen)
12398 {
12399 len = *pLen;
12400 *pLen = pSession->nWpaRsnReqIeLength;
12401 if(pBuf)
12402 {
12403 if(len >= pSession->nWpaRsnReqIeLength)
12404 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012405 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12406 pSession->nWpaRsnReqIeLength);
12407 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012408 }
12409 }
12410 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012411 return (status);
12412}
12413
Jeff Johnson295189b2012-06-20 16:38:30 -070012414eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12415{
12416 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12417 tANI_U32 len;
12418 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012419
12420 if(!pSession)
12421 {
12422 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12423 return eHAL_STATUS_FAILURE;
12424 }
12425
Jeff Johnson295189b2012-06-20 16:38:30 -070012426 if(pLen)
12427 {
12428 len = *pLen;
12429 *pLen = pSession->nWpaRsnRspIeLength;
12430 if(pBuf)
12431 {
12432 if(len >= pSession->nWpaRsnRspIeLength)
12433 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012434 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12435 pSession->nWpaRsnRspIeLength);
12436 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012437 }
12438 }
12439 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012440 return (status);
12441}
Jeff Johnson295189b2012-06-20 16:38:30 -070012442#ifdef FEATURE_WLAN_WAPI
12443eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12444{
12445 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12446 tANI_U32 len;
12447 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012448
12449 if(!pSession)
12450 {
12451 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12452 return eHAL_STATUS_FAILURE;
12453 }
12454
Jeff Johnson295189b2012-06-20 16:38:30 -070012455 if(pLen)
12456 {
12457 len = *pLen;
12458 *pLen = pSession->nWapiReqIeLength;
12459 if(pBuf)
12460 {
12461 if(len >= pSession->nWapiReqIeLength)
12462 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012463 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12464 pSession->nWapiReqIeLength);
12465 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012466 }
12467 }
12468 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012469 return (status);
12470}
Jeff Johnson295189b2012-06-20 16:38:30 -070012471eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12472{
12473 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12474 tANI_U32 len;
12475 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012476
12477 if(!pSession)
12478 {
12479 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12480 return eHAL_STATUS_FAILURE;
12481 }
12482
Jeff Johnson295189b2012-06-20 16:38:30 -070012483 if(pLen)
12484 {
12485 len = *pLen;
12486 *pLen = pSession->nWapiRspIeLength;
12487 if(pBuf)
12488 {
12489 if(len >= pSession->nWapiRspIeLength)
12490 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012491 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12492 pSession->nWapiRspIeLength);
12493 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012494 }
12495 }
12496 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012497 return (status);
12498}
12499#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012500eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12501{
12502 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12503 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012504
12505 if(!pSession)
12506 {
12507 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12508 return (retStatus);
12509 }
12510
Jeff Johnson295189b2012-06-20 16:38:30 -070012511 if(CSR_IS_ROAMING(pSession))
12512 {
12513 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12514 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12515 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012516 return (retStatus);
12517}
12518
Jeff Johnson295189b2012-06-20 16:38:30 -070012519//This function remove the connected BSS from te cached scan result
12520eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12521 tCsrRoamConnectedProfile *pConnProfile)
12522{
12523 eHalStatus status = eHAL_STATUS_FAILURE;
12524 tCsrScanResultFilter *pScanFilter = NULL;
12525 tListElem *pEntry;
12526 tCsrScanResult *pResult;
12527 tDot11fBeaconIEs *pIes;
12528 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012529 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12530 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12531 {
12532 do
12533 {
12534 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012535 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12536 if ( NULL == pScanFilter )
12537 status = eHAL_STATUS_FAILURE;
12538 else
12539 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012540 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012541 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12542 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12543 if ( NULL == pScanFilter->BSSIDs.bssid )
12544 status = eHAL_STATUS_FAILURE;
12545 else
12546 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012547 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012548 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12549 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012550 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12551 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12552 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012553 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12554 if ( NULL == pScanFilter->SSIDs.SSIDList )
12555 status = eHAL_STATUS_FAILURE;
12556 else
12557 status = eHAL_STATUS_SUCCESS;
12558 if (!HAL_STATUS_SUCCESS(status)) break;
12559 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12560 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012561 }
12562 pScanFilter->authType.numEntries = 1;
12563 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12564 pScanFilter->BSSType = pConnProfile->BSSType;
12565 pScanFilter->EncryptionType.numEntries = 1;
12566 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12567 pScanFilter->mcEncryptionType.numEntries = 1;
12568 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12569 //We ignore the channel for now, BSSID should be enough
12570 pScanFilter->ChannelInfo.numOfChannels = 0;
12571 //Also ignore the following fields
12572 pScanFilter->uapsd_mask = 0;
12573 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012574 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012575 pScanFilter->countryCode[0] = 0;
12576 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012577 csrLLLock(&pMac->scan.scanResultList);
12578 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12579 while( pEntry )
12580 {
12581 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12582 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12583 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12584 pScanFilter, NULL, NULL, NULL, &pIes);
12585 //Release the IEs allocated by csrMatchBSS is needed
12586 if( !pResult->Result.pvIes )
12587 {
12588 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012589 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012590 }
12591 if(fMatch)
12592 {
12593 //We found the one
12594 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12595 {
12596 //Free the memory
12597 csrFreeScanResultEntry( pMac, pResult );
12598 }
12599 break;
12600 }
12601 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12602 }//while
12603 csrLLUnlock(&pMac->scan.scanResultList);
12604 }while(0);
12605 if(pScanFilter)
12606 {
12607 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012608 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012609 }
12610 }
12611 return (status);
12612}
12613
Jeff Johnson295189b2012-06-20 16:38:30 -070012614//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012615eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12616{
12617 eHalStatus status = eHAL_STATUS_SUCCESS;
12618 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012619 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12620 {
12621 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12622 {
12623 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12624 {
12625 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012626 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012627 status = eHAL_STATUS_CSR_WRONG_STATE;
12628 break;
12629 }
12630 if( csrIsConnStateInfra( pMac, sessionId ) )
12631 {
12632 if( chnId &&
12633 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12634 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012635 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012636 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12637 status = eHAL_STATUS_CSR_WRONG_STATE;
12638 break;
12639 }
12640 }
12641 }
12642 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012643 return ( status );
12644}
12645
Jeff Johnson295189b2012-06-20 16:38:30 -070012646static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12647{
12648 eHalStatus status = eHAL_STATUS_SUCCESS;
12649 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12650 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012651
12652 if(!pSession)
12653 {
12654 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12655 return eHAL_STATUS_FAILURE;
12656 }
12657
Jeff Johnson295189b2012-06-20 16:38:30 -070012658 if ( csrIsConnStateIbss( pMac, sessionId ) )
12659 {
12660 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12661 }
12662 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12663 {
12664 // Disassociate from the connected Infrastructure network...
12665 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12666 }
12667 else
12668 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012669 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12670 //Otherwise we need to add code to handle the
12671 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12672 //send stop_bss to PE, before we can continue.
12673 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012674 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012675 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012676 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12677 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012678 // there is no Bss description before we start an WDS so we need
12679 // to adopt all Bss configuration parameters from the Profile.
12680 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12681 if(HAL_STATUS_SUCCESS(status))
12682 {
12683 //Save profile for late use
12684 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012685 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12686 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012687 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012688 vos_mem_set(pSession->pCurRoamProfile,
12689 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012690 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12691 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012692 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012693 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012694 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12695 NULL, &bssConfig,
12696 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012697 }
12698 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012699
Jeff Johnson295189b2012-06-20 16:38:30 -070012700 return( status );
12701}
12702
Jeff Johnson295189b2012-06-20 16:38:30 -070012703////////////////////Mail box
12704
Jeff Johnson295189b2012-06-20 16:38:30 -070012705//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12706//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012707static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12708 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012709 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12710{
12711 tCsrChannelSet channelGroup;
12712 tSirMacCapabilityInfo *pAP_capabilityInfo;
12713 tAniBool fTmp;
12714 tANI_BOOLEAN found = FALSE;
12715 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012716 tANI_S8 pwrLimit = 0;
12717 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012718 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12719 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12720 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12721 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012722 // 802.11h
12723 //We can do this because it is in HOST CPU order for now.
12724 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012725 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12726 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12727 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012728 fTmp = (tAniBool)pal_cpu_to_be32(1);
12729 }
12730 else
12731 fTmp = (tAniBool)0;
12732
12733 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012734 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012735 pBuf += sizeof(tAniBool);
12736 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012737 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012738 // This is required for 11k test VoWiFi Ent: Test 2.
12739 // We need the power capabilities for Assoc Req.
12740 // This macro is provided by the halPhyCfg.h. We pick our
12741 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012742 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12743 if (0 != pwrLimit)
12744 {
12745 *pBuf++ = pwrLimit;
12746 }
12747 else
12748 {
12749 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12750 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012751 size = sizeof(pMac->roam.validChannelList);
12752 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12753 {
12754 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12755 for ( i = 0; i < size; i++)
12756 {
12757 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12758
12759 }
12760 }
12761 else
12762 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012763 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012764 *pBuf++ = 0; //tSirSupChnl->numChnl
12765 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012766 //Check whether it is ok to enter UAPSD
12767#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12768 if( btcIsReadyForUapsd(pMac) )
12769#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12770 {
12771 *pBuf++ = uapsdMask;
12772 }
12773#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12774 else
12775 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012776 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012777 *pBuf++ = 0;
12778 }
12779#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12780
Jeff Johnson295189b2012-06-20 16:38:30 -070012781 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012782 vos_mem_copy(pBuf, pBssDescription,
12783 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012784 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12785}
12786
Jeff Johnson295189b2012-06-20 16:38:30 -070012787/*
12788 * The communication between HDD and LIM is thru mailbox (MB).
12789 * Both sides will access the data structure "tSirSmeJoinReq".
12790 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12791 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12792 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12793 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12794 */
12795eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012796 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012797{
12798 eHalStatus status = eHAL_STATUS_SUCCESS;
12799 tSirSmeJoinReq *pMsg;
12800 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012801 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012802 tANI_U16 msgLen, wTmp, ieLen;
12803 tSirMacRateSet OpRateSet;
12804 tSirMacRateSet ExRateSet;
12805 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12806 tANI_U32 dwTmp;
12807 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012808 tANI_U32 ucDot11Mode = 0;
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053012809 tANI_U8 txBFCsnValue = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012810
12811 if(!pSession)
12812 {
12813 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12814 return eHAL_STATUS_FAILURE;
12815 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012816 /* To satisfy klockworks */
12817 if (NULL == pBssDescription)
12818 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012819 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012820 return eHAL_STATUS_FAILURE;
12821 }
12822
Jeff Johnson295189b2012-06-20 16:38:30 -070012823 do {
12824 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12825 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053012826 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012827 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12828 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12829 // IE fields, but the length field in the bssDescription needs to be interpreted to
12830 // determine length of the IE fields.
12831 //
12832 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12833 // add in the length from the bssDescription (then add the size of the 'length' field
12834 // itself because that is NOT included in the length field).
12835 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12836 pBssDescription->length + sizeof( pBssDescription->length ) +
12837 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 +053012838 pMsg = vos_mem_malloc(msgLen);
12839 if (NULL == pMsg)
12840 status = eHAL_STATUS_FAILURE;
12841 else
12842 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012843 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012844 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012845 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012846 pMsg->length = pal_cpu_to_be16(msgLen);
12847 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012848 // sessionId
12849 *pBuf = (tANI_U8)sessionId;
12850 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012851 // transactionId
12852 *pBuf = 0;
12853 *( pBuf + 1 ) = 0;
12854 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012855 // ssId
12856 if( pIes->SSID.present && pIes->SSID.num_ssid )
12857 {
12858 // ssId len
12859 *pBuf = pIes->SSID.num_ssid;
12860 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012861 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012862 pBuf += pIes->SSID.num_ssid;
12863 }
12864 else
12865 {
12866 *pBuf = 0;
12867 pBuf++;
12868 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012869 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012870 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12871 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012872 pBuf += sizeof(tSirMacAddr);
12873 // bsstype
12874 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12875 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012876 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012877 pBuf += sizeof(tSirBssType);
12878 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012879 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12880 if (pBssDescription->channelId <= 14 &&
12881 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12882 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12883 {
12884 //Need to disable VHT operation in 2.4 GHz band
12885 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12886 }
12887 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012888 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012889 //Persona
12890 *pBuf = (tANI_U8)pProfile->csrPersona;
12891 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012892 //CBMode
12893 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12894 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012895
12896 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012897 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12898
Jeff Johnson295189b2012-06-20 16:38:30 -070012899 // uapsdPerAcBitmask
12900 *pBuf = pProfile->uapsd_mask;
12901 pBuf++;
12902
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012903
12904
Jeff Johnson295189b2012-06-20 16:38:30 -070012905 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012906 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012907 {
12908 // OperationalRateSet
12909 if (OpRateSet.numRates) {
12910 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012911 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012912 pBuf += OpRateSet.numRates;
12913 } else *pBuf++ = 0;
12914 // ExtendedRateSet
12915 if (ExRateSet.numRates) {
12916 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012917 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012918 pBuf += ExRateSet.numRates;
12919 } else *pBuf++ = 0;
12920 }
12921 else
12922 {
12923 *pBuf++ = 0;
12924 *pBuf++ = 0;
12925 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012926 // rsnIE
12927 if ( csrIsProfileWpa( pProfile ) )
12928 {
12929 // Insert the Wpa IE into the join request
12930 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12931 (tCsrWpaIe *)( wpaRsnIE ) );
12932 }
12933 else if( csrIsProfileRSN( pProfile ) )
12934 {
12935 // Insert the RSN IE into the join request
12936 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12937 (tCsrRSNIe *)( wpaRsnIE ) );
12938 }
12939#ifdef FEATURE_WLAN_WAPI
12940 else if( csrIsProfileWapi( pProfile ) )
12941 {
12942 // Insert the WAPI IE into the join request
12943 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12944 (tCsrWapiIe *)( wpaRsnIE ) );
12945 }
12946#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012947 else
12948 {
12949 ieLen = 0;
12950 }
12951 //remember the IE for future use
12952 if( ieLen )
12953 {
12954 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12955 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012956 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 -070012957 ieLen = DOT11F_IE_RSN_MAX_LEN;
12958 }
12959#ifdef FEATURE_WLAN_WAPI
12960 if( csrIsProfileWapi( pProfile ) )
12961 {
12962 //Check whether we need to allocate more memory
12963 if(ieLen > pSession->nWapiReqIeLength)
12964 {
12965 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12966 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012967 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012968 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012969 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12970 if (NULL == pSession->pWapiReqIE)
12971 status = eHAL_STATUS_FAILURE;
12972 else
12973 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012974 if(!HAL_STATUS_SUCCESS(status)) break;
12975 }
12976 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012977 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012978 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012979 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012980 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012981 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012982 pBuf += ieLen;
12983 }
12984 else//should be WPA/WPA2 otherwise
12985#endif /* FEATURE_WLAN_WAPI */
12986 {
12987 //Check whether we need to allocate more memory
12988 if(ieLen > pSession->nWpaRsnReqIeLength)
12989 {
12990 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12991 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012992 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012993 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012994 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12995 if (NULL == pSession->pWpaRsnReqIE)
12996 status = eHAL_STATUS_FAILURE;
12997 else
12998 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012999 if(!HAL_STATUS_SUCCESS(status)) break;
13000 }
13001 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013002 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013003 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013004 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013005 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013006 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013007 pBuf += ieLen;
13008 }
13009 }
13010 else
13011 {
13012 //free whatever old info
13013 pSession->nWpaRsnReqIeLength = 0;
13014 if(pSession->pWpaRsnReqIE)
13015 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013016 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013017 pSession->pWpaRsnReqIE = NULL;
13018 }
13019#ifdef FEATURE_WLAN_WAPI
13020 pSession->nWapiReqIeLength = 0;
13021 if(pSession->pWapiReqIE)
13022 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013023 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013024 pSession->pWapiReqIE = NULL;
13025 }
13026#endif /* FEATURE_WLAN_WAPI */
13027 //length is two bytes
13028 *pBuf = 0;
13029 *(pBuf + 1) = 0;
13030 pBuf += 2;
13031 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013032#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013033 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013034 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013035 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070013036 //length is two bytes
13037 *pBuf = 0;
13038 *(pBuf + 1) = 0;
13039 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013040 }
13041 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013042 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013043 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013044 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013045 {
13046 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013047#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013048 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080013049 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013050 pSession->suppCckmIeInfo.cckmIe, ieLen);
13051#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013052 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013053 pSession,
13054 pProfile,
13055 pBssDescription,
13056 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070013057 pSession->nWpaRsnReqIeLength,
13058 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013059#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013060 }
13061 else
13062 {
13063 ieLen = 0;
13064 }
13065 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
13066 if( ieLen )
13067 {
13068 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
13069 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013070 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013071 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013072 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013073 pBuf += ieLen;
13074 }
13075 else
13076 {
13077 //Indicate you have no CCKM IE
13078 //length is two bytes
13079 *pBuf = 0;
13080 *(pBuf + 1) = 0;
13081 pBuf += 2;
13082 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013083 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013084#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070013085 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053013086 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070013087 {
13088 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013089 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013090 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013091 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013092 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013093 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013094 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053013095 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013096 pBuf += ieLen;
13097 }
13098 else
13099 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053013100 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013101 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013102 *pBuf = 0;
13103 *(pBuf + 1) = 0;
13104 pBuf += 2;
13105 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013106 // addIEAssoc
13107 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
13108 {
13109 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070013110 if(ieLen > pSession->nAddIEAssocLength)
13111 {
13112 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053013113 {
13114 vos_mem_free(pSession->pAddIEAssoc);
13115 }
13116 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
13117 if (NULL == pSession->pAddIEAssoc)
13118 status = eHAL_STATUS_FAILURE;
13119 else
13120 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013121 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013122 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013123 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013124 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013125 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013126 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013127 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013128 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013129 pBuf += ieLen;
13130 }
13131 else
13132 {
13133 pSession->nAddIEAssocLength = 0;
13134 if(pSession->pAddIEAssoc)
13135 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013136 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013137 pSession->pAddIEAssoc = NULL;
13138 }
13139 *pBuf = 0;
13140 *(pBuf + 1) = 0;
13141 pBuf += 2;
13142 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013143
13144 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013145 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013146 //Unmask any AC in reassoc that is ACM-set
13147 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13148 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013149 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013150 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13151 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013152#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013153 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013154#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013155 }
13156 else
13157 {
13158 uapsd_mask = 0;
13159 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013160 }
13161 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013162
Jeff Johnson295189b2012-06-20 16:38:30 -070013163 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013164 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013165 pBuf += sizeof(tANI_U32);
13166
Jeff Johnson295189b2012-06-20 16:38:30 -070013167 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013168 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013169 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013170#ifdef WLAN_FEATURE_11W
13171 //MgmtEncryption
13172 if (pProfile->MFPEnabled)
13173 {
13174 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13175 }
13176 else
13177 {
13178 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13179 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013180 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013181 pBuf += sizeof(tANI_U32);
13182#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013183#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013184 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013185 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013186#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013187 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013188 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013189#endif
13190 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013191 {
13192 // is11Rconnection;
13193 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013194 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013195 pBuf += sizeof(tAniBool);
13196 }
13197 else
13198 {
13199 // is11Rconnection;
13200 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013201 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013202 pBuf += sizeof(tAniBool);
13203 }
13204#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013205#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013206
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013207 // isESEFeatureIniEnabled
13208 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013209 {
13210 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013211 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013212 pBuf += sizeof(tAniBool);
13213 }
13214 else
13215 {
13216 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013217 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013218 pBuf += sizeof(tAniBool);
13219 }
13220
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013221 /* A profile can not be both ESE and 11R. But an 802.11R AP
13222 * may be advertising support for ESE as well. So if we are
13223 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013224 * If we are associating explictly 11R only then we will get
13225 * 11R.
13226 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013227 if ((csrIsProfileESE(pProfile) ||
13228 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013229 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13230 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13231 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13232 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13233#ifdef WLAN_FEATURE_11W
13234 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013235 || (pProfile->negotiatedAuthType ==
13236 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013237#endif
13238 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013239 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013240 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013241 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013242 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013243 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013244 pBuf += sizeof(tAniBool);
13245 }
13246 else
13247 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013248 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013249 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013250 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013251 pBuf += sizeof(tAniBool);
13252 }
13253
13254 if (eWNI_SME_JOIN_REQ == messageType)
13255 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013256 tESETspecInfo eseTspec;
13257 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013258 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013259 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13260 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13261 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013262 }
13263 else if (eWNI_SME_REASSOC_REQ == messageType)
13264 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013265 if ((csrIsProfileESE(pProfile) ||
13266 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013267 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13268 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13269 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13270 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13271#ifdef WLAN_FEATURE_11W
13272 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013273 || (pProfile->negotiatedAuthType ==
13274 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013275#endif
13276 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013277 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013278 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013279 tESETspecInfo eseTspec;
13280 // ESE Tspec information
13281 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13282 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13283 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013284 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013285 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013286 if (eseTspec.numTspecs) {
13287 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13288 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013289 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013290 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013291 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013292 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013293 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013294 tESETspecInfo eseTspec;
13295 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013296 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013297 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13298 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13299 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013300 }
13301 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013302#endif // FEATURE_WLAN_ESE
13303#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013304 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013305 if (pMac->roam.configParam.isFastTransitionEnabled
13306#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013307 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013308#endif
13309 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013311 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013312 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013313 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013314 }
13315 else
13316 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013317 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013318 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013319 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013320 }
13321#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013322#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013323 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013324 {
13325 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013326 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013327 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013328 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013329 }
13330 else
13331 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013332 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013333 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013334 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013335 }
13336#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013337
13338 // txLdpcIniFeatureEnabled
13339 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13340 pBuf++;
13341
Kiran4a17ebe2013-01-31 10:43:43 -080013342 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13343 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13344 {
13345 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13346 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13347 csrApplyPower2Current(pMac);
13348 }
13349
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013350#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013351 // txBFIniFeatureEnabled
13352 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13353 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013354
13355 // txBFCsnValue
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013356 txBFCsnValue = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13357 if (pIes->VHTCaps.present)
13358 {
13359 txBFCsnValue = CSR_ROAM_MIN(txBFCsnValue, pIes->VHTCaps.numSoundingDim);
13360 }
13361 *pBuf = txBFCsnValue;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013362 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053013363
13364 /* Only enable MuBf if no other MuBF session exist
13365 * and FW and HOST is MuBF capable.
13366 */
13367 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
13368 {
13369 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
13370 pBuf++;
13371 }
13372 else
13373 {
13374 *pBuf = 0;
13375 pBuf++;
13376 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013377#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013378 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13379 pBuf++;
13380
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013381 // WME
13382 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13383 {
13384 //WME enabled
13385 dwTmp = pal_cpu_to_be32(TRUE);
13386 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13387 pBuf += sizeof(tAniBool);
13388 }
13389 else
13390 {
13391 dwTmp = pal_cpu_to_be32(FALSE);
13392 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13393 pBuf += sizeof(tAniBool);
13394 }
13395
13396 // QOS
13397 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13398 {
13399 //QOS enabled
13400 dwTmp = pal_cpu_to_be32(TRUE);
13401 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13402 pBuf += sizeof(tAniBool);
13403 }
13404 else
13405 {
13406 dwTmp = pal_cpu_to_be32(FALSE);
13407 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13408 pBuf += sizeof(tAniBool);
13409 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013410 //BssDesc
13411 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13412 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013413
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013414 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053013415 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
13416 pMsg = NULL;
13417
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013418 if(!HAL_STATUS_SUCCESS(status))
13419 {
13420 break;
13421 }
13422 else
13423 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013424#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013425 if (eWNI_SME_JOIN_REQ == messageType)
13426 {
13427 //Tush-QoS: notify QoS module that join happening
13428 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13429 }
13430 else if (eWNI_SME_REASSOC_REQ == messageType)
13431 {
13432 //Tush-QoS: notify QoS module that reassoc happening
13433 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13434 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013435#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013436 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013437 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053013438
13439 if (pMsg != NULL)
13440 {
13441 vos_mem_free( pMsg );
13442 }
13443
Jeff Johnson295189b2012-06-20 16:38:30 -070013444 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013445}
13446
Jeff Johnson295189b2012-06-20 16:38:30 -070013447//
13448eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13449{
13450 eHalStatus status = eHAL_STATUS_SUCCESS;
13451 tSirSmeDisassocReq *pMsg;
13452 tANI_U8 *pBuf;
13453 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013454 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13455 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13456 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013457 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013458 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13459 if (NULL == pMsg)
13460 status = eHAL_STATUS_FAILURE;
13461 else
13462 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013463 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013464 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013465 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13466 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013467 pBuf = &pMsg->sessionId;
13468 // sessionId
13469 *pBuf++ = (tANI_U8)sessionId;
13470 // transactionId
13471 *pBuf = 0;
13472 *( pBuf + 1 ) = 0;
13473 pBuf += sizeof(tANI_U16);
13474
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013475 if ( (pSession->pCurRoamProfile != NULL) &&
13476 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13477 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013478 {
13479 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013480 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13481 sizeof( tSirMacAddr ));
13482 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013483 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013484 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013485 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13486 //perMacAddr is passed as bssId for softAP
13487 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013488 pBuf = pBuf + sizeof ( tSirMacAddr );
13489 }
13490 else
13491 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013492 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013493 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13494 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013495 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013496 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13497 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013498 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013499 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013500 if(!HAL_STATUS_SUCCESS(status))
13501 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013502 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013503 break;
13504 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013505 // reasonCode
13506 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013507 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13508 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013509 if(!HAL_STATUS_SUCCESS(status))
13510 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013511 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013512 break;
13513 }
13514 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013515 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13516 Here we should not send the disassoc over the air to the AP */
13517 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13518#ifdef WLAN_FEATURE_VOWIFI_11R
13519 && csrRoamIs11rAssoc(pMac)
13520#endif
13521 )
13522 {
13523 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13524 }
13525 pBuf += sizeof(tANI_U8);
13526 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013527 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013528 return( status );
13529}
Jeff Johnson295189b2012-06-20 16:38:30 -070013530eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13531{
13532 eHalStatus status = eHAL_STATUS_SUCCESS;
13533 tSirSmeTkipCntrMeasReq *pMsg;
13534 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013535 do
13536 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013537 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13538 if ( NULL == pMsg )
13539 status = eHAL_STATUS_FAILURE;
13540 else
13541 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013542 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013543 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013544 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13545 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013546 pBuf = &pMsg->sessionId;
13547 // sessionId
13548 *pBuf++ = (tANI_U8)sessionId;
13549 // transactionId
13550 *pBuf = 0;
13551 *( pBuf + 1 ) = 0;
13552 pBuf += sizeof(tANI_U16);
13553 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013554 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13555 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013556 pBuf = pBuf + sizeof ( tSirMacAddr );
13557 // bEnable
13558 *pBuf = (tANI_BOOLEAN)bEnable;
13559 if(!HAL_STATUS_SUCCESS(status))
13560 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013561 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013562 break;
13563 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013564 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013565 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013566 return( status );
13567}
Jeff Johnson295189b2012-06-20 16:38:30 -070013568eHalStatus
13569csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13570 VOS_MODULE_ID modId, tSirMacAddr bssId,
13571 void *pUsrContext, void *pfnSapEventCallback,
13572 tANI_U8 *pAssocStasBuf )
13573{
13574 eHalStatus status = eHAL_STATUS_SUCCESS;
13575 tSirSmeGetAssocSTAsReq *pMsg;
13576 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13577 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013578 do
13579 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013580 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13581 if ( NULL == pMsg )
13582 status = eHAL_STATUS_FAILURE;
13583 else
13584 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013585 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013586 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013587 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013588 pBuf = (tANI_U8 *)&pMsg->bssId;
13589 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013590 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013591 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013592 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013593 // modId
13594 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013595 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013596 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013597 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013598 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
13599 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013600 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013601 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
13602 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013603 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080013604 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
13605 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013606 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013607 status = palSendMBMessage( pMac->hHdd, pMsg );
13608 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013609 return( status );
13610 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013611eHalStatus
13612csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13613 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13614 {
13615 eHalStatus status = eHAL_STATUS_SUCCESS;
13616 tSirSmeGetWPSPBCSessionsReq *pMsg;
13617 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080013618
Jeff Johnson295189b2012-06-20 16:38:30 -070013619 do
13620 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013621 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13622 if ( NULL == pMsg )
13623 status = eHAL_STATUS_FAILURE;
13624 else
13625 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013626 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013627 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013628 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013629 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013630 VOS_ASSERT(pBuf);
13631
Jeff Johnson295189b2012-06-20 16:38:30 -070013632 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013633 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013634 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
13635 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013636 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013637 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
13638 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013639 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013640 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013641 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013642 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013643 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013644 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013645 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013646 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013647 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 return( status );
13649}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013650
13651eHalStatus
13652csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13653{
13654 tpSirChangeBIParams pMsg;
13655 tANI_U16 len = 0;
13656 eHalStatus status = eHAL_STATUS_SUCCESS;
13657 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13658
13659 if(!pSession)
13660 {
13661 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13662 return eHAL_STATUS_FAILURE;
13663 }
13664
13665 //NO need to update the Beacon Params if update beacon parameter flag is not set
13666 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13667 return eHAL_STATUS_SUCCESS;
13668
13669 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13670
13671 /* Create the message and send to lim */
13672 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013673 pMsg = vos_mem_malloc(len);
13674 if ( NULL == pMsg )
13675 status = eHAL_STATUS_FAILURE;
13676 else
13677 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013678 if(HAL_STATUS_SUCCESS(status))
13679 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013680 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013681 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13682 pMsg->length = len;
13683
13684 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013685 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13686 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013687 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13688 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013689 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013690 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013691 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13692 status = palSendMBMessage(pMac->hHdd, pMsg);
13693 }
13694 return status;
13695}
13696
Jeff Johnson295189b2012-06-20 16:38:30 -070013697eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13698{
13699 eHalStatus status = eHAL_STATUS_SUCCESS;
13700 tSirSmeDeauthReq *pMsg;
13701 tANI_U8 *pBuf;
13702 tANI_U16 wTmp;
13703 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13704 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13705 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013706 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013707 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13708 if ( NULL == pMsg )
13709 status = eHAL_STATUS_FAILURE;
13710 else
13711 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013712 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013713 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013714 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13715 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13716 //sessionId
13717 pBuf = &pMsg->sessionId;
13718 *pBuf++ = (tANI_U8)sessionId;
13719
13720 //tansactionId
13721 *pBuf = 0;
13722 *(pBuf + 1 ) = 0;
13723 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013724 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013725 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013726 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13727 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013728 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13729 sizeof( pMsg->peerMacAddr ) );
13730 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013731 pBuf = pBuf + sizeof(tSirMacAddr);
13732 }
13733 else
13734 {
13735 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013736 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13737 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013738 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013739 }
13740 if(!HAL_STATUS_SUCCESS(status))
13741 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013742 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013743 break;
13744 }
13745 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013746 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13747 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013748 pBuf = pBuf + sizeof(tSirMacAddr);
13749 if(!HAL_STATUS_SUCCESS(status))
13750 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013751 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013752 break;
13753 }
13754 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013755 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13756 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013757 if(!HAL_STATUS_SUCCESS(status))
13758 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013759 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013760 break;
13761 }
13762 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013763 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013764 return( status );
13765}
13766
Jeff Johnson295189b2012-06-20 16:38:30 -070013767eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13768{
13769 eHalStatus status = eHAL_STATUS_SUCCESS;
13770 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013771 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013772 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13773 if ( NULL == pMsg )
13774 status = eHAL_STATUS_FAILURE;
13775 else
13776 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013777 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013778 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013779 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13780 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13781 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013782 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13783 sizeof(pMsg->peerMacAddr));
13784 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013785 if(!HAL_STATUS_SUCCESS(status))
13786 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013787 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013788 break;
13789 }
13790//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013791 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13792 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013793 if(!HAL_STATUS_SUCCESS(status))
13794 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013795 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013796 break;
13797 }
13798//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013799 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013800 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013801 return( status );
13802}
13803
Jeff Johnson295189b2012-06-20 16:38:30 -070013804eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13805{
13806 eHalStatus status = eHAL_STATUS_SUCCESS;
13807 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013808 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013809 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13810 if ( NULL == pMsg )
13811 status = eHAL_STATUS_FAILURE;
13812 else
13813 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013814 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013815 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013816 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13817 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13818 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013819 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13820 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013821 if(!HAL_STATUS_SUCCESS(status))
13822 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013823 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013824 break;
13825 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013826 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13827 sizeof(pMsg->peerMacAddr));
13828 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013829 if(!HAL_STATUS_SUCCESS(status))
13830 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013831 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013832 break;
13833 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013834 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013835 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013836 return( status );
13837}
Jeff Johnson295189b2012-06-20 16:38:30 -070013838eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13839{
13840 eHalStatus status = eHAL_STATUS_SUCCESS;
13841 tSirSmeAssocCnf *pMsg;
13842 tANI_U8 *pBuf;
13843 tSirResultCodes statusCode;
13844 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013845 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013846 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13847 if ( NULL == pMsg )
13848 status = eHAL_STATUS_FAILURE;
13849 else
13850 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013851 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013852 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013853 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13854 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013855 pBuf = (tANI_U8 *)&pMsg->statusCode;
13856 if(HAL_STATUS_SUCCESS(Halstatus))
13857 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13858 else
13859 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013860 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013861 pBuf += sizeof(tSirResultCodes);
13862 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013863 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13864 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013865 pBuf += sizeof (tSirMacAddr);
13866 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013867 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13868 sizeof(tSirMacAddr));
13869 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013870 pBuf += sizeof (tSirMacAddr);
13871 // aid
13872 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013873 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013874 pBuf += sizeof (tANI_U16);
13875 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013876 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13877 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013878 pBuf += sizeof (tSirMacAddr);
13879 // alternateChannelId
13880 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013881 status = palSendMBMessage( pMac->hHdd, pMsg );
13882 if(!HAL_STATUS_SUCCESS(status))
13883 {
13884 //pMsg is freed by palSendMBMessage
13885 break;
13886 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013887 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013888 return( status );
13889}
Jeff Johnson295189b2012-06-20 16:38:30 -070013890eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13891 tpSirSmeAssocInd pAssocInd,
13892 eHalStatus Halstatus,
13893 tANI_U8 sessionId)
13894{
13895 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013896 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13897 tANI_U8 *pBuf;
13898 tSirResultCodes statusCode;
13899 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013900 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013901 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13902 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13903 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013904
Jeff Johnson295189b2012-06-20 16:38:30 -070013905 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13906 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13907
13908 pMsg->sessionId = sessionId;
13909
13910 pBuf = (tANI_U8 *)&pMsg->statusCode;
13911 if(HAL_STATUS_SUCCESS(Halstatus))
13912 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13913 else
13914 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013915 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013916 pBuf += sizeof(tSirResultCodes);
13917 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013918 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013919 pBuf += sizeof (tSirMacAddr);
13920 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013921 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13922 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013923 pBuf += sizeof (tSirMacAddr);
13924 // StaId
13925 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013926 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013927 pBuf += sizeof (tANI_U16);
13928 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013929 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013930 pBuf += sizeof (tSirMacAddr);
13931 // alternateChannelId
13932 *pBuf = 11;
13933 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013934 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013935 //Wmm
13936 *pBuf = pAssocInd->wmmEnabledSta;
13937 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013938 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013939 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013940 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013941 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013942 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013943 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013944 //reassocReq
13945 *pBuf = pAssocInd->reassocReq;
13946 pBuf += sizeof (tANI_U8);
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053013947#ifdef WLAN_FEATURE_AP_HT40_24G
13948 // 40 MHz Intolerant
13949 *pBuf = pAssocInd->HT40MHzIntoEnabledSta;
13950 pBuf += sizeof (tANI_U8);
13951#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013952 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13953 msgQ.bodyptr = pMsg;
13954 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013955 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013956 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013957 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013958}
Jeff Johnson295189b2012-06-20 16:38:30 -070013959
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013960eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013961 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13962 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13963 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13964 tANI_U8 *pKeyRsc )
13965{
13966 tSirSmeSetContextReq *pMsg;
13967 tANI_U16 msgLen;
13968 eHalStatus status = eHAL_STATUS_FAILURE;
13969 tAniEdType tmpEdType;
13970 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013971 tANI_U8 *pBuf = NULL;
13972 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013973 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Sushant Kaushike7de85f2014-06-16 17:13:30 +053013974 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
13975 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013976 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013977 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013978 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13979 // key set. Since we only support upto one key, we always allocate memory for 1 key
13980 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13981 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13982 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13983 ( sizeof( pMsg->keyMaterial.key ) );
13984
Kiet Lam64c1b492013-07-12 13:56:44 +053013985 pMsg = vos_mem_malloc(msgLen);
13986 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13987 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13989 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013990 //sessionId
13991 pBuf = &pMsg->sessionId;
13992 *pBuf = (tANI_U8)sessionId;
13993 pBuf++;
13994 // transactionId
13995 *pBuf = 0;
13996 *(pBuf + 1) = 0;
13997 pBuf += sizeof(tANI_U16);
13998 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013999 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014000
14001 pBuf += sizeof(tSirMacAddr);
14002
14003 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014004 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14005 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014006
14007 pBuf += sizeof(tSirMacAddr);
14008
14009 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014010 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
14011 // in the tSirKeyMaterial keyMaterial; field).
14012 //
14013 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
14014 // shorter than this max size. Is LIM interpreting this ok ?
14015 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 -070014016 // set pMsg->keyMaterial.edType
14017 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014018 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070014020 // set the pMsg->keyMaterial.numKeys field
14021 *p = numKeys;
14022 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070014023 // set pSirKey->keyId = keyId;
14024 *p = keyId;
14025 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014026 // set pSirKey->unicast = (tANI_U8)fUnicast;
14027 *p = (tANI_U8)fUnicast;
14028 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070014029 // set pSirKey->keyDirection = aniKeyDirection;
14030 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053014031 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070014032 p += sizeof(tAniKeyDirection);
14033 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053014034 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070014035 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070014036 // set pSirKey->paeRole
14037 *p = paeRole; // 0 is Supplicant
14038 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014039 // set pSirKey->keyLength = keyLength;
14040 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070014041 if ( keyLength && pKey )
14042 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014043 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070014044 if(keyLength == 16)
14045 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014046 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 -070014047 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
14048 pKey[5], pKey[6], pKey[7], pKey[8],
14049 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
14050 }
14051 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014052 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014053 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014054 return( status );
14055}
14056
Jeff Johnson295189b2012-06-20 16:38:30 -070014057eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
14058 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
14059{
14060 eHalStatus status;
14061 tSirSmeStartBssReq *pMsg;
14062 tANI_U8 *pBuf = NULL;
14063 tANI_U8 *wTmpBuf = NULL;
14064 tANI_U16 msgLen, wTmp;
14065 tANI_U32 dwTmp;
14066 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070014067 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014068 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070014069 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014070
14071 if(!pSession)
14072 {
14073 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14074 return eHAL_STATUS_FAILURE;
14075 }
14076
Jeff Johnson295189b2012-06-20 16:38:30 -070014077 do {
14078 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
14079 pSession->joinFailStatusCode.reasonCode = 0;
14080 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014081 pMsg = vos_mem_malloc(msgLen);
14082 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14083 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014084 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014085 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014086 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014087 //sessionId
14088 *pBuf = (tANI_U8)sessionId;
14089 pBuf++;
14090 // transactionId
14091 *pBuf = 0;
14092 *(pBuf + 1) = 0;
14093 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014094 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053014095 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014096 pBuf += sizeof(tSirMacAddr);
14097 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014098 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014099 pBuf += sizeof(tSirMacAddr);
14100 // beaconInterval
14101 if( pBssDesc && pBssDesc->beaconInterval )
14102 {
14103 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
14104 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014105 else if(pParam->beaconInterval)
14106 {
14107 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
14108 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014109 else
14110 {
14111 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
14112 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070014113 if(csrIsconcurrentsessionValid (pMac, sessionId,
14114 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070014115 == eHAL_STATUS_SUCCESS )
14116 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080014117 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070014118 pParam->bssPersona);
14119 //Update the beacon Interval
14120 pParam->beaconInterval = wTmp;
14121 }
14122 else
14123 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014124 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014125 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053014126 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070014127 return status;
14128 }
14129
Kiet Lam64c1b492013-07-12 13:56:44 +053014130 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014131 pBuf += sizeof(tANI_U16);
14132 // dot11mode
14133 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
14134 pBuf += 1;
14135 // bssType
14136 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053014137 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014138 pBuf += sizeof(tSirBssType);
14139 // ssId
14140 if( pParam->ssId.length )
14141 {
14142 // ssId len
14143 *pBuf = pParam->ssId.length;
14144 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014145 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070014146 pBuf += pParam->ssId.length;
14147 }
14148 else
14149 {
14150 *pBuf = 0;
14151 pBuf++;
14152 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014153 // set the channel Id
14154 *pBuf = pParam->operationChn;
14155 pBuf++;
14156 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070014157 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014158 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070014159 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014160
Jeff Johnson295189b2012-06-20 16:38:30 -070014161 // Set privacy
14162 *pBuf = pParam->privacy;
14163 pBuf++;
14164
14165 //Set Uapsd
14166 *pBuf = pParam->ApUapsdEnable;
14167 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014168 //Set SSID hidden
14169 *pBuf = pParam->ssidHidden;
14170 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014171 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
14172 pBuf++;
14173
14174 //Ht protection Enable/Disable
14175 *pBuf = (tANI_U8)pParam->protEnabled;
14176 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014177 //Enable Beacons to Receive for OBSS protection Enable/Disable
14178 *pBuf = (tANI_U8)pParam->obssProtEnabled;
14179 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014180 //set cfg related to protection
14181 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053014182 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014183 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014184 // Set Auth type
14185 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014186 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014187 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014188 // Set DTIM
14189 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053014190 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014191 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014192 // Set wps_state
14193 *pBuf = pParam->wps_state;
14194 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080014195 // set isCoalesingInIBSSAllowed
14196 *pBuf = pMac->isCoalesingInIBSSAllowed;
14197 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014198 //Persona
14199 *pBuf = (tANI_U8)pParam->bssPersona;
14200 pBuf++;
14201
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080014202 //txLdpcIniFeatureEnabled
14203 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
14204 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070014205
Chet Lanctot8cecea22014-02-11 19:09:36 -080014206#ifdef WLAN_FEATURE_11W
14207 // Set MFP capable/required
14208 *pBuf = (tANI_U8)pParam->mfpCapable;
14209 pBuf++;
14210 *pBuf = (tANI_U8)pParam->mfpRequired;
14211 pBuf++;
14212#endif
14213
krunal soni4f087d22013-07-29 16:32:26 -070014214 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070014215 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
14216 {
14217 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053014218 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014219 break;
14220 }
14221 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053014222 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014223 pBuf += sizeof(tANI_U16);
14224 if( wTmp )
14225 {
14226 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053014227 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014228 pBuf += wTmp;
14229 }
14230 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014231 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014232 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014233 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
14234 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014235 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
14236 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070014237 pBuf += pParam->operationalRateSet.numRates ;
14238 *pBuf++ = pParam->extendedRateSet.numRates;
14239 if(0 != pParam->extendedRateSet.numRates)
14240 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014241 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
14242 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070014243 pBuf += pParam->extendedRateSet.numRates;
14244 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053014245#ifdef WLAN_FEATURE_AP_HT40_24G
14246 *pBuf++ = (tANI_U8)pMac->roam.configParam.apHT40_24GEnabled;
14247#endif
krunal sonie9002db2013-11-25 14:24:17 -080014248
Jeff Johnson295189b2012-06-20 16:38:30 -070014249 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
14250 pMsg->length = pal_cpu_to_be16(msgLen);
14251
14252 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014253 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014254 return( status );
14255}
14256
Jeff Johnson295189b2012-06-20 16:38:30 -070014257eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
14258{
14259 eHalStatus status = eHAL_STATUS_FAILURE;
14260 tSirSmeStopBssReq *pMsg;
14261 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14262 tANI_U8 *pBuf;
14263 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070014264
14265 if(!pSession)
14266 {
14267 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14268 return eHAL_STATUS_FAILURE;
14269 }
14270
Jeff Johnson295189b2012-06-20 16:38:30 -070014271 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014272 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14273 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14274 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014275 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14276 pBuf = &pMsg->sessionId;
14277 //sessionId
14278 *pBuf = (tANI_U8)sessionId;
14279 pBuf++;
14280 // transactionId
14281 *pBuf = 0;
14282 pBuf += sizeof(tANI_U16);
14283 //reason code
14284 *pBuf = 0;
14285 pBuf += sizeof(tSirResultCodes);
14286 // bssid
14287 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14288 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14289 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014290 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
14291 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014292 }
14293 else
14294 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014295 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14296 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014297 }
14298 pBuf += sizeof(tSirMacAddr);
14299 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
14300 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014301 status = palSendMBMessage( pMac->hHdd, pMsg );
14302#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053014303 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14304 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14305 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014306 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14307 pMsg->reasonCode = 0;
14308 // bssid
14309 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14310 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14311 {
14312 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
14313 }
14314 else
14315 {
14316 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
14317 }
Kiet Lam64c1b492013-07-12 13:56:44 +053014318 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014319 pMsg->transactionId = 0;
14320 pMsg->sessionId = (tANI_U8)sessionId;
14321 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
14322 status = palSendMBMessage( pMac->hHdd, pMsg );
14323#endif
14324 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014325 return( status );
14326}
14327
Jeff Johnson295189b2012-06-20 16:38:30 -070014328eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
14329 tCsrRoamModifyProfileFields *pModProfileFields,
14330 tANI_U32 *pRoamId, v_BOOL_t fForce)
14331{
Jeff Johnson295189b2012-06-20 16:38:30 -070014332 eHalStatus status = eHAL_STATUS_FAILURE;
14333 tANI_U32 roamId = 0;
14334 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014335 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053014336 (fForce || (!vos_mem_compare( &pModProfileFields,
14337 &pSession->connectedProfile.modifyProfileFields,
14338 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014339 {
14340 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14341 if(pRoamId)
14342 {
14343 *pRoamId = roamId;
14344 }
14345
Jeff Johnson295189b2012-06-20 16:38:30 -070014346 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
14347 eCsrSmeIssuedReassocToSameAP, roamId,
14348 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014349 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014350 return status;
14351}
Jeff Johnson295189b2012-06-20 16:38:30 -070014352static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
14353{
14354 eHalStatus status = eHAL_STATUS_SUCCESS;
14355 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053014356 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014357 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
14358 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
14359 return (status);
14360}
Jeff Johnson295189b2012-06-20 16:38:30 -070014361eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14362{
14363 eHalStatus status = eHAL_STATUS_SUCCESS;
14364 tListElem *pEntry = NULL;
14365 tSmeCmd *pCommand = NULL;
14366 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014367 do
14368 {
14369 if(pMsg == NULL)
14370 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014371 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014372 status = eHAL_STATUS_FAILURE;
14373 break;
14374 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014375 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14376 if(pEntry)
14377 {
14378 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14379 if(eSmeCommandAddStaSession == pCommand->command)
14380 {
14381 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014382 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053014383 if (pRsp->status == eSIR_FAILURE) {
14384 VOS_ASSERT( 0 );
14385 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014386 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014387 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014388 //Remove this command out of the active list
14389 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14390 {
14391 //Now put this command back on the avilable command list
14392 csrReleaseCommand(pMac, pCommand);
14393 }
14394 smeProcessPendingQueue( pMac );
14395 }
14396 else
14397 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014398 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 -070014399 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014400 status = eHAL_STATUS_FAILURE;
14401 break;
14402 }
14403 }
14404 else
14405 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014406 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 -070014407 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014408 status = eHAL_STATUS_FAILURE;
14409 break;
14410 }
14411 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014412 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014413}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014414eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14415 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014416{
14417 tSirSmeAddStaSelfReq *pMsg;
14418 tANI_U16 msgLen;
14419 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014420 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014421 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014422 pMsg = vos_mem_malloc(msgLen);
14423 if ( NULL == pMsg ) break;
14424 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014425 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14426 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014427 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014428 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014429 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14430
14431 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14432
Arif Hussain24bafea2013-11-15 15:10:03 -080014433 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14434 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014435 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014436 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014437 return( status );
14438}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014439eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14440 tANI_U32 sessionId,
14441 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014442{
14443 eHalStatus status = eHAL_STATUS_SUCCESS;
14444 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014445 pCommand = csrGetCommandBuffer(pMac);
14446 if(NULL == pCommand)
14447 {
14448 status = eHAL_STATUS_RESOURCES;
14449 }
14450 else
14451 {
14452 pCommand->command = eSmeCommandAddStaSession;
14453 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014454 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14455 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014456 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014457 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14458 if( !HAL_STATUS_SUCCESS( status ) )
14459 {
14460 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014461 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014462 }
14463 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014464 return (status);
14465}
Jeff Johnson295189b2012-06-20 16:38:30 -070014466eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14467{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014468 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014469}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014470eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14471 csrRoamCompleteCallback callback,
14472 void *pContext, tANI_U8 *pSelfMacAddr,
14473 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014474{
14475 eHalStatus status = eHAL_STATUS_SUCCESS;
14476 tANI_U32 i;
14477 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014478 *pbSessionId = CSR_SESSION_ID_INVALID;
14479 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14480 {
14481 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14482 {
14483 pSession = CSR_GET_SESSION( pMac, i );
14484 status = eHAL_STATUS_SUCCESS;
14485 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14486 pSession->sessionId = (tANI_U8)i;
14487 pSession->callback = callback;
14488 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014489 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014490 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014491 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14492 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014493 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014494 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014495 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014496 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014497 break;
14498 }
14499#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014500 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14501 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014502 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014503 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014504 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014505 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014506 break;
14507 }
14508#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014509 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014510 break;
14511 }
14512 }
14513 if( CSR_ROAM_SESSION_MAX == i )
14514 {
14515 //No session is available
14516 status = eHAL_STATUS_RESOURCES;
14517 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014518 return ( status );
14519}
Jeff Johnson295189b2012-06-20 16:38:30 -070014520eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14521{
14522 eHalStatus status = eHAL_STATUS_SUCCESS;
14523 tListElem *pEntry = NULL;
14524 tSmeCmd *pCommand = NULL;
14525 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014526 do
14527 {
14528 if(pMsg == NULL)
14529 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014530 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014531 status = eHAL_STATUS_FAILURE;
14532 break;
14533 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014534 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14535 if(pEntry)
14536 {
14537 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14538 if(eSmeCommandDelStaSession == pCommand->command)
14539 {
14540 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014541 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014542 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014543 //This session is done.
14544 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014545 if(pCommand->u.delStaSessionCmd.callback)
14546 {
14547
14548 status = sme_ReleaseGlobalLock( &pMac->sme );
14549 if ( HAL_STATUS_SUCCESS( status ) )
14550 {
14551 pCommand->u.delStaSessionCmd.callback(
14552 pCommand->u.delStaSessionCmd.pContext);
14553 status = sme_AcquireGlobalLock( &pMac->sme );
14554 if (! HAL_STATUS_SUCCESS( status ) )
14555 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014556 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014557 return status;
14558 }
14559 }
14560 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014561 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014562 }
14563 }
14564
14565 //Remove this command out of the active list
14566 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14567 {
14568 //Now put this command back on the avilable command list
14569 csrReleaseCommand(pMac, pCommand);
14570 }
14571 smeProcessPendingQueue( pMac );
14572 }
14573 else
14574 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014575 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 -070014576 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014577 status = eHAL_STATUS_FAILURE;
14578 break;
14579 }
14580 }
14581 else
14582 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014583 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 -070014584 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014585 status = eHAL_STATUS_FAILURE;
14586 break;
14587 }
14588 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014589 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014590}
Jeff Johnson295189b2012-06-20 16:38:30 -070014591eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14592{
14593 tSirSmeDelStaSelfReq *pMsg;
14594 tANI_U16 msgLen;
14595 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014596 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014597 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14598 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014599 pMsg = vos_mem_malloc(msgLen);
14600 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14601 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014602 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14603 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014604 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014605 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14606 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014607 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014608 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014609 return( status );
14610}
Jeff Johnson295189b2012-06-20 16:38:30 -070014611eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14612 tSirMacAddr sessionMacAddr,
14613 csrRoamSessionCloseCallback callback,
14614 void *pContext)
14615{
14616 eHalStatus status = eHAL_STATUS_SUCCESS;
14617 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014618 pCommand = csrGetCommandBuffer(pMac);
14619 if(NULL == pCommand)
14620 {
14621 status = eHAL_STATUS_RESOURCES;
14622 }
14623 else
14624 {
14625 pCommand->command = eSmeCommandDelStaSession;
14626 pCommand->sessionId = (tANI_U8)sessionId;
14627 pCommand->u.delStaSessionCmd.callback = callback;
14628 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014629 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14630 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014631 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14632 if( !HAL_STATUS_SUCCESS( status ) )
14633 {
14634 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014635 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014636 }
14637 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014638 return (status);
14639}
Jeff Johnson295189b2012-06-20 16:38:30 -070014640eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14641{
14642 return csrSendMBDelSelfStaReqMsg( pMac,
14643 pCommand->u.delStaSessionCmd.selfMacAddr );
14644}
Jeff Johnson295189b2012-06-20 16:38:30 -070014645static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14646{
14647 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14648 tListElem *pEntry, *pNext;
14649 tSmeCmd *pCommand;
14650 tDblLinkList localList;
14651
14652 vos_mem_zero(&localList, sizeof(tDblLinkList));
14653 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14654 {
14655 smsLog(pMac, LOGE, FL(" failed to open list"));
14656 return;
14657 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014658 csrLLLock(pList);
14659 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14660 while(pEntry != NULL)
14661 {
14662 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14663 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14664 if(pCommand->sessionId == sessionId)
14665 {
14666 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14667 {
14668 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14669 }
14670 }
14671 pEntry = pNext;
14672 }
14673 csrLLUnlock(pList);
14674
14675 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14676 {
14677 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14678 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14679 }
14680 csrLLClose(&localList);
14681}
14682
Jeff Johnson295189b2012-06-20 16:38:30 -070014683void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14684{
14685 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14686 {
14687 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014688 csrRoamStop(pMac, sessionId);
14689 csrFreeConnectBssDesc(pMac, sessionId);
14690 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14691 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014692 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014693#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014694 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014695#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014696 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14697 if (pMac->fScanOffload)
14698 {
14699 purgeSmeSessionCmdList(pMac, sessionId,
14700 &pMac->sme.smeScanCmdPendingList);
14701 }
14702
Jeff Johnson295189b2012-06-20 16:38:30 -070014703 purgeCsrSessionCmdList(pMac, sessionId);
14704 csrInitSession(pMac, sessionId);
14705 }
14706}
14707
Jeff Johnson295189b2012-06-20 16:38:30 -070014708eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14709 tANI_BOOLEAN fSync,
14710 csrRoamSessionCloseCallback callback,
14711 void *pContext )
14712{
14713 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014714 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14715 {
14716 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14717 if(fSync)
14718 {
14719 csrCleanupSession(pMac, sessionId);
14720 }
14721 else
14722 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014723 purgeSmeSessionCmdList(pMac, sessionId,
14724 &pMac->sme.smeCmdPendingList);
14725 if (pMac->fScanOffload)
14726 {
14727 purgeSmeSessionCmdList(pMac, sessionId,
14728 &pMac->sme.smeScanCmdPendingList);
14729 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014730 purgeCsrSessionCmdList(pMac, sessionId);
14731 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14732 pSession->selfMacAddr, callback, pContext);
14733 }
14734 }
14735 else
14736 {
14737 status = eHAL_STATUS_INVALID_PARAMETER;
14738 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014739 return ( status );
14740}
14741
Jeff Johnson295189b2012-06-20 16:38:30 -070014742static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14743{
14744 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014745
14746 if(!pSession)
14747 {
14748 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14749 return;
14750 }
14751
Jeff Johnson295189b2012-06-20 16:38:30 -070014752 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14753 pSession->sessionId = CSR_SESSION_ID_INVALID;
14754 pSession->callback = NULL;
14755 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014756 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14757 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14758 csrFreeRoamProfile( pMac, sessionId );
14759 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14760 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14761 csrFreeConnectBssDesc(pMac, sessionId);
14762 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014763 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14764 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014765 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014766 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014767 pSession->pWpaRsnReqIE = NULL;
14768 }
14769 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014770 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014771 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014772 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014773 pSession->pWpaRsnRspIE = NULL;
14774 }
14775 pSession->nWpaRsnRspIeLength = 0;
14776#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014777 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014778 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014779 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014780 pSession->pWapiReqIE = NULL;
14781 }
14782 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014783 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014784 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014785 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014786 pSession->pWapiRspIE = NULL;
14787 }
14788 pSession->nWapiRspIeLength = 0;
14789#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014790 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014791 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014792 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014793 }
14794 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014795
Kiet Lam64c1b492013-07-12 13:56:44 +053014796 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014797 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014798 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014799 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014800 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014801 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014802}
14803
Jeff Johnson295189b2012-06-20 16:38:30 -070014804eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14805{
14806 eHalStatus status = eHAL_STATUS_FAILURE;
14807 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014808 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14809 {
14810 if( CSR_IS_SESSION_VALID( pMac, i ) )
14811 {
14812 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14813 {
14814 //Found it
14815 status = eHAL_STATUS_SUCCESS;
14816 *pSessionId = i;
14817 break;
14818 }
14819 }
14820 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014821 return( status );
14822}
14823
Jeff Johnson295189b2012-06-20 16:38:30 -070014824//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14825//session because for IBSS, the bssid changes.
14826static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14827{
14828 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14829 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014830 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14831 {
14832 if( CSR_IS_SESSION_VALID( pMac, i ) )
14833 {
14834 pSession = CSR_GET_SESSION( pMac, i );
14835 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14836 {
14837 //Found it
14838 nRet = i;
14839 break;
14840 }
14841 }
14842 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014843 return (nRet);
14844}
Jeff Johnson295189b2012-06-20 16:38:30 -070014845static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14846{
Mukul Sharma20aa6582014-08-07 21:36:12 +053014847 VOS_STATUS status = VOS_STATUS_SUCCESS;
14848
14849 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070014850 profile info from pmac global structure */
14851
Arif Hussain24bafea2013-11-15 15:10:03 -080014852 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14853 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014854 /* Check for user misconfig of RSSI trigger threshold */
14855 pMac->roam.configParam.vccRssiThreshold =
14856 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14857 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14858 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014859 /* Check for user misconfig of UL MAC Loss trigger threshold */
14860 pMac->roam.configParam.vccUlMacLossThreshold =
14861 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14862 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014863#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14864 {
14865 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014866 /* Indicate the neighbor roal algorithm about the connect indication */
14867 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14868 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053014869
14870 // Making sure we are roaming force fully to 5GHz AP only once and
14871 // only when we connected to 2.4GH AP only during initial association.
14872 if(pMac->roam.neighborRoamInfo.cfgParams.neighborInitialForcedRoamTo5GhEnable &&
14873 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel) == SIR_BAND_2_4_GHZ)
14874 {
14875 //Making ini value to false here only so we just roam to
14876 //only once for whole driver load to unload tenure
14877 pMac->roam.neighborRoamInfo.cfgParams.neighborInitialForcedRoamTo5GhEnable = VOS_FALSE;
14878
14879 status = vos_timer_start(&pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer,
14880 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
14881 //MUKUL TODO: change the neighborResultsRefreshPeriod to some ini value reuqired ??
14882 if ( status != VOS_STATUS_SUCCESS )
14883 {
14884 smsLog(pMac, LOGE, FL("%s Neighbor forcedInitialRoamTo5GHTimer start failed with status %d"), __func__, status);
14885 }
14886 smsLog(pMac, LOGE, FL("%s: Forced roam to 5G started Timer"), __func__);
14887 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014888 }
14889#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014890}
14891
Jeff Johnson295189b2012-06-20 16:38:30 -070014892static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14893{
14894 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014895
14896 if(!pSession)
14897 {
14898 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14899 return;
14900 }
14901
Jeff Johnson295189b2012-06-20 16:38:30 -070014902 //Only to handle the case for Handover on infra link
14903 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14904 {
14905 return;
14906 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014907 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14908 csrRoamDeregStatisticsReq(pMac);
14909 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14910#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14911 /* Indicate the neighbor roal algorithm about the disconnect indication */
14912 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14913#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014914
14915 //Remove this code once SLM_Sessionization is supported
14916 //BMPS_WORKAROUND_NOT_NEEDED
14917 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014918 csrIsInfraApStarted( pMac ) &&
14919 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014920 {
14921 pMac->roam.configParam.doBMPSWorkaround = 0;
14922 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014923}
14924
Jeff Johnson295189b2012-06-20 16:38:30 -070014925void csrRoamTlStatsTimerHandler(void *pv)
14926{
14927 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14928 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014929 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14930
Jeff Johnsone7245742012-09-05 17:12:55 -070014931 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14932
Jeff Johnson295189b2012-06-20 16:38:30 -070014933#if 0
14934 // TODO Persession .???
14935 //req TL for stats
14936 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14937 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014938 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014939 }
14940 else
14941 {
14942 //save in SME
14943 csrRoamSaveStatsFromTl(pMac, tlStats);
14944 }
14945#endif
14946 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14947 {
14948 if(pMac->roam.tlStatsReqInfo.periodicity)
14949 {
14950 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014951 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14952 pMac->roam.tlStatsReqInfo.periodicity);
14953 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014954 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014955 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014956 return;
14957 }
14958 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14959 }
14960 }
14961}
Jeff Johnson295189b2012-06-20 16:38:30 -070014962void csrRoamPeStatsTimerHandler(void *pv)
14963{
14964 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14965 eHalStatus status;
14966 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14967 VOS_STATUS vosStatus;
14968 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014969 pPeStatsReqListEntry->timerRunning = FALSE;
14970 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14971 {
14972 // If we entered here, meaning the timer could not be successfully
14973 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14974
14975 /* Destroy the timer */
14976 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14977 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14978 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014979 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014980 }
14981
14982 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014983 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014984 pPeStatsReqListEntry = NULL;
14985 }
14986 else
14987 {
14988 if(!pPeStatsReqListEntry->rspPending)
14989 {
14990 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14991 pPeStatsReqListEntry->staId);
14992 if(!HAL_STATUS_SUCCESS(status))
14993 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014994 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014995 }
14996 else
14997 {
14998 pPeStatsReqListEntry->rspPending = TRUE;
14999 }
15000 }
15001
15002 //send down a req
15003 if(pPeStatsReqListEntry->periodicity &&
15004 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
15005 {
15006 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15007 if(ePMC_FULL_POWER == powerState)
15008 {
15009 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15010 {
15011 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15012 }
15013 }
15014 else
15015 {
15016 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15017 {
15018 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15019 }
15020 }
15021 //start timer
15022 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
15023 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15024 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015025 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015026 return;
15027 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015028 pPeStatsReqListEntry->timerRunning = TRUE;
15029
15030 }
15031
15032 }
15033}
Jeff Johnson295189b2012-06-20 16:38:30 -070015034void csrRoamStatsClientTimerHandler(void *pv)
15035{
15036 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070015037 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
15038 {
15039#if 0
15040 // TODO Stats fix for multisession
15041 //start the timer
15042 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
15043
15044 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15045 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015046 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015047 }
15048#endif
15049 }
15050#if 0
15051 //send up the stats report
15052 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
15053 pStaEntry->staId, pStaEntry->pContext);
15054#endif
15055}
15056
15057
15058
Jeff Johnson295189b2012-06-20 16:38:30 -070015059eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
15060{
15061 tAniGetPEStatsReq *pMsg;
15062 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053015063 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
15064 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015065 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015066 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053015067 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015068 }
15069 // need to initiate a stats request to PE
15070 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
15071 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
15072 pMsg->staId = staId;
15073 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015074 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015075 if(!HAL_STATUS_SUCCESS(status))
15076 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015077 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070015078 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015079 return status;
15080}
Jeff Johnson295189b2012-06-20 16:38:30 -070015081void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
15082{
15083 tAniGetPEStatsRsp *pSmeStatsRsp;
15084 eHalStatus status = eHAL_STATUS_FAILURE;
15085 tListElem *pEntry = NULL;
15086 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15087 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15088 tANI_U32 tempMask = 0;
15089 tANI_U8 counter = 0;
15090 tANI_U8 *pStats = NULL;
15091 tANI_U32 length = 0;
15092 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015093 v_S7_t rssi = 0, snr = 0;
15094 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015095 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015096 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
15097 if(pSmeStatsRsp->rc)
15098 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015099 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015100 goto post_update;
15101 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015102 tempMask = pSmeStatsRsp->statsMask;
15103 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070015104 /* subtract all statistics from this length, and after processing the entire
15105 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
15106 * in this 'stats' message.
15107 */
15108 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070015109 //new stats info from PE, fill up the stats strucutres in PMAC
15110 while(tempMask)
15111 {
15112 if(tempMask & 1)
15113 {
15114 switch(counter)
15115 {
15116 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015117 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015118 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
15119 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015120 pStats += sizeof(tCsrSummaryStatsInfo);
15121 length -= sizeof(tCsrSummaryStatsInfo);
15122 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015123 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015124 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015125 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
15126 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015127 pStats += sizeof(tCsrGlobalClassAStatsInfo);
15128 length -= sizeof(tCsrGlobalClassAStatsInfo);
15129 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015130 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015131 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015132 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
15133 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015134 pStats += sizeof(tCsrGlobalClassBStatsInfo);
15135 length -= sizeof(tCsrGlobalClassBStatsInfo);
15136 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015137 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015138 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015139 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
15140 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015141 pStats += sizeof(tCsrGlobalClassCStatsInfo);
15142 length -= sizeof(tCsrGlobalClassCStatsInfo);
15143 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015144 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015145 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015146 if( CSR_MAX_STA > pSmeStatsRsp->staId )
15147 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015148 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
15149 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015150 }
15151 else
15152 {
15153 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015154 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015155 VOS_ASSERT( 0 );
15156 }
15157 if(!HAL_STATUS_SUCCESS(status))
15158 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015159 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015160 }
15161 pStats += sizeof(tCsrPerStaStatsInfo);
15162 length -= sizeof(tCsrPerStaStatsInfo);
15163 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015164 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015165 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015166 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015167 }
15168 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015169 tempMask >>=1;
15170 counter++;
15171 }
15172 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
15173 if (length != 0)
15174 {
15175 pRssi = (tANI_U32*)pStats;
15176 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015177 pStats += sizeof(tANI_U32);
15178 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015179 }
15180 else
15181 {
15182 /* If riva is not sending rssi, continue to use the hack */
15183 rssi = RSSI_HACK_BMPS;
15184 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015185
Jeff Johnson295189b2012-06-20 16:38:30 -070015186 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015187
15188 if (length != 0)
15189 {
15190 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015191 pStats += sizeof(tANI_U32);
15192 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015193 }
15194 else
15195 {
15196 linkCapacity = 0;
15197 }
15198
15199 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015200
15201 if (length != 0)
15202 {
15203 pSnr = (tANI_U32*)pStats;
15204 snr = (v_S7_t)*pSnr;
15205 }
15206 else
15207 {
15208 snr = SNR_HACK_BMPS;
15209 }
15210
15211 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015212post_update:
15213 //make sure to update the pe stats req list
15214 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
15215 if(pEntry)
15216 {
15217 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
15218 pPeStaEntry->rspPending = FALSE;
15219
15220 }
15221 //check the one timer cases
15222 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
15223 if(pEntry)
15224 {
Jeff Johnson295189b2012-06-20 16:38:30 -070015225 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015226 if(pTempStaEntry->timerExpired)
15227 {
15228 //send up the stats report
15229 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15230 pTempStaEntry->staId, pTempStaEntry->pContext);
15231 //also remove from the client list
15232 csrRoamRemoveStatListEntry(pMac, pEntry);
15233 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015234 }
15235 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015236}
Jeff Johnson295189b2012-06-20 16:38:30 -070015237tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15238{
15239 tListElem *pEntry = NULL;
15240 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015241 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015242 if(!pEntry)
15243 {
15244 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015245 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015246 return NULL;
15247 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015248 while( pEntry )
15249 {
15250 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015251 if(pTempStaEntry->statsMask == statsMask)
15252 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015253 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015254 break;
15255 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015256 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15257 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015258 return pEntry;
15259}
15260
Jeff Johnson295189b2012-06-20 16:38:30 -070015261tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
15262 tANI_BOOLEAN update)
15263{
15264 tListElem *pEntry;
15265 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015266 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015267 if(!pEntry)
15268 {
15269 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015270 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015271 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015272 return NULL;
15273 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015274 while( pEntry )
15275 {
15276 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015277 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
15278 (pTempStaEntry->statsMask == pStaEntry->statsMask))
15279 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015280 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015281 if(update)
15282 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015283 pTempStaEntry->periodicity = pStaEntry->periodicity;
15284 pTempStaEntry->callback = pStaEntry->callback;
15285 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015286 }
15287 break;
15288 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015289 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15290 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015291 return pEntry;
15292}
Jeff Johnson295189b2012-06-20 16:38:30 -070015293tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15294{
15295 tListElem *pEntry;
15296 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015297 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015298 if(!pEntry)
15299 {
15300 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015301 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015302 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015303 return NULL;
15304 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015305 while( pEntry )
15306 {
15307 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015308 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
15309 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015310 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015311 break;
15312 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015313 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15314 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015315 return pEntry;
15316}
Jeff Johnson295189b2012-06-20 16:38:30 -070015317eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
15318 csrRoamLinkQualityIndCallback callback,
15319 void *pContext)
15320{
15321 pMac->roam.linkQualityIndInfo.callback = callback;
15322 pMac->roam.linkQualityIndInfo.context = pContext;
15323 if( NULL == callback )
15324 {
15325 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
15326 }
15327 else
15328 {
15329 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070015330 /* do we need to invoke the callback to notify client of initial value ?? */
15331 }
15332 return eHAL_STATUS_SUCCESS;
15333}
Jeff Johnson295189b2012-06-20 16:38:30 -070015334void csrRoamVccTrigger(tpAniSirGlobal pMac)
15335{
15336 eCsrRoamLinkQualityInd newVccLinkQuality;
15337 tANI_U32 ul_mac_loss = 0;
15338 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015339 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15340 /*-------------------------------------------------------------------------
15341 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015342 Check for a change in link quality and notify client if necessary
15343 -------------------------------------------------------------------------*/
15344 ul_mac_loss_trigger_threshold =
15345 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015346 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015347 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015348 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070015349 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
15350 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015351 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015352 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15353 }
15354 else
15355 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015356 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070015357 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15358 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015359 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
15360 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070015361 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15362 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015363 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015364 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15365 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015366 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015367 newVccLinkQuality );
15368
15369 /* we now invoke the callback once to notify client of initial value */
15370 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15371 pMac->roam.linkQualityIndInfo.context );
15372 //event: EVENT_WLAN_VCC
15373 }
15374 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015375 pMac->roam.vccLinkQuality = newVccLinkQuality;
15376
Jeff Johnson295189b2012-06-20 16:38:30 -070015377}
Jeff Johnson295189b2012-06-20 16:38:30 -070015378VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
15379 v_U8_t rssiNotification,
15380 void * context)
15381{
15382 tpAniSirGlobal pMac = PMAC_STRUCT( context );
15383 eCsrRoamLinkQualityInd newVccLinkQuality;
15384 // TODO : Session info unavailable
15385 tANI_U32 sessionId = 0;
15386 VOS_STATUS status = VOS_STATUS_SUCCESS;
15387 /*-------------------------------------------------------------------------
15388 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015389 Check for a change in link quality and notify client if necessary
15390 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015391 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015392 pMac->roam.configParam.vccRssiThreshold);
15393 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15394 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015395 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015396 return VOS_STATUS_SUCCESS;
15397 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015398 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15399 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015400 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015401 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15402 }
15403 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15404 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015405 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015406 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15407 }
15408 else
15409 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015410 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015411 //Set to this so the code below won't do anything
15412 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015413 VOS_ASSERT(0);
15414 }
15415
Jeff Johnson295189b2012-06-20 16:38:30 -070015416 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15417 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015418 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015419 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15420 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015421 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015422 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070015423 /* we now invoke the callback once to notify client of initial value */
15424 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15425 pMac->roam.linkQualityIndInfo.context );
15426 //event: EVENT_WLAN_VCC
15427 }
15428 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015429 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015430 return status;
15431}
Jeff Johnson295189b2012-06-20 16:38:30 -070015432tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
15433 tDblLinkList *pStaList,
15434 tCsrStatsClientReqInfo *pStaEntry)
15435{
15436 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015437 //if same entity requested for same set of stats with different periodicity &
15438 // callback update it
15439 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
15440 {
15441
Kiet Lam64c1b492013-07-12 13:56:44 +053015442 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15443 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015444 {
15445 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015446 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015447 return NULL;
15448 }
15449
Jeff Johnson295189b2012-06-20 16:38:30 -070015450 pNewStaEntry->callback = pStaEntry->callback;
15451 pNewStaEntry->pContext = pStaEntry->pContext;
15452 pNewStaEntry->periodicity = pStaEntry->periodicity;
15453 pNewStaEntry->requesterId = pStaEntry->requesterId;
15454 pNewStaEntry->statsMask = pStaEntry->statsMask;
15455 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15456 pNewStaEntry->pMac = pStaEntry->pMac;
15457 pNewStaEntry->staId = pStaEntry->staId;
15458 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15459
15460 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15461 }
15462 return pNewStaEntry;
15463}
15464
Jeff Johnson295189b2012-06-20 16:38:30 -070015465tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15466 tDblLinkList *pStaList,
15467 tCsrPeStatsReqInfo *pStaEntry)
15468{
15469 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015470 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15471 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015472 {
15473 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015474 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015475 return NULL;
15476 }
15477
Jeff Johnson295189b2012-06-20 16:38:30 -070015478 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15479 pNewStaEntry->numClient = pStaEntry->numClient;
15480 pNewStaEntry->periodicity = pStaEntry->periodicity;
15481 pNewStaEntry->statsMask = pStaEntry->statsMask;
15482 pNewStaEntry->pMac = pStaEntry->pMac;
15483 pNewStaEntry->staId = pStaEntry->staId;
15484 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15485 pNewStaEntry->rspPending = pStaEntry->rspPending;
15486
15487 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015488 return pNewStaEntry;
15489}
Jeff Johnson295189b2012-06-20 16:38:30 -070015490eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15491 tCsrRssiCallback callback,
15492 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15493{
15494 eHalStatus status = eHAL_STATUS_SUCCESS;
15495 vos_msg_t msg;
15496 tANI_U32 sessionId;
15497
15498 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015499 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015500 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15501 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015502 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015503 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015504 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015505 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015506 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15507
15508 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15509 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15510 pMsg->sessionId = sessionId;
15511 pMsg->staId = staId;
15512 pMsg->rssiCallback = callback;
15513 pMsg->pDevContext = pContext;
15514 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015515 msg.type = eWNI_SME_GET_RSSI_REQ;
15516 msg.bodyptr = pMsg;
15517 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015518 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15519 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015520 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015521 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015522 status = eHAL_STATUS_FAILURE;
15523 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015524 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015525 return status;
15526}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015527
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015528eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15529 tCsrSnrCallback callback,
15530 tANI_U8 staId, tCsrBssid bssId,
15531 void *pContext)
15532{
15533 eHalStatus status = eHAL_STATUS_SUCCESS;
15534 vos_msg_t msg;
15535 tANI_U32 sessionId;
15536
15537 tAniGetSnrReq *pMsg;
15538
15539 smsLog(pMac, LOG2, FL("called"));
15540
15541 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15542 if (NULL == pMsg )
15543 {
15544 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15545 return status;
15546 }
15547
15548 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15549
15550 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15551 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15552 pMsg->sessionId = sessionId;
15553 pMsg->staId = staId;
15554 pMsg->snrCallback = callback;
15555 pMsg->pDevContext = pContext;
15556 msg.type = eWNI_SME_GET_SNR_REQ;
15557 msg.bodyptr = pMsg;
15558 msg.reserved = 0;
15559
15560 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15561 {
15562 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15563 vos_mem_free((v_VOID_t *)pMsg);
15564 status = eHAL_STATUS_FAILURE;
15565 }
15566
15567 smsLog(pMac, LOG2, FL("returned"));
15568 return status;
15569}
15570
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015571#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015572eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15573 tCsrRssiCallback callback,
15574 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15575{
15576 eHalStatus status = eHAL_STATUS_SUCCESS;
15577 tAniGetRssiReq *pMsg;
15578
Kiet Lam64c1b492013-07-12 13:56:44 +053015579 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15580 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015581 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015582 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015583 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015584 }
15585 // need to initiate a stats request to PE
15586 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15587 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15588 pMsg->staId = staId;
15589 pMsg->rssiCallback = callback;
15590 pMsg->pDevContext = pContext;
15591 pMsg->pVosContext = pVosContext;
15592 status = palSendMBMessage(pMac->hHdd, pMsg );
15593 if(!HAL_STATUS_SUCCESS(status))
15594 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015595 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015596 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015597 status = eHAL_STATUS_FAILURE;
15598 }
15599 return status;
15600}
15601#endif
15602
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015603
15604
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015605#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015606eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15607 tCsrTsmStatsCallback callback,
15608 tANI_U8 staId,
15609 tCsrBssid bssId,
15610 void *pContext,
15611 void* pVosContext,
15612 tANI_U8 tid)
15613{
15614 eHalStatus status = eHAL_STATUS_SUCCESS;
15615 tAniGetTsmStatsReq *pMsg = NULL;
15616
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015617 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15618 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015619 {
15620 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015621 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015622 }
15623 // need to initiate a stats request to PE
15624 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15625 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15626 pMsg->staId = staId;
15627 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015628 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015629 pMsg->tsmStatsCallback = callback;
15630 pMsg->pDevContext = pContext;
15631 pMsg->pVosContext = pVosContext;
15632 status = palSendMBMessage(pMac->hHdd, pMsg );
15633 if(!HAL_STATUS_SUCCESS(status))
15634 {
15635 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15636 //pMsg is freed by palSendMBMessage
15637 status = eHAL_STATUS_FAILURE;
15638 }
15639 return status;
15640}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015641#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015642
15643
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015644/* ---------------------------------------------------------------------------
15645 \fn csrGetTLSTAState
15646 \helper function to get teh TL STA State whenever the function is called.
15647
15648 \param staId - The staID to be passed to the TL
15649 to get the relevant TL STA State
15650 \return the state as tANI_U16
15651 ---------------------------------------------------------------------------*/
15652tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15653{
15654 WLANTL_STAStateType tlSTAState;
15655 tlSTAState = WLANTL_STA_INIT;
15656
15657 //request TL for STA State
15658 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15659 {
15660 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15661 }
15662
15663 return tlSTAState;
15664}
15665
Jeff Johnson295189b2012-06-20 16:38:30 -070015666eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15667 tANI_U32 statsMask,
15668 tCsrStatsCallback callback,
15669 tANI_U32 periodicity, tANI_BOOLEAN cache,
15670 tANI_U8 staId, void *pContext)
15671{
15672 tCsrStatsClientReqInfo staEntry;
15673 tCsrStatsClientReqInfo *pStaEntry = NULL;
15674 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15675 tListElem *pEntry = NULL;
15676 tANI_BOOLEAN found = FALSE;
15677 eHalStatus status = eHAL_STATUS_SUCCESS;
15678 tANI_BOOLEAN insertInClientList = FALSE;
15679 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015680 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015681
15682 if( csrIsAllSessionDisconnected(pMac) )
15683 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015684 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015685 return eHAL_STATUS_FAILURE;
15686 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015687
15688 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15689 {
15690 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15691 return eHAL_STATUS_FAILURE;
15692 }
15693
Jeff Johnson295189b2012-06-20 16:38:30 -070015694 if((!statsMask) && (!callback))
15695 {
15696 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015697 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015698 return eHAL_STATUS_FAILURE;
15699 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015700 //for the search list method for deregister
15701 staEntry.requesterId = requesterId;
15702 staEntry.statsMask = statsMask;
15703 //requester wants to deregister or just an error
15704 if((statsMask) && (!callback))
15705 {
15706 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15707 if(!pEntry)
15708 {
15709 //msg
15710 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015711 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015712 return eHAL_STATUS_FAILURE;
15713 }
15714 else
15715 {
15716 //clean up & return
15717 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015718 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015719 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015720 pStaEntry->pPeStaEntry->numClient--;
15721 //check if we need to delete the entry from peStatsReqList too
15722 if(!pStaEntry->pPeStaEntry->numClient)
15723 {
15724 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15725 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015726 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015727
Jeff Johnson295189b2012-06-20 16:38:30 -070015728 //check if we need to stop the tl stats timer too
15729 pMac->roam.tlStatsReqInfo.numClient--;
15730 if(!pMac->roam.tlStatsReqInfo.numClient)
15731 {
15732 if(pMac->roam.tlStatsReqInfo.timerRunning)
15733 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015734 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15735 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015736 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015737 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015738 return eHAL_STATUS_FAILURE;
15739 }
15740 }
15741 pMac->roam.tlStatsReqInfo.periodicity = 0;
15742 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15743 }
15744 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015745 // Destroy the vos timer...
15746 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15747 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15748 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015749 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015750 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015751 csrRoamRemoveStatListEntry(pMac, pEntry);
15752 pStaEntry = NULL;
15753 return eHAL_STATUS_SUCCESS;
15754 }
15755 }
15756
15757 if(cache && !periodicity)
15758 {
15759 //return the cached stats
15760 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15761 }
15762 else
15763 {
15764 //add the request in the client req list
15765 staEntry.callback = callback;
15766 staEntry.pContext = pContext;
15767 staEntry.periodicity = periodicity;
15768 staEntry.pPeStaEntry = NULL;
15769 staEntry.staId = staId;
15770 staEntry.pMac = pMac;
15771 staEntry.timerExpired = FALSE;
15772
15773
Jeff Johnson295189b2012-06-20 16:38:30 -070015774 //if periodic report requested with non cached result from PE/TL
15775 if(periodicity)
15776 {
15777
15778 //if looking for stats from PE
15779 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15780 {
15781
15782 //check if same request made already & waiting for rsp
15783 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15784 periodicity, &found, staId);
15785 if(!pPeStaEntry)
15786 {
15787 //bail out, maxed out on number of req for PE
15788 return eHAL_STATUS_FAILURE;
15789 }
15790 else
15791 {
15792 staEntry.pPeStaEntry = pPeStaEntry;
15793 }
15794
15795 }
15796 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15797 if(statsMask & (1 << eCsrGlobalClassDStats))
15798 {
15799 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15800 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015801 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015802 }
15803 else
15804 {
15805
15806 //update periodicity
15807 if(pMac->roam.tlStatsReqInfo.periodicity)
15808 {
15809 pMac->roam.tlStatsReqInfo.periodicity =
15810 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15811 }
15812 else
15813 {
15814 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15815 }
15816 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15817 {
15818 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15819 }
15820
15821 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15822 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015823 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015824 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015825 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015826 //req TL for class D stats
15827 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15828 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015829 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015830 }
15831 else
15832 {
15833 //save in SME
15834 csrRoamSaveStatsFromTl(pMac, pTlStats);
15835 }
15836 vos_mem_free(pTlStats);
15837 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015838 }
15839 else
15840 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015841 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015842 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015843
Jeff Johnson295189b2012-06-20 16:38:30 -070015844 if(pMac->roam.tlStatsReqInfo.periodicity)
15845 {
15846 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015847 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15848 pMac->roam.tlStatsReqInfo.periodicity);
15849 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015850 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015851 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015852 return eHAL_STATUS_FAILURE;
15853 }
15854 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15855 }
15856 }
15857 }
15858 pMac->roam.tlStatsReqInfo.numClient++;
15859 }
15860
15861 insertInClientList = TRUE;
15862 }
15863 //if one time report requested with non cached result from PE/TL
15864 else if(!cache && !periodicity)
15865 {
15866 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15867 {
15868 //send down a req
15869 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15870 if(!HAL_STATUS_SUCCESS(status))
15871 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015872 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015873 }
15874 //so that when the stats rsp comes back from PE we respond to upper layer
15875 //right away
15876 staEntry.timerExpired = TRUE;
15877 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015878 }
15879 if(statsMask & (1 << eCsrGlobalClassDStats))
15880 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015881 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015882 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015883 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015884 //req TL for class D stats
15885 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15886 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015887 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015888 }
15889 else
15890 {
15891 //save in SME
15892 csrRoamSaveStatsFromTl(pMac, pTlStats);
15893 }
15894 vos_mem_free(pTlStats);
15895 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015896 }
15897 else
15898 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015899 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015900 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015901
15902 }
15903 //if looking for stats from TL only
15904 if(!insertInClientList)
15905 {
15906 //return the stats
15907 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15908 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015909 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015910 if(insertInClientList)
15911 {
15912 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15913 if(!pStaEntry)
15914 {
15915 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015916 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015917 return eHAL_STATUS_FAILURE;
15918 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015919 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015920 //Init & start timer if needed
15921 if(periodicity)
15922 {
15923 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15924 csrRoamStatsClientTimerHandler, pStaEntry );
15925 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15926 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015927 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015928 return eHAL_STATUS_FAILURE;
15929 }
15930 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15931 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15932 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015933 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015934 return eHAL_STATUS_FAILURE;
15935 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015936 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015937 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015938 }
15939 return eHAL_STATUS_SUCCESS;
15940}
15941
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015942#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15943
15944static tSirRetStatus
15945csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15946 tANI_U8* pBD,
15947 tANI_U8 type,
15948 tANI_U8 subType,
15949 tSirMacAddr peerAddr,
15950 tSirMacAddr selfMacAddr)
15951{
15952 tSirRetStatus statusCode = eSIR_SUCCESS;
15953 tpSirMacMgmtHdr pMacHdr;
15954
15955 /* Prepare MAC management header */
15956 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15957
15958 /* Prepare FC */
15959 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15960 pMacHdr->fc.type = type;
15961 pMacHdr->fc.subType = subType;
15962
15963 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015964 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15965 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015966
15967 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15968
15969 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015970 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15971 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015972 return statusCode;
15973} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15974
15975static tSirRetStatus
15976csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15977 tANI_U8 nChannelNum,
15978 tANI_U32 dot11mode,
15979 tSirMacAddr selfMacAddr,
15980 tANI_U8 *pFrame,
15981 tANI_U16 *pusLen)
15982{
15983 tDot11fProbeRequest pr;
15984 tANI_U32 nStatus, nBytes, nPayload;
15985 tSirRetStatus nSirStatus;
15986 /*Bcast tx*/
15987 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15988 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15989
15990
Kiet Lam64c1b492013-07-12 13:56:44 +053015991 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015992
15993 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15994
15995 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15996 {
15997 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15998 }
15999
16000
16001 if (IS_DOT11_MODE_HT(dot11mode))
16002 {
16003 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
16004 }
16005
16006
16007 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
16008 if ( DOT11F_FAILED( nStatus ) )
16009 {
16010 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16011 "Failed to calculate the packed size f"
16012 "or a Probe Request (0x%08x).\n", nStatus );
16013
16014
16015 nPayload = sizeof( tDot11fProbeRequest );
16016 }
16017 else if ( DOT11F_WARNED( nStatus ) )
16018 {
16019 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16020 "There were warnings while calculating"
16021 "the packed size for a Probe Request ("
16022 "0x%08x).\n", nStatus );
16023 }
16024
16025 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
16026
16027 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053016028 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016029
16030
16031 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016032 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016033
16034 if ( eSIR_SUCCESS != nSirStatus )
16035 {
16036 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16037 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
16038 nSirStatus );
16039 return nSirStatus;
16040 }
16041
16042
16043 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
16044 sizeof( tSirMacMgmtHdr ),
16045 nPayload, &nPayload );
16046 if ( DOT11F_FAILED( nStatus ) )
16047 {
16048 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16049 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
16050 return eSIR_FAILURE;
16051 }
16052 else if ( DOT11F_WARNED( nStatus ) )
16053 {
16054 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070016055 "There were warnings while packing a Probe Request (0x%08x).\n",
16056 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016057 }
16058
16059 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
16060 return eSIR_SUCCESS;
16061}
16062
16063eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
16064{
16065 vos_msg_t msg;
16066 tSirRoamOffloadScanReq *pRequestBuf;
16067 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
16068 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016069 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016070 tANI_U8 *ChannelList = NULL;
16071 tANI_U32 sessionId;
16072 eHalStatus status = eHAL_STATUS_SUCCESS;
16073 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070016074 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016075 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016076 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016077 tSirBssDescription *pBssDesc = NULL;
16078 tDot11fBeaconIEs *pIes = NULL;
16079 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080016080 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016081
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016082 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
16083
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070016084 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016085 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016086 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016087 return eHAL_STATUS_FAILURE;
16088 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016089
16090 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
16091 {
16092 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
16093 return eHAL_STATUS_FAILURE;
16094 }
Abhishek Singh3e915632014-11-01 17:14:50 +053016095
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016096 /*The Dynamic Config Items Update may happen even if the state is in INIT.
16097 * It is important to ensure that the command is passed down to the FW only
16098 * if the Infra Station is in a connected state.A connected station could also be
16099 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
16100 * We also have to ensure that if there is a STOP command we always have to inform Riva,
16101 * irrespective of whichever state we are in.*/
16102 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
16103 (command != ROAM_SCAN_OFFLOAD_STOP))
16104 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053016105 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
16106 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
16107 macTraceGetNeighbourRoamState(
16108 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016109 return eHAL_STATUS_FAILURE;
16110 }
16111
Abhishek Singh3e915632014-11-01 17:14:50 +053016112 /* We dont need psession during ROAM_SCAN_OFFLOAD_STOP
16113 * Also there are cases where pNeighborRoamInfo->currAPbssid
16114 * is set to 0 during disconnect and so we might return without stopping
16115 * the roam scan. So no need to find the session if command is
16116 * ROAM_SCAN_OFFLOAD_STOP.
16117 */
16118 if( ROAM_SCAN_OFFLOAD_STOP != command )
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016119 {
Abhishek Singh3e915632014-11-01 17:14:50 +053016120 status = csrRoamGetSessionIdFromBSSID(pMac,
16121 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
16122 &sessionId);
16123
16124 if ( !HAL_STATUS_SUCCESS( status ) )
16125 {
16126 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16127 "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
16128 return eHAL_STATUS_FAILURE;
16129 }
16130 pSession = CSR_GET_SESSION( pMac, sessionId );
16131 if (NULL == pSession)
16132 {
16133 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
krunal soni587bf012014-02-04 12:35:11 -080016134 "%s:pSession is null", __func__);
Abhishek Singh3e915632014-11-01 17:14:50 +053016135 return eHAL_STATUS_FAILURE;
16136 }
16137 pBssDesc = pSession->pConnectBssDesc;
16138 if (pBssDesc == NULL)
16139 {
16140 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16141 "%s: pBssDesc not found for current session", __func__);
16142 return eHAL_STATUS_FAILURE;
16143 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016144 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016145 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
16146 if (NULL == pRequestBuf)
16147 {
Abhishek Singh3e915632014-11-01 17:14:50 +053016148 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16149 "%s: Not able to allocate memory for Roam Offload scan request", __func__);
16150 return eHAL_STATUS_FAILED_ALLOC;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016151 }
16152
Abhishek Singh3e915632014-11-01 17:14:50 +053016153 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
16154 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
16155 * host driver reloads, but Riva still up and running*/
16156 pRequestBuf->Command = command;
16157 if(command == ROAM_SCAN_OFFLOAD_STOP)
16158 {
16159 pRequestBuf->RoamScanOffloadEnabled = 0;
16160 /*For a STOP Command, there is no need to
16161 * go through filling up all the below parameters
16162 * since they are not required for the STOP command*/
16163 goto send_roam_scan_offload_cmd;
16164 }
16165 else
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016166 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053016167 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
16168 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016169 sizeof(tCsrBssid));
16170 pRequestBuf->ConnectedNetwork.ssId.length =
16171 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
16172 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
16173 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
16174 pRequestBuf->ConnectedNetwork.ssId.length);
16175 pRequestBuf->ConnectedNetwork.authentication =
16176 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
16177 pRequestBuf->ConnectedNetwork.encryption =
16178 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
16179 pRequestBuf->ConnectedNetwork.mcencryption =
16180 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016181 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
16182 {
16183 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016184 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016185 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16186 }
16187 else
16188 {
16189 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
16190 operationChannel = pSession->connectedProfile.operationChannel;
16191
16192 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
16193 {
16194 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16195 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
16196 vos_mem_free(pRequestBuf);
16197 return eHAL_STATUS_FAILURE;
16198 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016199 if(NULL == pIes)
16200 {
16201 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16202 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053016203 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016204 return eHAL_STATUS_FAILURE;
16205 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016206 if (pIes->SuppRates.present)
16207 {
16208 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
16209 /*Check for both basic rates and extended rates.*/
16210 for (i = 0; i < pIes->SuppRates.num_rates; i++)
16211 {
16212 /*Check if the Rate is Mandatory or Not*/
16213 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
16214 && (pIes->SuppRates.rates[i] & 0x80))
16215 {
16216 /*Retrieve the actual data rate*/
16217 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
16218 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16219 if (minRate == 0)
16220 minRate = dataRate;
16221 else
16222 minRate = (minRate < dataRate) ? minRate:dataRate;
16223 }
16224 }
16225
16226 if (pIes->ExtSuppRates.present)
16227 {
16228 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
16229 {
16230 /*Check if the Rate is Mandatory or Not*/
16231 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
16232 && (pIes->ExtSuppRates.rates[i] & 0x80))
16233 {
16234 /*Retrieve the actual data rate*/
16235 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
16236 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16237 if (minRate == 0)
16238 minRate = dataRate;
16239 else
16240 minRate = (minRate < dataRate) ? minRate:dataRate;
16241 }
16242 }
16243 }
16244 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
16245 }
16246 else
16247 {
16248 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16249 "%s: Supp Rates not present in pIes", __func__);
16250 vos_mem_free(pRequestBuf);
16251 return eHAL_STATUS_FAILURE;
16252 }
16253 if (NULL != pIes)
16254 {
16255 vos_mem_free(pIes);
16256 pIes = NULL;
16257 }
16258 switch (minRate)
16259 {
16260 case 1:
16261 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
16262 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
16263 break;
16264 case 2:
16265 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
16266 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
16267 break;
16268 case 5:
16269 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
16270 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
16271 break;
16272 case 6:
16273 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16274 {
16275 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
16276 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
16277 }
16278 else
16279 {
16280 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
16281 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
16282 }
16283 break;
16284 case 11:
16285 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
16286 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
16287 break;
16288 case 12:
16289 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16290 {
16291 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
16292 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
16293 }
16294 else
16295 {
16296 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
16297 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
16298 }
16299 break;
16300 case 24:
16301 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16302 {
16303 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
16304 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
16305 }
16306 else
16307 {
16308 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
16309 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
16310 }
16311 break;
16312 default:
16313 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
16314 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16315 break;
16316 }
16317 }
16318 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16319 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
16320 operationChannel, minRate,
16321 pRequestBuf->RxSensitivityThreshold,
16322 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016323 pRequestBuf->RoamRssiDiff =
16324 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016325 pRequestBuf->StartScanReason = reason;
16326 pRequestBuf->NeighborScanTimerPeriod =
16327 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
16328 pRequestBuf->NeighborRoamScanRefreshPeriod =
16329 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
16330 pRequestBuf->NeighborScanChannelMinTime =
16331 pNeighborRoamInfo->cfgParams.minChannelScanTime;
16332 pRequestBuf->NeighborScanChannelMaxTime =
16333 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
16334 pRequestBuf->EmptyRefreshScanPeriod =
16335 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080016336 /* MAWC feature */
16337 pRequestBuf->MAWCEnabled =
16338 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016339#ifdef FEATURE_WLAN_ESE
16340 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016341#endif
16342 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016343#ifdef FEATURE_WLAN_ESE
16344 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016345 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
16346 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016347 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
16348#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016349 currChannelListInfo->numOfChannels == 0)
16350 {
16351
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016352 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
16353 * Give Preference to INI Channels.*/
16354 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
16355 {
16356 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
16357 /*The INI channels need to be filtered with respect to the current
16358 * band that is supported.*/
16359 eBand = pMac->roam.configParam.bandCapability;
16360 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016361 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016362 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16363 "Invalid band, No operation carried out (Band %d)", eBand);
16364 vos_mem_free(pRequestBuf);
16365 return eHAL_STATUS_FAILURE;
16366 }
16367 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
16368 {
16369 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
16370 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
16371 (eCSR_BAND_ALL == eBand))
16372 {
16373 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
16374 csrRoamIsChannelValid(pMac, *ChannelList) &&
16375 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16376 {
16377 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16378 }
16379 }
16380 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016381 }
16382 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16383 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016384 }
16385 else
16386 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016387 ChannelList = pMac->scan.occupiedChannels.channelList;
16388 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
16389 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016390 /*Allow DFS channels only if the DFS channel roam flag is enabled */
16391 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16392 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016393 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16394 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016395 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016396 }
16397 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016398 }
16399 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16400 /* If the profile changes as to what it was earlier, inform the FW through
16401 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
16402 * for the earlier profile and try to learn them afresh.*/
16403 if (reason == REASON_FLUSH_CHANNEL_LIST)
16404 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16405 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016406 if (csrNeighborRoamIsNewConnectedProfile(pMac))
16407 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16408 else
16409 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016410 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016411 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016412 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016413#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016414 else
16415 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016416 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016417 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016418 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016419 if (currChannelListInfo->numOfChannels != 0)
16420 {
16421 ChannelList = currChannelListInfo->ChannelList;
16422 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016423 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016424 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16425 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016426 {
16427 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16428 }
16429 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016430 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016431 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16432 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16433 }
16434 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016435#endif
Kaushik, Sushant5ed8ab62014-03-05 11:21:11 +053016436 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0])) && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016437 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016438 if (j < sizeof(ChannelCacheStr))
16439 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016440 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
16441 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016442 }
16443 else
16444 {
16445 break;
16446 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016447 }
16448 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16449 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
16450 pRequestBuf->ChannelCacheType,
16451 pRequestBuf->ConnectedNetwork.ChannelCount,
16452 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016453 num_channels = 0;
16454 ChannelList = NULL;
16455
16456 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070016457 host_channels = sizeof(pMac->roam.validChannelList);
16458 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016459 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070016460 ChannelList = pMac->roam.validChannelList;
16461 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016462 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070016463 else
16464 {
16465 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16466 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070016467 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070016468 return eHAL_STATUS_FAILURE;
16469 }
16470 for(i=0; i<pMac->roam.numValidChannels; i++)
16471 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016472 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16473 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Srinivas Girigowda56076852013-08-20 14:00:50 -070016474 {
16475 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
16476 }
16477 ChannelList++;
16478 }
16479 pRequestBuf->ValidChannelCount = num_channels;
16480
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016481 pRequestBuf->MDID.mdiePresent =
16482 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16483 pRequestBuf->MDID.mobilityDomain =
16484 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016485 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16486
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016487 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016488 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16489 * where RFS is the RF Switching time. It is twice RFS to consider the
16490 * time to go off channel and return to the home channel. */
16491 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16492 {
16493 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16494 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16495 " Hence enforcing home away time to disable (0)",
16496 __func__, pRequestBuf->HomeAwayTime,
16497 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16498 pRequestBuf->HomeAwayTime = 0;
16499 }
16500 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016501
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016502 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16503 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16504 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16505 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16506 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16507
16508 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16509 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016510send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016511 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016512 msg.reserved = 0;
16513 msg.bodyptr = pRequestBuf;
16514 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16515 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016516 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16517 vos_mem_free(pRequestBuf);
16518 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016519 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016520 else
16521 {
16522 if (ROAM_SCAN_OFFLOAD_START == command)
16523 bRoamScanOffloadStarted = VOS_TRUE;
16524 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16525 bRoamScanOffloadStarted = VOS_FALSE;
16526 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016527
16528 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16529 return status;
16530}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016531
16532eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16533{
16534 switch(reason)
16535 {
16536 case 0:
16537 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16538 break;
16539 case REASON_OS_REQUESTED_ROAMING_NOW:
16540 csrNeighborRoamProceedWithHandoffReq(pMac);
16541 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053016542 case REASON_INITIAL_FORCED_ROAM_TO_5G:
16543 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
16544 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016545 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016546 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 -070016547 }
16548 return eHAL_STATUS_SUCCESS;
16549}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016550#endif
16551
Jeff Johnson295189b2012-06-20 16:38:30 -070016552tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16553 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16554{
16555 tANI_BOOLEAN found = FALSE;
16556 eHalStatus status = eHAL_STATUS_SUCCESS;
16557 tCsrPeStatsReqInfo staEntry;
16558 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16559 tListElem *pStaEntry = NULL;
16560 VOS_STATUS vosStatus;
16561 tPmcPowerState powerState;
16562 *pFound = FALSE;
16563
16564 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16565 if(pStaEntry)
16566 {
16567 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16568 if(pTempStaEntry->periodicity)
16569 {
16570 pTempStaEntry->periodicity =
16571 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16572 }
16573 else
16574 {
16575 pTempStaEntry->periodicity = periodicity;
16576 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016577 pTempStaEntry->numClient++;
16578 found = TRUE;
16579 }
16580 else
16581 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016582 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016583 staEntry.numClient = 1;
16584 staEntry.periodicity = periodicity;
16585 staEntry.pMac = pMac;
16586 staEntry.rspPending = FALSE;
16587 staEntry.staId = staId;
16588 staEntry.statsMask = statsMask;
16589 staEntry.timerRunning = FALSE;
16590 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16591 if(!pTempStaEntry)
16592 {
16593 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016594 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016595 return NULL;
16596 }
16597 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016598 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16599 if(ePMC_FULL_POWER == powerState)
16600 {
16601 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16602 {
16603 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16604 }
16605 }
16606 else
16607 {
16608 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16609 {
16610 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16611 }
16612 }
16613 if(!pTempStaEntry->timerRunning)
16614 {
16615 //send down a req in case of one time req, for periodic ones wait for timer to expire
16616 if(!pTempStaEntry->rspPending &&
16617 !pTempStaEntry->periodicity)
16618 {
16619 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16620 if(!HAL_STATUS_SUCCESS(status))
16621 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016622 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016623 }
16624 else
16625 {
16626 pTempStaEntry->rspPending = TRUE;
16627 }
16628 }
16629 if(pTempStaEntry->periodicity)
16630 {
16631 if(!found)
16632 {
16633
16634 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16635 csrRoamPeStatsTimerHandler, pTempStaEntry );
16636 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016638 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016639 return NULL;
16640 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016641 }
16642 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016643 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016644 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16645 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16646 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016647 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016648 return NULL;
16649 }
16650 pTempStaEntry->timerRunning = TRUE;
16651 }
16652 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016653 *pFound = found;
16654 return pTempStaEntry;
16655}
16656
Jeff Johnson295189b2012-06-20 16:38:30 -070016657/*
16658 pStaEntry is no longer invalid upon the return of this function.
16659*/
16660static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16661{
16662 if(pEntry)
16663 {
16664 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16665 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016666 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016667 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016668 }
16669 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016670
16671void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16672{
16673 tListElem *pEntry;
16674 tCsrPeStatsReqInfo *pTempStaEntry;
16675 VOS_STATUS vosStatus;
16676 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016677 if(!pEntry)
16678 {
16679 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016680 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016681 return;
16682 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016683 while( pEntry )
16684 {
16685 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016686 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16687 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016688 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016689 if(pTempStaEntry->timerRunning)
16690 {
16691 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16692 /* If we are not able to stop the timer here, just remove
16693 * the entry from the linked list. Destroy the timer object
16694 * and free the memory in the timer CB
16695 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016696 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016697 {
16698 /* the timer is successfully stopped */
16699 pTempStaEntry->timerRunning = FALSE;
16700
16701 /* Destroy the timer */
16702 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16703 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16704 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016705 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016706 }
16707 }
16708 else
16709 {
16710 // the timer could not be stopped. Hence destroy and free the
16711 // memory for the PE stat entry in the timer CB.
16712 pTempStaEntry->timerStopFailed = TRUE;
16713 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016714 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016715
16716 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16717 {
16718 // Only free the memory if we could stop the timer successfully
16719 if(!pTempStaEntry->timerStopFailed)
16720 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016721 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016722 pTempStaEntry = NULL;
16723 }
16724 break;
16725 }
16726
16727 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16728 }
16729 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016730 return;
16731}
16732
16733
Jeff Johnsone7245742012-09-05 17:12:55 -070016734void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016735{
16736
Jeff Johnsone7245742012-09-05 17:12:55 -070016737 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16738 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16739 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16740 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16741 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16742 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16743 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016744 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016745 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16746 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16747 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16748 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16749 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16750 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016751 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016752 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16753 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016754
16755}
16756
Jeff Johnson295189b2012-06-20 16:38:30 -070016757void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16758 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16759{
16760 tANI_U8 stats[500];
16761 tANI_U8 *pStats = NULL;
16762 tANI_U32 tempMask = 0;
16763 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016764 if(!callback)
16765 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016766 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016767 return;
16768 }
16769 if(!statsMask)
16770 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016771 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016772 return;
16773 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016774 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016775 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016776 while(tempMask)
16777 {
16778 if(tempMask & 1)
16779 {
16780 //new stats info from PE, fill up the stats strucutres in PMAC
16781 switch(counter)
16782 {
16783 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016784 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016785 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16786 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016787 pStats += sizeof(tCsrSummaryStatsInfo);
16788 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016789 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016790 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016791 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16792 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016793 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016794 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016795 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016796 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016797 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16798 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016799 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016800 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016801 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016802 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016803 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16804 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016805 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016806 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016807 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016808 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016809 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16810 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016811 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016812 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016813 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016814 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016815 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16816 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016817 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016818 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016819 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016820 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016821 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016822 }
16823 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016824 tempMask >>=1;
16825 counter++;
16826 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016827 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016828}
16829
Jeff Johnson295189b2012-06-20 16:38:30 -070016830eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16831{
16832 tListElem *pEntry = NULL;
16833 tListElem *pPrevEntry = NULL;
16834 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16835 eHalStatus status = eHAL_STATUS_SUCCESS;
16836 VOS_STATUS vosStatus;
16837 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016838 if(!pEntry)
16839 {
16840 //list empty
16841 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016842 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016843 return status;
16844 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016845 while( pEntry )
16846 {
16847 if(pPrevEntry)
16848 {
16849 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16850 //send up the stats report
16851 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16852 pTempStaEntry->staId, pTempStaEntry->pContext);
16853 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16854 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016855 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016856 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16857 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016858 pTempStaEntry->pPeStaEntry->numClient--;
16859 //check if we need to delete the entry from peStatsReqList too
16860 if(!pTempStaEntry->pPeStaEntry->numClient)
16861 {
16862 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16863 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016864 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016865 //check if we need to stop the tl stats timer too
16866 pMac->roam.tlStatsReqInfo.numClient--;
16867 if(!pMac->roam.tlStatsReqInfo.numClient)
16868 {
16869 if(pMac->roam.tlStatsReqInfo.timerRunning)
16870 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016871 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16872 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016873 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016874 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016875 //we will continue
16876 }
16877 }
16878 pMac->roam.tlStatsReqInfo.periodicity = 0;
16879 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16880 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016881 if (pTempStaEntry->periodicity)
16882 {
16883 //While creating StaEntry in csrGetStatistics,
16884 //Initializing and starting timer only when periodicity is set.
16885 //So Stop and Destroy timer only when periodicity is set.
16886
Jeff Johnsone7245742012-09-05 17:12:55 -070016887 vos_timer_stop( &pTempStaEntry->timer );
16888 // Destroy the vos timer...
16889 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16890 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16891 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016892 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016893 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016894 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016895
Jeff Johnson295189b2012-06-20 16:38:30 -070016896
16897 pPrevEntry = pEntry;
16898 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16899 }
16900 //the last one
16901 if(pPrevEntry)
16902 {
16903 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16904 //send up the stats report
16905 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16906 pTempStaEntry->staId, pTempStaEntry->pContext);
16907 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16908 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016909 return status;
16910
16911}
16912
Jeff Johnson295189b2012-06-20 16:38:30 -070016913eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16914 tRequestFullPowerReason *pReason,
16915 tANI_BOOLEAN *pfNeedPower )
16916{
16917 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16918 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16919 tPmcState pmcState;
16920 eHalStatus status = eHAL_STATUS_SUCCESS;
16921 // TODO : Session info unavailable
16922 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016923 if( pfNeedPower )
16924 {
16925 *pfNeedPower = eANI_BOOLEAN_FALSE;
16926 }
16927 //We only handle CSR commands
16928 if( !(eSmeCsrCommandMask & pCommand->command) )
16929 {
16930 return eHAL_STATUS_SUCCESS;
16931 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016932 //Check PMC state first
16933 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016934 switch( pmcState )
16935 {
16936 case REQUEST_IMPS:
16937 case IMPS:
16938 if( eSmeCommandScan == pCommand->command )
16939 {
16940 switch( pCommand->u.scanCmd.reason )
16941 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016942#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16943 case eCsrScanGetLfrResult:
16944#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016945 case eCsrScanGetResult:
16946 case eCsrScanBGScanAbort:
16947 case eCsrScanBGScanEnable:
16948 case eCsrScanGetScanChnInfo:
16949 //Internal process, no need for full power
16950 fNeedFullPower = eANI_BOOLEAN_FALSE;
16951 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016952 default:
16953 //Other scans are real scan, ask for power
16954 fNeedFullPower = eANI_BOOLEAN_TRUE;
16955 break;
16956 } //switch
16957 }
16958 else
16959 {
16960 //ask for power for roam and status change
16961 fNeedFullPower = eANI_BOOLEAN_TRUE;
16962 }
16963 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016964 case REQUEST_BMPS:
16965 case BMPS:
16966 case REQUEST_START_UAPSD:
16967 case UAPSD:
16968 //We treat WOWL same as BMPS
16969 case REQUEST_ENTER_WOWL:
16970 case WOWL:
16971 if( eSmeCommandRoam == pCommand->command )
16972 {
16973 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16974 tCsrScanResult *pScanResult;
16975 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016976 switch ( pCommand->u.roamCmd.roamReason )
16977 {
16978 case eCsrForcedDisassoc:
16979 case eCsrForcedDisassocMICFailure:
16980 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16981 fNeedFullPower = eANI_BOOLEAN_TRUE;
16982 break;
16983 case eCsrSmeIssuedDisassocForHandoff:
16984 case eCsrForcedDeauth:
16985 case eCsrHddIssuedReassocToSameAP:
16986 case eCsrSmeIssuedReassocToSameAP:
16987 fNeedFullPower = eANI_BOOLEAN_TRUE;
16988 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016989 case eCsrCapsChange:
16990 fNeedFullPower = eANI_BOOLEAN_TRUE;
16991 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016992 default:
16993 //Check whether the profile is already connected. If so, no need for full power
16994 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16995 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16996 {
16997 //Only need to check the first one
16998 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16999 if( pEntry )
17000 {
17001 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
17002#if 0
17003 // TODO : Session Specific info pConnectBssDesc
17004 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
17005 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
17006 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
17007 {
17008 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
17009 // with Authenticating first. To force this, stop the current association (Disassociate) and
17010 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
17011 // a new Association.
17012 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
17013 {
17014 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
17015 {
17016 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
17017 //No need for full power
17018 //Set the flag so the code later can avoid to do the above
17019 //check again.
17020 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
17021 break;
17022 }
17023 }
17024 }
17025#endif
17026 }
17027 }
17028 //If we are here, full power is needed
17029 fNeedFullPower = eANI_BOOLEAN_TRUE;
17030 break;
17031 }
17032 }
17033 else if( eSmeCommandWmStatusChange == pCommand->command )
17034 {
17035 //need full power for all
17036 fNeedFullPower = eANI_BOOLEAN_TRUE;
17037 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
17038 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017039#ifdef FEATURE_WLAN_TDLS
17040 else if( eSmeCommandTdlsAddPeer == pCommand->command )
17041 {
17042 //TDLS link is getting established. need full power
17043 fNeedFullPower = eANI_BOOLEAN_TRUE;
17044 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
17045 }
17046#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017047 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017048 case REQUEST_STOP_UAPSD:
17049 case REQUEST_EXIT_WOWL:
17050 if( eSmeCommandRoam == pCommand->command )
17051 {
17052 fNeedFullPower = eANI_BOOLEAN_TRUE;
17053 switch ( pCommand->u.roamCmd.roamReason )
17054 {
17055 case eCsrForcedDisassoc:
17056 case eCsrForcedDisassocMICFailure:
17057 reason = eSME_LINK_DISCONNECTED_BY_HDD;
17058 break;
17059 default:
17060 break;
17061 }
17062 }
17063 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017064 case STOPPED:
17065 case REQUEST_STANDBY:
17066 case STANDBY:
17067 case LOW_POWER:
17068 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053017069 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
17070 " stopped/standby state %s (%d)" ),
17071 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070017072 status = eHAL_STATUS_FAILURE;
17073 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017074 case FULL_POWER:
17075 case REQUEST_FULL_POWER:
17076 default:
17077 //No need to ask for full power. This has to be FULL_POWER state
17078 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017079 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070017080 if( pReason )
17081 {
17082 *pReason = reason;
17083 }
17084 if( pfNeedPower )
17085 {
17086 *pfNeedPower = fNeedFullPower;
17087 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017088 return ( status );
17089}
17090
Jeff Johnson295189b2012-06-20 16:38:30 -070017091static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
17092{
17093 eHalStatus status = eHAL_STATUS_SUCCESS;
17094 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
17095 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070017096 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070017097 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
17098 {
17099 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
17100 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017101 return ( status );
17102}
17103
Jeff Johnson295189b2012-06-20 16:38:30 -070017104tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
17105{
17106 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070017107 if( pCmd )
17108 {
17109 pMac->roam.sPendingCommands++;
17110 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017111 return ( pCmd );
17112}
17113
Jeff Johnson295189b2012-06-20 16:38:30 -070017114void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
17115{
17116 if (pMac->roam.sPendingCommands > 0)
17117 {
17118 //All command allocated through csrGetCommandBuffer need to
17119 //decrement the pending count when releasing.
17120 pMac->roam.sPendingCommands--;
17121 smeReleaseCommand( pMac, pCommand );
17122 }
17123 else
17124 {
17125 smsLog(pMac, LOGE, FL( "no pending commands"));
17126 VOS_ASSERT(0);
17127 }
17128}
17129
Jeff Johnson295189b2012-06-20 16:38:30 -070017130//Return SUCCESS is the command is queued, failed
17131eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
17132{
17133 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017134 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
17135 {
17136 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
17137 pCommand->u.scanCmd.reason);
17138 return eHAL_STATUS_CSR_WRONG_STATE;
17139 }
17140
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017141 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
17142 {
17143 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
17144 &pCommand->Link, LL_ACCESS_LOCK);
17145 // process the command queue...
17146 smeProcessPendingQueue(pMac);
17147 status = eHAL_STATUS_SUCCESS;
17148 goto end;
17149 }
17150
Jeff Johnson295189b2012-06-20 16:38:30 -070017151 //We can call request full power first before putting the command into pending Q
17152 //because we are holding SME lock at this point.
17153 status = csrRequestFullPower( pMac, pCommand );
17154 if( HAL_STATUS_SUCCESS( status ) )
17155 {
17156 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070017157 //make sure roamCmdPendingList is not empty first
17158 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
17159 if( fNoCmdPending )
17160 {
17161 smePushCommand( pMac, pCommand, fHighPriority );
17162 }
17163 else
17164 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017165 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070017166 //no list lock is needed since SME lock is held
17167 if( !fHighPriority )
17168 {
17169 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17170 }
17171 else {
17172 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17173 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017174 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017175 }
17176 else if( eHAL_STATUS_PMC_PENDING == status )
17177 {
17178 //no list lock is needed since SME lock is held
17179 if( !fHighPriority )
17180 {
17181 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17182 }
17183 else {
17184 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17185 }
17186 //Let caller know the command is queue
17187 status = eHAL_STATUS_SUCCESS;
17188 }
17189 else
17190 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017191 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070017192 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017193 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070017194 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017195end:
Jeff Johnson295189b2012-06-20 16:38:30 -070017196 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070017197}
Jeff Johnson295189b2012-06-20 16:38:30 -070017198eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
17199{
17200 eHalStatus status = eHAL_STATUS_SUCCESS;
17201 tSirUpdateAPWPSIEsReq *pMsg;
17202 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
17203
17204 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17205 if (NULL == pSession)
17206 {
17207 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17208 return eHAL_STATUS_FAILURE;
17209 }
17210
Jeff Johnson295189b2012-06-20 16:38:30 -070017211 do
17212 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017213 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
17214 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17215 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017216 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
17217
17218 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070017219 VOS_ASSERT(pBuf);
17220
Jeff Johnson295189b2012-06-20 16:38:30 -070017221 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017222 // transactionId
17223 *pBuf = 0;
17224 *( pBuf + 1 ) = 0;
17225 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070017226 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017227 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17228 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017229 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017230 //sessionId
17231 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017232 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017233 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070017234 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070017235 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017236 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017237 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017238 return ( status );
17239}
Jeff Johnson295189b2012-06-20 16:38:30 -070017240eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
17241{
17242 eHalStatus status = eHAL_STATUS_SUCCESS;
17243 tSirUpdateAPWPARSNIEsReq *pMsg;
17244 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017245 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17246 if (NULL == pSession)
17247 {
17248 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17249 return eHAL_STATUS_FAILURE;
17250 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017251 do
17252 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017253 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
17254 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17255 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017256 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070017257 pBuf = (tANI_U8 *)&pMsg->transactionId;
17258 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017259 // transactionId
17260 *pBuf = 0;
17261 *( pBuf + 1 ) = 0;
17262 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070017263 VOS_ASSERT(pBuf);
17264
Jeff Johnson295189b2012-06-20 16:38:30 -070017265 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017266 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17267 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017268 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017269 // sessionId
17270 *pBuf++ = (tANI_U8)sessionId;
17271
17272 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017273 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070017274 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070017275 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017276 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017277 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017278 return ( status );
17279}
Jeff Johnson295189b2012-06-20 16:38:30 -070017280
17281#ifdef WLAN_FEATURE_VOWIFI_11R
17282//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
17283eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
17284{
17285 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17286 tpSirFTPreAuthReq pftPreAuthReq;
17287 tANI_U16 auth_req_len = 0;
17288 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017289 auth_req_len = sizeof(tSirFTPreAuthReq);
17290 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053017291 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070017292 {
17293 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
17294 return eHAL_STATUS_RESOURCES;
17295 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017296 // Save the SME Session ID here. We need it while processing the preauth response
17297 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017298 vos_mem_zero(pftPreAuthReq, auth_req_len);
17299
17300 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
17301 sizeof(pBssDescription->length) + pBssDescription->length);
17302
17303 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
17304
17305 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
17306
Kiet Lam64c1b492013-07-12 13:56:44 +053017307 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
17308 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
17309 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
17310 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017311
Jeff Johnson295189b2012-06-20 16:38:30 -070017312#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080017313 if (csrRoamIs11rAssoc(pMac) &&
17314 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070017315 {
17316 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053017317 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
17318 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070017319 }
17320 else
17321#endif
17322 {
17323 pftPreAuthReq->ft_ies_length = 0;
17324 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070017325 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
17326 sizeof(pBssDescription->length) + pBssDescription->length);
17327 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070017328 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
17329}
Jeff Johnson295189b2012-06-20 16:38:30 -070017330/*--------------------------------------------------------------------------
17331 * This will receive and process the FT Pre Auth Rsp from the current
17332 * associated ap.
17333 *
17334 * This will invoke the hdd call back. This is so that hdd can now
17335 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
17336 ------------------------------------------------------------------------*/
17337void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
17338{
17339 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17340 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017341#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017342 tCsrRoamInfo roamInfo;
17343#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017344 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070017345
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017346#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080017347 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017348 if (status != eHAL_STATUS_SUCCESS) {
17349 /*
17350 * Bail out if pre-auth was not even processed.
17351 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017352 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
17353 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017354 return;
17355 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017356#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017357 /* The below function calls/timers should be invoked only if the pre-auth is successful */
17358 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
17359 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070017360 // Implies a success
17361 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017362 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
17363 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053017364 /* No need to notify qos module if this is a non 11r & ESE roam*/
17365 if (csrRoamIs11rAssoc(pMac)
17366#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
17367 || csrRoamIsESEAssoc(pMac)
17368#endif
17369 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070017370 {
17371 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
17372 }
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053017373#ifdef DEBUG_ROAM_DELAY
17374 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
17375#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017376 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
17377 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017378 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
17379 60);
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053017380#ifdef DEBUG_ROAM_DELAY
17381 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
17382#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017383 if (eHAL_STATUS_SUCCESS != status)
17384 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017385 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017386 return;
17387 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017388 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017389 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
17390 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070017391 if (csrRoamIs11rAssoc(pMac))
17392 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
17393 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
17394
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017395#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
17396 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017397 {
17398 /* read TSF */
17399 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
17400
17401 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017402 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017403 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
17404 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017405#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017406#ifdef FEATURE_WLAN_LFR
17407 // If Legacy Fast Roaming is enabled, signal the supplicant
17408 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053017409 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017410 {
17411 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017412 vos_mem_copy((void *)&roamInfo.bssid,
17413 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017414 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
17415 }
17416
17417#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017418
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017419 // If its an Open Auth, FT IEs are not provided by supplicant
17420 // Hence populate them here
17421 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
17422 pMac->ft.ftSmeContext.addMDIE = FALSE;
17423 if( csrRoamIs11rAssoc(pMac) &&
17424 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
17425 {
17426 tANI_U16 ft_ies_length;
17427 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
17428
17429 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
17430 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
17431 {
17432 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
17433 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
17434 }
17435
17436 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
17437 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
17438 {
17439 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
17440 }
17441 else
17442 {
17443 // Copy the RIC IEs to reassoc IEs
17444 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
17445 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
17446 pFTPreAuthRsp->ric_ies_length);
17447 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
17448 pMac->ft.ftSmeContext.addMDIE = TRUE;
17449 }
17450 }
17451
Jeff Johnson295189b2012-06-20 16:38:30 -070017452 // Done with it, init it.
17453 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
17454}
17455#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017456
Jeff Johnson295189b2012-06-20 16:38:30 -070017457#ifdef FEATURE_WLAN_BTAMP_UT_RF
17458void csrRoamJoinRetryTimerHandler(void *pv)
17459{
17460 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
17461 tpAniSirGlobal pMac = pInfo->pMac;
17462 tANI_U32 sessionId = pInfo->sessionId;
17463 tCsrRoamSession *pSession;
17464
17465 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17466 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017467 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017468 pSession = CSR_GET_SESSION( pMac, sessionId );
17469 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
17470 {
17471 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
17472 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017473 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017474 }
17475 }
17476 }
17477}
Jeff Johnson295189b2012-06-20 16:38:30 -070017478eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
17479{
17480 eHalStatus status = eHAL_STATUS_FAILURE;
17481 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17482
17483 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
17484 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017485 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070017486 pSession->maxRetryCount--;
17487 pSession->joinRetryTimerInfo.pMac = pMac;
17488 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017489 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
17490 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017491 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017492 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017493 }
17494 }
17495 else
17496 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017497 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070017498 pSession->maxRetryCount);
17499 }
17500
17501 return (status);
17502}
Jeff Johnson295189b2012-06-20 16:38:30 -070017503eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
17504{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017505 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070017506 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17507 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017508 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070017509 }
17510
17511 return eHAL_STATUS_SUCCESS;
17512}
17513#endif
17514
17515
17516/*
17517 pBuf points to the beginning of the message
17518 LIM packs disassoc rsp as below,
17519 messageType - 2 bytes
17520 messageLength - 2 bytes
17521 sessionId - 1 byte
17522 transactionId - 2 bytes (tANI_U16)
17523 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17524 peerMacAddr - 6 bytes
17525 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17526*/
17527static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
17528{
17529 if(pBuf && pRsp)
17530 {
17531 pBuf += 4; //skip type and length
17532 pRsp->sessionId = *pBuf++;
17533 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
17534 pBuf += 2;
17535 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
17536 pBuf += 4;
17537 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17538 }
17539}
17540
Jeff Johnsond13512a2012-07-17 11:42:19 -070017541eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17542{
17543 static uNvTables nvTables;
17544 eHalStatus status = eHAL_STATUS_SUCCESS;
17545 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17546
17547 /* read the country code from NV and use it */
17548 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17549 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017550 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17551 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017552 return status;
17553 }
17554 else
17555 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017556 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017557 status = eHAL_STATUS_FAILURE;
17558 return status;
17559 }
17560}
17561
17562eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17563{
Kiet Lam64c1b492013-07-12 13:56:44 +053017564 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017565 return eHAL_STATUS_SUCCESS;
17566}
schang86c22c42013-03-13 18:41:24 -070017567
17568eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17569{
17570 tSirSetTxPowerReq *pMsg = NULL;
17571 eHalStatus status = eHAL_STATUS_SUCCESS;
17572 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17573
17574 if (!pSession)
17575 {
17576 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17577 return eHAL_STATUS_FAILURE;
17578 }
17579
Kiet Lam64c1b492013-07-12 13:56:44 +053017580 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17581 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17582 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17583 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17584 pMsg->length = sizeof(tSirSetTxPowerReq);
17585 pMsg->mwPower = mW;
17586 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17587 sizeof(tSirMacAddr));
17588 status = palSendMBMessage(pMac->hHdd, pMsg);
17589 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017590 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017591 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17592 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017593 }
17594 return status;
17595}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017596
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017597eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
17598{
17599 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
17600 eHalStatus status = eHAL_STATUS_SUCCESS;
17601 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17602
17603 if (!pSession)
17604 {
17605 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17606 return eHAL_STATUS_FAILURE;
17607 }
17608 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
17609 {
17610 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053017611
17612 if( NULL == pMsg )
17613 {
17614 smsLog(pMac, LOGE, FL("PMsg is NULL "));
17615 return eHAL_STATUS_FAILURE;
17616 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017617 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
17618 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
17619 pMsg->length = sizeof(tANI_U8);
17620 pMsg->seesionId = sessionId;
17621 status = palSendMBMessage(pMac->hHdd, pMsg);
17622 if (!HAL_STATUS_SUCCESS(status))
17623 {
17624 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
17625 //pMsg is freed by palSendMBMessage
17626 }
17627 }
17628 else
17629 {
17630 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
17631 status = eHAL_STATUS_FAILURE;
17632 }
17633 return status;
17634}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017635/* Returns whether a session is in VOS_STA_MODE...or not */
17636tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17637{
17638 tCsrRoamSession *pSession = NULL;
17639 pSession = CSR_GET_SESSION ( pMac, sessionId );
17640 if(!pSession)
17641 {
17642 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17643 return eANI_BOOLEAN_FALSE;
17644 }
17645 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17646 {
17647 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17648 return eANI_BOOLEAN_FALSE;
17649 }
17650 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17651 {
17652 return eANI_BOOLEAN_FALSE;
17653 }
17654 /* There is a possibility that the above check may fail,because
17655 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17656 * when it is connected.So,we may sneak through the above check even
17657 * if we are not a STA mode INFRA station. So, if we sneak through
17658 * the above condition, we can use the following check if we are
17659 * really in STA Mode.*/
17660
17661 if ( NULL != pSession->pCurRoamProfile )
17662 {
17663 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17664 {
17665 return eANI_BOOLEAN_TRUE;
17666 } else {
17667 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17668 return eANI_BOOLEAN_FALSE;
17669 }
17670 }
17671
17672 return eANI_BOOLEAN_FALSE;
17673}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017674
17675#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17676eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17677 tCsrHandoffRequest *pHandoffInfo)
17678{
17679 eHalStatus status = eHAL_STATUS_SUCCESS;
17680 vos_msg_t msg;
17681
17682 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017683 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17684 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017685 {
17686 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017687 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017688 }
17689 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17690 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17691 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17692 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017693 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017694 pHandoffInfo->bssid,
17695 6);
17696 msg.type = eWNI_SME_HANDOFF_REQ;
17697 msg.bodyptr = pMsg;
17698 msg.reserved = 0;
17699 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17700 {
17701 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017702 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017703 status = eHAL_STATUS_FAILURE;
17704 }
17705 return status;
17706}
17707#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017708
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017709
17710#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017711/* ---------------------------------------------------------------------------
17712 \fn csrSetCCKMIe
17713 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17714 data structure and this IE will be packed inside reassociation request
17715 \param pMac - pMac global structure
17716 \param sessionId - Current session id
17717 \param pCckmIe - pointer to CCKM IE data
17718 \param ccKmIeLen - length of the CCKM IE
17719 \- return Success or failure
17720 -------------------------------------------------------------------------*/
17721VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17722 const tANI_U8 *pCckmIe,
17723 const tANI_U8 ccKmIeLen)
17724{
17725 eHalStatus status = eHAL_STATUS_SUCCESS;
17726 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17727
17728 if (!pSession)
17729 {
17730 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17731 return eHAL_STATUS_FAILURE;
17732 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017733 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017734 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17735 return status;
17736}
17737
17738/* ---------------------------------------------------------------------------
17739 \fn csrRoamReadTSF
17740 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17741 probe response reception from the hand off AP to arrive at the latest TSF value.
17742 \param pMac - pMac global structure
17743 \param pTimestamp - output TSF timestamp
17744 \- return Success or failure
17745 -------------------------------------------------------------------------*/
17746VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17747{
17748 eHalStatus status = eHAL_STATUS_SUCCESS;
17749 tCsrNeighborRoamBSSInfo handoffNode;
17750 tANI_U32 timer_diff = 0;
17751 tANI_U32 timeStamp[2];
17752 tpSirBssDescription pBssDescription = NULL;
17753
17754 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17755 pBssDescription = handoffNode.pBssDescription;
17756
17757 // Get the time diff in milli seconds
17758 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17759 // Convert msec to micro sec timer
17760 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17761
17762 timeStamp[0] = pBssDescription->timeStamp[0];
17763 timeStamp[1] = pBssDescription->timeStamp[1];
17764
17765 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17766
Kiet Lamf2f201e2013-11-16 21:24:16 +053017767 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017768 sizeof (tANI_U32) * 2);
17769 return status;
17770}
17771
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017772#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017773
Agarwal Ashish738843c2014-09-25 12:27:56 +053017774/* ---------------------------------------------------------------------------
17775 \fn csrDisableDfsChannel
17776 \brief This function will call csrApplyChannelPowerCountryInfo to
17777 \ to trim the list on basis of NO_DFS flag.
17778 \param pMac - pMac global structure
17779 \- return void
17780 -------------------------------------------------------------------------*/
17781void csrDisableDfsChannel(tpAniSirGlobal pMac)
17782{
17783 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
17784 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE);
17785}