blob: 3a17f7ed85a498c93ed9724534f66aec999c4266 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam0fb93dd2014-02-19 00:32:59 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Kiet Lam0fb93dd2014-02-19 00:32:59 -080026 */
27
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------- *
32 ------------------------------------------------------------------------- *
Jeff Johnsone7245742012-09-05 17:12:55 -070033
Jeff Johnson295189b2012-06-20 16:38:30 -070034
35 \file csrApiRoam.c
36
37 Implementation for the Common Roaming interfaces.
38
Kiet Lamaa8e15a2014-02-11 23:30:06 -080039 Copyright (C) 2008 Qualcomm, Incorporated
40
Jeff Johnson295189b2012-06-20 16:38:30 -070041
42 ========================================================================== */
Jeff Johnson295189b2012-06-20 16:38:30 -070043/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070044 EDIT HISTORY FOR FILE
45
Jeff Johnson295189b2012-06-20 16:38:30 -070046 This section contains comments describing changes made to the module.
47 Notice that changes are listed in reverse chronological order.
48
Jeff Johnson295189b2012-06-20 16:38:30 -070049 when who what, where, why
50---------- --- --------------------------------------------------------
5106/03/10 js Added support to hostapd driven
52 * deauth/disassoc/mic failure
Jeff Johnson295189b2012-06-20 16:38:30 -070053===========================================================================*/
Jeff Johnson295189b2012-06-20 16:38:30 -070054#include "aniGlobal.h" //for tpAniSirGlobal
55#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070056#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
Jeff Johnsone7245742012-09-05 17:12:55 -070057#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070058#include "palApi.h"
59#include "csrInsideApi.h"
60#include "smsDebug.h"
61#include "logDump.h"
62#include "smeQosInternal.h"
63#include "wlan_qct_tl.h"
64#include "smeInside.h"
65#include "vos_diag_core_event.h"
66#include "vos_diag_core_log.h"
67#include "csrApi.h"
68#include "pmc.h"
69#include "vos_nvitem.h"
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053070#include "macTrace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070071#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
72#include "csrNeighborRoam.h"
73#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080074#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
75#include "csrEse.h"
76#endif /* FEATURE_WLAN_ESE && !FEATURE_WLAN_ESE_UPLOAD */
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053077#ifdef DEBUG_ROAM_DELAY
78#include "vos_utils.h"
79#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070080#define CSR_NUM_IBSS_START_CHANNELS_50 4
81#define CSR_NUM_IBSS_START_CHANNELS_24 3
82#define CSR_DEF_IBSS_START_CHANNEL_50 36
83#define CSR_DEF_IBSS_START_CHANNEL_24 1
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080084#define CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD ( 5 * PAL_TIMER_TO_SEC_UNIT ) // 5 seconds, for WPA, WPA2, CCKM
Jeff Johnson295189b2012-06-20 16:38:30 -070085#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
86/*---------------------------------------------------------------------------
87 OBIWAN recommends [8 10]% : pick 9%
88---------------------------------------------------------------------------*/
89#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070090/*---------------------------------------------------------------------------
91 OBIWAN recommends -85dBm
92---------------------------------------------------------------------------*/
93#define CSR_VCC_RSSI_THRESHOLD 80
94#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
95#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
96#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
97#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -070098//We use constatnt 4 here
99//This macro returns true when higher AC parameter is bigger than lower AC for a difference
100//The bigger the number, the less chance of TX
101//It must put lower AC as the first parameter.
102#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700103//Flag to send/do not send disassoc frame over the air
104#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700106#define MAX_CB_VALUE_IN_INI (2)
107
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700108#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
109static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
110#endif
111
Jeff Johnson295189b2012-06-20 16:38:30 -0700112/*--------------------------------------------------------------------------
113 Static Type declarations
114 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800115static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800116
Jeff Johnson295189b2012-06-20 16:38:30 -0700117/*--------------------------------------------------------------------------
118 Type declarations
119 ------------------------------------------------------------------------*/
120#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700121int diagAuthTypeFromCSRType(eCsrAuthType authType)
122{
123 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700124 switch(authType)
125 {
126 case eCSR_AUTH_TYPE_SHARED_KEY:
127 n = AUTH_SHARED;
128 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700129 case eCSR_AUTH_TYPE_WPA:
130 n = AUTH_WPA_EAP;
131 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700132 case eCSR_AUTH_TYPE_WPA_PSK:
133 n = AUTH_WPA_PSK;
134 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700135 case eCSR_AUTH_TYPE_RSN:
Abhishek Singhae408032014-09-25 17:22:04 +0530136#ifdef WLAN_FEATURE_11W
137 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
138#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700139 n = AUTH_WPA2_EAP;
140 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700141 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700142#ifdef WLAN_FEATURE_11W
143 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
144#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700145 n = AUTH_WPA2_PSK;
146 break;
147#ifdef FEATURE_WLAN_WAPI
148 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
149 n = AUTH_WAPI_CERT;
150 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
152 n = AUTH_WAPI_PSK;
153 break;
154#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700155 default:
156 break;
157 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700158 return (n);
159}
Jeff Johnson295189b2012-06-20 16:38:30 -0700160int diagEncTypeFromCSRType(eCsrEncryptionType encType)
161{
162 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700163 switch(encType)
164 {
165 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
166 case eCSR_ENCRYPT_TYPE_WEP40:
167 n = ENC_MODE_WEP40;
168 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
170 case eCSR_ENCRYPT_TYPE_WEP104:
171 n = ENC_MODE_WEP104;
172 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700173 case eCSR_ENCRYPT_TYPE_TKIP:
174 n = ENC_MODE_TKIP;
175 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700176 case eCSR_ENCRYPT_TYPE_AES:
177 n = ENC_MODE_AES;
178 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700179#ifdef FEATURE_WLAN_WAPI
180 case eCSR_ENCRYPT_TYPE_WPI:
181 n = ENC_MODE_SMS4;
182 break;
183#endif /* FEATURE_WLAN_WAPI */
184 default:
185 break;
186 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700187 return (n);
188}
Jeff Johnson295189b2012-06-20 16:38:30 -0700189#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700190static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
191static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700192static void initConfigParam(tpAniSirGlobal pMac);
193static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
194 eCsrRoamCompleteResult Result, void *Context );
195static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
196 tCsrRoamProfile *pProfile,
197 tANI_BOOLEAN *pfSameIbss );
198static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
199static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700200 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
201static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700202eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
203static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
204eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
205eHalStatus csrRoamClose(tpAniSirGlobal pMac);
206void csrRoamMICErrorTimerHandler(void *pv);
207void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
208tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
209
210static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
211static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
212static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700213eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
214eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
215static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700216static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700217static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700218static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
219eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
220 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
221 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
222 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
223 tANI_U8 *pKeyRsc );
224static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
225 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
226 tCsrRoamProfile *pProfile );
227void csrRoamStatisticsTimerHandler(void *pv);
228void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700229static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
230VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
231 v_U8_t rssiNotification,
232 void * context);
233static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
234void csrRoamVccTrigger(tpAniSirGlobal pMac);
235eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
236/*
237 pStaEntry is no longer invalid upon the return of this function.
238*/
239static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700240static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700241static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700242tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
243 tDblLinkList *pStaList,
244 tCsrStatsClientReqInfo *pStaEntry);
245void csrRoamStatsClientTimerHandler(void *pv);
246tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
247 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
248void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
249 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700250void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700251void csrRoamTlStatsTimerHandler(void *pv);
252void csrRoamPeStatsTimerHandler(void *pv);
253tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
254void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
255tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
256eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
257static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
258static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
259static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
260static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
261 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
262//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
263static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
264void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
265#ifdef FEATURE_WLAN_BTAMP_UT_RF
266void csrRoamJoinRetryTimerHandler(void *pv);
267#endif
Atul Mittalb849d5a2014-07-29 12:08:39 +0530268void limInitOperatingClasses( tHalHandle hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -0700269extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700270extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700271static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700272void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700273
274//Initialize global variables
275static void csrRoamInitGlobals(tpAniSirGlobal pMac)
276{
277 if(pMac)
278 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800279 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
280 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700281 }
282 return;
283}
284
Jeff Johnson295189b2012-06-20 16:38:30 -0700285static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
286{
287 if(pMac)
288 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800289 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700290 }
291 return;
292}
Jeff Johnson295189b2012-06-20 16:38:30 -0700293eHalStatus csrOpen(tpAniSirGlobal pMac)
294{
295 eHalStatus status = eHAL_STATUS_SUCCESS;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530296#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 static uNvTables nvTables;
298 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700299 v_REGDOMAIN_t regId;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530300#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700301 tANI_U32 i;
302
303 do
304 {
305 /* Initialize CSR Roam Globals */
306 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700307 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
308 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
309
310 initConfigParam(pMac);
311 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
312 break;
313 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
314 break;
315 pMac->roam.nextRoamId = 1; //Must not be 0
316 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
317 break;
318 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
319 break;
320 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
321 break;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530322
323#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700324 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
325 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
326 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530327 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
328 WNI_CFG_COUNTRY_CODE_LEN);
329 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700330 }
331 else
332 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800333 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 //hardcoded for now
335 pMac->scan.countryCodeDefault[0] = 'U';
336 pMac->scan.countryCodeDefault[1] = 'S';
337 pMac->scan.countryCodeDefault[2] = 'I';
338 //status = eHAL_STATUS_SUCCESS;
339 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700340 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Kiet Lam6c583332013-10-14 05:37:09 +0530341
342 if (!('0' == pMac->scan.countryCodeDefault[0] &&
343 '0' == pMac->scan.countryCodeDefault[1]))
344 {
345 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
346 &regId, COUNTRY_NV);
347 }
348 else
349 {
350 regId = REGDOMAIN_WORLD;
351 }
Abhishek Singha306a442013-11-07 18:39:01 +0530352 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700353 pMac->scan.domainIdDefault = regId;
354 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530355 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
356 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700357 status = csrInitGetChannels( pMac );
Mihir Shetee1093ba2014-01-21 20:13:32 +0530358#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 }while(0);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530360
Jeff Johnson295189b2012-06-20 16:38:30 -0700361 return (status);
362}
363
Mihir Shetee1093ba2014-01-21 20:13:32 +0530364/* --------------------------------------------------------------------------
365 \fn csrInitChannels
366 \brief This function must be called to initialize CSR channel lists
367 \return eHalStatus
368 ----------------------------------------------------------------------------*/
369eHalStatus csrInitChannels(tpAniSirGlobal pMac)
370{
371 eHalStatus status = eHAL_STATUS_SUCCESS;
372 static uNvTables nvTables;
373 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530374 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530375
376 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
377 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
378 {
379 vos_mem_copy(pMac->scan.countryCodeDefault,
380 nvTables.defaultCountryTable.countryCode,
381 WNI_CFG_COUNTRY_CODE_LEN);
382 }
383 else
384 {
385 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
386 //hardcoded for now
387 pMac->scan.countryCodeDefault[0] = 'U';
388 pMac->scan.countryCodeDefault[1] = 'S';
389 pMac->scan.countryCodeDefault[2] = 'I';
390 }
391 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
392
Mihir Shetee1093ba2014-01-21 20:13:32 +0530393 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
394 pMac->scan.domainIdDefault = regId;
395 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
396 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
397 WNI_CFG_COUNTRY_CODE_LEN);
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530398 vos_mem_copy(pMac->scan.countryCodeElected, pMac->scan.countryCodeDefault,
399 WNI_CFG_COUNTRY_CODE_LEN);
Agarwal Ashishcd9b8e62014-07-21 19:48:24 +0530400 vos_mem_copy(pMac->scan.countryCode11d, pMac->scan.countryCodeDefault,
401 WNI_CFG_COUNTRY_CODE_LEN);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530402 status = csrInitGetChannels( pMac );
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530403 csrClearVotesForCountryInfo(pMac);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530404
405 return status;
406}
407
Mihir Shete04206452014-11-20 17:50:58 +0530408#ifdef CONFIG_ENABLE_LINUX_REG
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530409eHalStatus csrInitChannelsForCC(tpAniSirGlobal pMac, driver_load_type init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530410{
411 eHalStatus status = eHAL_STATUS_SUCCESS;
412 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530413 tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN];
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530414
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530415 /* In case of driver load ; driver need to get channel
416 * list with default Countrycode.
417 * In case of SSR; driver need to get channel list
418 * with old country code. 0 is for init and
419 * 1 is for reinit
420 */
421 switch (init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530422 {
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530423 case INIT:
424 vos_mem_copy(cc, pMac->scan.countryCodeDefault,
425 WNI_CFG_COUNTRY_CODE_LEN);
426 if (!('0' == cc[0] &&
427 '0' == cc[1]))
428 {
429 csrGetRegulatoryDomainForCountry(pMac, cc,
430 &regId, COUNTRY_NV);
431 }
432 else
433 {
434 return status;
435 }
436 pMac->scan.domainIdDefault = regId;
437 break;
438 case REINIT:
439 vos_getCurrentCountryCode(&cc[0]);
440 status = csrGetRegulatoryDomainForCountry(pMac,
441 cc, &regId, COUNTRY_QUERY);
442 break;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530443 }
444 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530445 pMac->scan.domainIdCurrent = regId;
446 vos_mem_copy(pMac->scan.countryCodeCurrent, cc,
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530447 WNI_CFG_COUNTRY_CODE_LEN);
448 status = csrInitGetChannels( pMac );
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530449
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530450 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
451 FL("Current Country is %c%c "), pMac->scan.countryCodeCurrent[0],
452 pMac->scan.countryCodeCurrent[1]);
453
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530454 /* reset info based on new cc, and we are done */
455 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
456 csrScanFilterResults(pMac);
457
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530458 return status;
459}
Mihir Shete04206452014-11-20 17:50:58 +0530460#endif
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530461
Jeff Johnson295189b2012-06-20 16:38:30 -0700462eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
463{
464 eHalStatus status = eHAL_STATUS_SUCCESS;
465 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
466 v_REGDOMAIN_t regId;
467 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 if(NULL == apCntryCode)
469 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530470 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 return eHAL_STATUS_FAILURE;
472 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530473 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700474 /* To get correct Regulatory domain from NV table
475 * 2 character Country code should be used
476 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700477 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
478/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700479 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700480
481 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
482 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800483 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700484 return eHAL_STATUS_FAILURE;
485 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700486*/
Kiet Lam6c583332013-10-14 05:37:09 +0530487 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
488 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 if (status != eHAL_STATUS_SUCCESS)
490 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700491 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 return status;
493 }
Abhishek Singha306a442013-11-07 18:39:01 +0530494 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700495 if (status != eHAL_STATUS_SUCCESS)
496 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700497 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700498 return status;
499 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700500 pMac->scan.domainIdDefault = regId;
501 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530503 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
504
Jeff Johnson295189b2012-06-20 16:38:30 -0700505 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530506 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
507
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 /* If 2 bytes country code, 3rd byte must be filled with space */
509 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
510 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530511 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700512 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530513 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
514 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700515 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700516 return status;
517}
Jeff Johnson295189b2012-06-20 16:38:30 -0700518eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
519{
520 eHalStatus status = eHAL_STATUS_SUCCESS;
521 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
522 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530523 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
524 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
526 {
527 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
528 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
529 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
530 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
531 }
532 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
533
534 return status;
535}
Jeff Johnson295189b2012-06-20 16:38:30 -0700536eHalStatus csrClose(tpAniSirGlobal pMac)
537{
538 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800539
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 csrRoamClose(pMac);
541 csrScanClose(pMac);
542 csrLLClose(&pMac->roam.statsClientReqList);
543 csrLLClose(&pMac->roam.peStatsReqList);
544 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 /* DeInit Globals */
546 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 return (status);
548}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530549
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800550eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530551{
552 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800553 tCsrScanStruct *pScan = &pMac->scan;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530554 tANI_U32 numChan = 0;
555 tANI_U32 bufLen ;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530556 vos_msg_t msg;
557 tANI_U8 i;
558
Atul Mittalb849d5a2014-07-29 12:08:39 +0530559 limInitOperatingClasses((tHalHandle)pMac);
Agarwal Ashish738843c2014-09-25 12:27:56 +0530560 numChan = sizeof(pMac->roam.validChannelList);
561
562 if ( !HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
563 (tANI_U8 *)pMac->roam.validChannelList, &numChan)))
564 {
565 smsLog( pMac, LOGE, "Failed to get Channel list from CFG");
566 return eHAL_STATUS_FAILED_ALLOC;
567 }
568
569 bufLen = sizeof(tSirUpdateChanList) +
570 (sizeof(tSirUpdateChanParam) * (numChan - 1));
571
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530572 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
573 if (!pChanList)
574 {
575 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
576 "Failed to allocate memory for tSirUpdateChanList");
577 return eHAL_STATUS_FAILED_ALLOC;
578 }
579
580 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
581 msg.reserved = 0;
582 msg.bodyptr = pChanList;
583 pChanList->numChan = numChan;
584 for (i = 0; i < pChanList->numChan; i++)
585 {
Agarwal Ashish738843c2014-09-25 12:27:56 +0530586 pChanList->chanParam[i].chanId = pMac->roam.validChannelList[i];
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800587 pChanList->chanParam[i].pwr = cfgGetRegulatoryMaxTransmitPower(pMac,
588 pScan->defaultPowerTable[i].chanId);
589 if (vos_nv_getChannelEnabledState(pChanList->chanParam[i].chanId) ==
590 NV_CHANNEL_DFS)
591 pChanList->chanParam[i].dfsSet = VOS_TRUE;
592 else
593 pChanList->chanParam[i].dfsSet = VOS_FALSE;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530594 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
595 "%s Supported Channel: %d\n", __func__, pChanList->chanParam[i].chanId);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530596 }
597
598 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
599 {
600 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
601 "%s: Failed to post msg to WDA", __func__);
602 vos_mem_free(pChanList);
603 return eHAL_STATUS_FAILURE;
604 }
605
606 return eHAL_STATUS_SUCCESS;
607}
608
Jeff Johnson295189b2012-06-20 16:38:30 -0700609eHalStatus csrStart(tpAniSirGlobal pMac)
610{
611 eHalStatus status = eHAL_STATUS_SUCCESS;
612 tANI_U32 i;
613
614 do
615 {
616 //save the global vos context
617 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
618 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
619 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
620
621 status = csrRoamStart(pMac);
622 if(!HAL_STATUS_SUCCESS(status)) break;
623 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
624 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
625 if(!HAL_STATUS_SUCCESS(status)) break;
626 pMac->roam.sPendingCommands = 0;
627 csrScanEnable(pMac);
628#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
629 status = csrNeighborRoamInit(pMac);
630#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
631 pMac->roam.tlStatsReqInfo.numClient = 0;
632 pMac->roam.tlStatsReqInfo.periodicity = 0;
633 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
634 //init the link quality indication also
635 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
636 if(!HAL_STATUS_SUCCESS(status))
637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800638 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 break;
640 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530641
Jeff Johnson295189b2012-06-20 16:38:30 -0700642 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700643#if defined(ANI_LOGDUMP)
644 csrDumpInit(pMac);
645#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700646 return (status);
647}
648
Kiet Lama72a2322013-11-15 11:18:11 +0530649eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700650{
651 tANI_U32 sessionId;
652 tANI_U32 i;
653
654 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
655 {
656 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
657 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 csrScanDisable(pMac);
659 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
660 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700661 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
662
663#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
664 csrNeighborRoamClose(pMac);
665#endif
666 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700667 // deregister from PMC since we register during csrStart()
668 // (ignore status since there is nothing we can do if it fails)
669 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700670 //Reset the domain back to the deault
671 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800672 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700673
674 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
675 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530676 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700677 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
678 }
679
Kiet Lama72a2322013-11-15 11:18:11 +0530680#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
681 /* When HAL resets all the context information
682 * in HAL is lost, so we might need to send the
683 * scan offload request again when it comes
684 * out of reset for scan offload to be functional
685 */
686 if (HAL_STOP_TYPE_SYS_RESET == stopType)
687 {
688 bRoamScanOffloadStarted = VOS_FALSE;
689 }
690#endif
691
Jeff Johnson295189b2012-06-20 16:38:30 -0700692 return (eHAL_STATUS_SUCCESS);
693}
694
Jeff Johnson295189b2012-06-20 16:38:30 -0700695eHalStatus csrReady(tpAniSirGlobal pMac)
696{
697 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 csrScanGetSupportedChannels( pMac );
699 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
700 //use it to init the background scan list
701 csrInitBGScanChannelList(pMac);
702 /* HDD issues the init scan */
703 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800704 /* If the gScanAgingTime is set to '0' then scan results aging timeout
705 based on timer feature is not enabled*/
706 if(0 != pMac->scan.scanResultCfgAgingTime )
707 {
708 csrScanStartResultCfgAgingTimer(pMac);
709 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 //Store the AC weights in TL for later use
711 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700712 status = csrInitChannelList( pMac );
713 if ( ! HAL_STATUS_SUCCESS( status ) )
714 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800715 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 status );
717 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 return (status);
719}
Jeff Johnson295189b2012-06-20 16:38:30 -0700720void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
721{
722 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700723 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
724 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
725}
Jeff Johnson295189b2012-06-20 16:38:30 -0700726void csrSetGlobalCfgs( tpAniSirGlobal pMac )
727{
Jeff Johnsone7245742012-09-05 17:12:55 -0700728
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
730 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
731 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
732 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
733 NULL, eANI_BOOLEAN_FALSE);
734 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700735 /* For now we will just use the 5GHz CB mode ini parameter to decide whether CB supported or not in Probes when there is no session
736 * Once session is established we will use the session related params stored in PE session for CB mode
737 */
738 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700739 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
740
741 //Update the operating mode to configured value during initialization,
742 //So that client can advertise full capabilities in Probe request frame.
743 csrSetDefaultDot11Mode( pMac );
744}
745
Jeff Johnson295189b2012-06-20 16:38:30 -0700746eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
747{
748 eHalStatus status = eHAL_STATUS_SUCCESS;
749 tANI_U32 i;
750 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 do
752 {
753 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
754 {
755 pSession = CSR_GET_SESSION( pMac, i );
756 pSession->roamingTimerInfo.pMac = pMac;
757 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
758 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700759 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
760 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530761 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
762 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530764 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800766 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700767 break;
768 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530769 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
770 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
771 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800773 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 return eHAL_STATUS_FAILURE;
775 }
776 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700777 return (status);
778}
779
Jeff Johnson295189b2012-06-20 16:38:30 -0700780eHalStatus csrRoamClose(tpAniSirGlobal pMac)
781{
782 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700783 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
784 {
785 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
786 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530787 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
788 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
789 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
790 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700791 return (eHAL_STATUS_SUCCESS);
792}
793
Jeff Johnson295189b2012-06-20 16:38:30 -0700794eHalStatus csrRoamStart(tpAniSirGlobal pMac)
795{
796 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 return (eHAL_STATUS_SUCCESS);
798}
799
Jeff Johnson295189b2012-06-20 16:38:30 -0700800void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
801{
802 csrRoamStopRoamingTimer(pMac, sessionId);
803 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
804 csrRoamDeregStatisticsReq(pMac);
805}
Jeff Johnson295189b2012-06-20 16:38:30 -0700806eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
807{
808 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800809 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700810 {
811 status = eHAL_STATUS_SUCCESS;
812 *pState = pMac->roam.roamSession[sessionId].connectState;
813 }
814 return (status);
815}
816
Jeff Johnson295189b2012-06-20 16:38:30 -0700817eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
818{
819 eHalStatus status = eHAL_STATUS_FAILURE;
820 tANI_U32 size = 0;
821 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700822
823 if(!pSession)
824 {
825 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
826 return eHAL_STATUS_FAILURE;
827 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700828
829 if(pProfile)
830 {
831 if(pSession->pConnectBssDesc)
832 {
833 do
834 {
835 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
836 if(size)
837 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530838 pProfile->pBssDesc = vos_mem_malloc(size);
839 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530841 vos_mem_copy(pProfile->pBssDesc,
842 pSession->pConnectBssDesc, size);
843 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700844 }
845 else
846 break;
847 }
848 else
849 {
850 pProfile->pBssDesc = NULL;
851 }
852 pProfile->AuthType = pSession->connectedProfile.AuthType;
853 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
854 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
855 pProfile->BSSType = pSession->connectedProfile.BSSType;
856 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
857 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530858 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
859 sizeof(tCsrBssid));
860 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
861 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700862#ifdef WLAN_FEATURE_VOWIFI_11R
863 if (pSession->connectedProfile.MDID.mdiePresent)
864 {
865 pProfile->MDID.mdiePresent = 1;
866 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
867 }
868 else
869 {
870 pProfile->MDID.mdiePresent = 0;
871 pProfile->MDID.mobilityDomain = 0;
872 }
873#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800874#ifdef FEATURE_WLAN_ESE
875 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
876 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800878 vos_mem_copy (pProfile->eseCckmInfo.krk,
879 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530880 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800881 pProfile->eseCckmInfo.reassoc_req_num=
882 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
883 pProfile->eseCckmInfo.krk_plumbed =
884 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700885 }
886#endif
887 }while(0);
888 }
889 }
890
891 return (status);
892}
893
Jeff Johnson295189b2012-06-20 16:38:30 -0700894eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
895{
896 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700897
898 if((csrIsConnStateConnected(pMac, sessionId)) ||
899 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 {
901 if(pProfile)
902 {
903 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
904 }
905 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700906 return (status);
907}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700908
Jeff Johnson295189b2012-06-20 16:38:30 -0700909eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
910{
911 eHalStatus status = eHAL_STATUS_SUCCESS;
912
Kiet Lam64c1b492013-07-12 13:56:44 +0530913 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530915 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530917 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700918 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530919 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700920 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530921 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
922
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
924 return (status);
925}
926
Jeff Johnson295189b2012-06-20 16:38:30 -0700927static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
928{
929 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700930 if( pConnectedInfo->pbFrames )
931 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530932 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700933 pConnectedInfo->pbFrames = NULL;
934 }
935 pConnectedInfo->nBeaconLength = 0;
936 pConnectedInfo->nAssocReqLength = 0;
937 pConnectedInfo->nAssocRspLength = 0;
938 pConnectedInfo->staId = 0;
939#ifdef WLAN_FEATURE_VOWIFI_11R
940 pConnectedInfo->nRICRspLength = 0;
941#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800942#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 pConnectedInfo->nTspecIeLength = 0;
944#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 return ( status );
946}
947
Jeff Johnson295189b2012-06-20 16:38:30 -0700948
949
Jeff Johnsone7245742012-09-05 17:12:55 -0700950
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700951void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
952{
953 csrReinitPreauthCmd(pMac, pCommand);
954 csrReleaseCommand( pMac, pCommand );
955}
956
Jeff Johnson295189b2012-06-20 16:38:30 -0700957void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
958{
959 csrReinitRoamCmd(pMac, pCommand);
960 csrReleaseCommand( pMac, pCommand );
961}
962
Jeff Johnson295189b2012-06-20 16:38:30 -0700963void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
964{
965 csrReinitScanCmd(pMac, pCommand);
966 csrReleaseCommand( pMac, pCommand );
967}
968
Jeff Johnson295189b2012-06-20 16:38:30 -0700969void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
970{
971 csrReinitWmStatusChangeCmd(pMac, pCommand);
972 csrReleaseCommand( pMac, pCommand );
973}
974
Jeff Johnson295189b2012-06-20 16:38:30 -0700975void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
976{
Kiet Lam64c1b492013-07-12 13:56:44 +0530977 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700978}
979
Jeff Johnson295189b2012-06-20 16:38:30 -0700980void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
981{
Kiet Lam64c1b492013-07-12 13:56:44 +0530982 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700983}
984
Jeff Johnson295189b2012-06-20 16:38:30 -0700985void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
986{
987 csrReinitSetKeyCmd(pMac, pCommand);
988 csrReleaseCommand( pMac, pCommand );
989}
Jeff Johnson295189b2012-06-20 16:38:30 -0700990void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
991{
992 csrReinitRemoveKeyCmd(pMac, pCommand);
993 csrReleaseCommand( pMac, pCommand );
994}
Jeff Johnson295189b2012-06-20 16:38:30 -0700995void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
996{
997
998 if( eSmeCsrCommandMask & pCommand->command )
999 {
1000 switch (pCommand->command)
1001 {
1002 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -08001003 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -08001004 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
1005 __func__, pCommand->u.scanCmd.reason,
1006 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 if (NULL != pCommand->u.scanCmd.callback)
1008 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001009 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001010 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
1011 }
1012 csrReleaseCommandScan( pMac, pCommand );
1013 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 case eSmeCommandRoam:
1015 csrReleaseCommandRoam( pMac, pCommand );
1016 break;
1017
1018 case eSmeCommandWmStatusChange:
1019 csrReleaseCommandWmStatusChange( pMac, pCommand );
1020 break;
1021
1022 case eSmeCommandSetKey:
1023 csrReleaseCommandSetKey( pMac, pCommand );
1024 break;
1025
1026 case eSmeCommandRemoveKey:
1027 csrReleaseCommandRemoveKey( pMac, pCommand );
1028 break;
1029
1030 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001031 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -07001032 csrReleaseCommand( pMac, pCommand );
1033 break;
1034 }
1035 }
1036}
1037
Jeff Johnson295189b2012-06-20 16:38:30 -07001038void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
1039{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301040 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1041 macTraceGetcsrRoamSubState(NewSubstate),
1042 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001043
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1045 {
1046 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001047 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 pMac->roam.curSubState[sessionId] = NewSubstate;
1049}
1050
Jeff Johnson295189b2012-06-20 16:38:30 -07001051eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1052{
1053 eCsrRoamState PreviousState;
1054
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301055 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1056 macTraceGetcsrRoamState(NewRoamState),
1057 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001058
1059 PreviousState = pMac->roam.curState[sessionId];
1060
1061 if ( NewRoamState != pMac->roam.curState[sessionId] )
1062 {
1063 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1064 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1065 {
1066 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1067 }
1068
1069 pMac->roam.curState[sessionId] = NewRoamState;
1070 }
1071 return( PreviousState );
1072}
1073
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001074void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001075{
1076 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 if(catOffset)
1078 {
1079 pMac->roam.configParam.bCatRssiOffset = catOffset;
1080 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1081 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001082 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)bestApRssi - pMac->roam.configParam.nSelect5GHzMargin - (int)(i * catOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001083 }
1084 }
1085}
1086
Jeff Johnson295189b2012-06-20 16:38:30 -07001087static void initConfigParam(tpAniSirGlobal pMac)
1088{
1089 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001090 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301091 pMac->roam.configParam.channelBondingMode24GHz =
1092 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1093 pMac->roam.configParam.channelBondingMode5GHz =
1094 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1096 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1097 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1098 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1099 pMac->roam.configParam.HeartbeatThresh24 = 40;
1100 pMac->roam.configParam.HeartbeatThresh50 = 40;
1101 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1102 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1103 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001104 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001105 pMac->roam.configParam.RTSThreshold = 2346;
1106 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1107 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1108 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1109 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1110 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1111 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1112 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1113 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1114 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1115 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1116 {
1117 pMac->roam.configParam.BssPreferValue[i] = i;
1118 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001119 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001120 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1121 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1122 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1124 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05301125 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001126 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1127 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1128 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1129 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001130 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1131 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001132 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001133#ifdef WLAN_AP_STA_CONCURRENCY
1134 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1135 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1136 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1137 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1138 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001139 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1140 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001141#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001142 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1143 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1144 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1145 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001146#ifdef WLAN_FEATURE_VOWIFI_11R
1147 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1148#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001149#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1150 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1151 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1152 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1153 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1154 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1155 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1156 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1157 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1158 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1159 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1160 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001161 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Mukul Sharma20aa6582014-08-07 21:36:12 +05301162 pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001163#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001164#ifdef WLAN_FEATURE_11AC
1165 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1166#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001167
1168 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1169 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001170
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001171 //Remove this code once SLM_Sessionization is supported
1172 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001173 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001174
Jeff Johnsone7245742012-09-05 17:12:55 -07001175}
Jeff Johnson295189b2012-06-20 16:38:30 -07001176eCsrBand csrGetCurrentBand(tHalHandle hHal)
1177{
1178 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1179 return pMac->roam.configParam.bandCapability;
1180}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001181
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001182
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001183#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001184/*
1185 This function flushes the roam scan cache
1186*/
1187eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1188{
1189 eHalStatus status = eHAL_STATUS_SUCCESS;
1190 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1191
1192 /* Free up the memory first (if required) */
1193 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1194 {
1195 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1196 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1197 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1198 }
1199 return status;
1200}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001201#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001202
1203
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001204#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001205/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001206 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001207*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001208eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001209{
1210 eHalStatus status = eHAL_STATUS_SUCCESS;
1211 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1212
1213 /* Free up the memory first (if required) */
1214 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1215 {
1216 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1217 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001218 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001219 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001220 return status;
1221}
1222
1223
1224
1225/*
1226 This function flushes the roam scan cache and creates fresh cache
1227 based on the input channel list
1228*/
1229eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1230 const tANI_U8 *pChannelList,
1231 const tANI_U8 numChannels)
1232{
1233 eHalStatus status = eHAL_STATUS_SUCCESS;
1234 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1235
Srinivas Girigowdade697412013-02-14 16:31:48 -08001236 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1237
1238 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1239 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1240
1241 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1242 {
1243 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1244 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1245 return eHAL_STATUS_RESOURCES;
1246 }
1247
1248 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301249 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1250 pChannelList,
1251 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001252 return status;
1253}
1254
1255/* This function modifies the bgscan channel list set via config ini or
1256 runtime, whenever the band changes.
1257 if the band is auto, then no operation is performed on the channel list
1258 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1259 if the band is 5G, then make sure channel list contains only 5G valid channels
1260*/
1261eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1262 eCsrBand eBand)
1263{
1264 eHalStatus status = eHAL_STATUS_SUCCESS;
1265 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1266 tANI_U8 outNumChannels = 0;
1267 tANI_U8 inNumChannels = 0;
1268 tANI_U8 *inPtr = NULL;
1269 tANI_U8 i = 0;
1270 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1271
1272 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1273
1274 {
1275 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1276 "No update required for channel list "
1277 "either cfg.ini channel list is not set up or "
1278 "auto band (Band %d)", eBand);
1279 return status;
1280 }
1281
1282 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1283 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1284 if (eCSR_BAND_24 == eBand)
1285 {
1286 for (i = 0; i < inNumChannels; i++)
1287 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001288 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001289 {
1290 ChannelList[outNumChannels++] = inPtr[i];
1291 }
1292 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001293 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001294 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001295 }
1296 else if (eCSR_BAND_5G == eBand)
1297 {
1298 for (i = 0; i < inNumChannels; i++)
1299 {
1300 /* Add 5G Non-DFS channel */
1301 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001302 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001303 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1304 {
1305 ChannelList[outNumChannels++] = inPtr[i];
1306 }
1307 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001308 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001309 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001310 }
1311 else if (eCSR_BAND_ALL == eBand)
1312 {
1313 for (i = 0; i < inNumChannels; i++)
1314 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001315 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001316 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1317 {
1318 ChannelList[outNumChannels++] = inPtr[i];
1319 }
1320 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001321 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001322 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001323 }
1324 else
1325 {
1326 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1327 "Invalid band, No operation carried out (Band %d)", eBand);
1328 status = eHAL_STATUS_INVALID_PARAMETER;
1329 }
1330
1331 return status;
1332}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001333#endif
1334
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001335#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001336/* This function modifies the roam scan channel list as per AP neighbor
1337 report; AP neighbor report may be empty or may include only other AP
1338 channels; in any case, we merge the channel list with the learned occupied
1339 channels list.
1340 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1341 if the band is 5G, then make sure channel list contains only 5G valid channels
1342*/
1343eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1344 tANI_U8 *pChannelList,
1345 tANI_U8 numChannels,
1346 const eCsrBand eBand)
1347{
1348 eHalStatus status = eHAL_STATUS_SUCCESS;
1349 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1350 tANI_U8 outNumChannels = 0;
1351 tANI_U8 inNumChannels = numChannels;
1352 tANI_U8 *inPtr = pChannelList;
1353 tANI_U8 i = 0;
1354 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1355 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1356 tANI_U8 mergedOutputNumOfChannels = 0;
1357 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1358
1359 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1360 * report Channels. This increases the chances of the DUT to get a candidate AP while
1361 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1362 if (pMac->scan.occupiedChannels.numChannels)
1363 {
1364 csrNeighborRoamMergeChannelLists(pMac,
1365 &pMac->scan.occupiedChannels.channelList[0],
1366 pMac->scan.occupiedChannels.numChannels,
1367 inPtr,
1368 inNumChannels,
1369 &mergedOutputNumOfChannels);
1370 inNumChannels = mergedOutputNumOfChannels;
1371 }
1372
1373 if (eCSR_BAND_24 == eBand)
1374 {
1375 for (i = 0; i < inNumChannels; i++)
1376 {
1377 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1378 {
1379 ChannelList[outNumChannels++] = inPtr[i];
1380 }
1381 }
1382 }
1383 else if (eCSR_BAND_5G == eBand)
1384 {
1385 for (i = 0; i < inNumChannels; i++)
1386 {
1387 /* Add 5G Non-DFS channel */
1388 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1389 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1390 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1391 {
1392 ChannelList[outNumChannels++] = inPtr[i];
1393 }
1394 }
1395 }
1396 else if (eCSR_BAND_ALL == eBand)
1397 {
1398 for (i = 0; i < inNumChannels; i++)
1399 {
1400 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1401 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1402 {
1403 ChannelList[outNumChannels++] = inPtr[i];
1404 }
1405 }
1406 }
1407 else
1408 {
1409 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1410 "Invalid band, No operation carried out (Band %d)", eBand);
1411 return eHAL_STATUS_INVALID_PARAMETER;
1412 }
1413
1414 /* if roaming within band is enabled, then select only the
1415 in band channels .
1416 This is required only if the band capability is set to ALL,
1417 E.g., if band capability is only 2.4G then all the channels in the
1418 list are already filtered for 2.4G channels, hence ignore this check*/
1419
1420 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1421 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05301422 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001423 pMac,
1424 ChannelList,
1425 outNumChannels,
1426 tmpChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05301427 &outNumChannels,
1428 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Kiet Lamf2f201e2013-11-16 21:24:16 +05301429 vos_mem_copy(ChannelList,
1430 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001431 }
1432
1433 /* Prepare final roam scan channel list */
1434 if(outNumChannels)
1435 {
1436 /* Clear the channel list first */
1437 if (NULL != currChannelListInfo->ChannelList)
1438 {
1439 vos_mem_free(currChannelListInfo->ChannelList);
1440 currChannelListInfo->ChannelList = NULL;
1441 currChannelListInfo->numOfChannels = 0;
1442 }
1443
1444 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1445 if (NULL == currChannelListInfo->ChannelList)
1446 {
1447 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1448 "Failed to allocate memory for roam scan channel list");
1449 currChannelListInfo->numOfChannels = 0;
1450 return VOS_STATUS_E_RESOURCES;
1451 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301452 vos_mem_copy(currChannelListInfo->ChannelList,
1453 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001454 }
1455 return status;
1456}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001457#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001458
Jeff Johnson295189b2012-06-20 16:38:30 -07001459eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1460{
1461 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1462 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001463 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1464 (eBand == eCSR_BAND_24))
1465 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001466 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001467 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001468 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001469 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001470 pMac->roam.configParam.uCfgDot11Mode, eBand);
1471 return eHAL_STATUS_INVALID_PARAMETER;
1472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001473 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1474 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1475 (eBand == eCSR_BAND_5G))
1476 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001477 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001478 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001479 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001480 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001481 pMac->roam.configParam.uCfgDot11Mode, eBand);
1482 return eHAL_STATUS_INVALID_PARAMETER;
1483 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001484 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001485 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001486 pMac->roam.configParam.eBand = eBand;
1487 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001488 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001489#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001490 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1491 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001492#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 status = csrInitGetChannels( pMac );
1494 if (eHAL_STATUS_SUCCESS == status)
1495 csrInitChannelList( hHal );
1496 return status;
1497}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001498
1499
Jeff Johnsone7245742012-09-05 17:12:55 -07001500/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1501 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1502 * Ideally we should have kept the ini value and enum value same and representing the same
1503 * cb values as in 11n standard i.e.
1504 * Set to 1 (SCA) if the secondary channel is above the primary channel
1505 * Set to 3 (SCB) if the secondary channel is below the primary channel
1506 * Set to 0 (SCN) if no secondary channel is present
1507 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1508 * 0 - secondary none
1509 * 1 - secondary LOW
1510 * 2 - secondary HIGH
1511 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1512 * The enum values are as follows:
1513 * PHY_SINGLE_CHANNEL_CENTERED = 0
1514 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1515 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1516 */
1517ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1518{
1519
1520 ePhyChanBondState phyCbState;
1521 switch (cbIniValue) {
1522 // secondary none
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301523 case eCSR_INI_SINGLE_CHANNEL_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001524 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1525 break;
1526 // secondary LOW
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301527 case eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001528 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1529 break;
1530 // secondary HIGH
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301531 case eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY:
Jeff Johnsone7245742012-09-05 17:12:55 -07001532 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1533 break;
1534#ifdef WLAN_FEATURE_11AC
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301535 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1536 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001537 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301538 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Jeff Johnsone7245742012-09-05 17:12:55 -07001539 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1540 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301541 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1542 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
1543 break;
1544 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001545 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1546 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301547 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Jeff Johnsone7245742012-09-05 17:12:55 -07001548 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301549 break;
1550 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001551 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1552 break;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301553 case eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Jeff Johnsone7245742012-09-05 17:12:55 -07001554 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301555 break;
1556#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001557 default:
1558 // If an invalid value is passed, disable CHANNEL BONDING
1559 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1560 break;
1561 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301562
Jeff Johnsone7245742012-09-05 17:12:55 -07001563 return phyCbState;
1564}
1565
1566v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1567{
1568
1569 v_U32_t cbIniValue;
1570 switch (phyCbState) {
1571 // secondary none
1572 case PHY_SINGLE_CHANNEL_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301573 cbIniValue = eCSR_INI_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001574 break;
1575 // secondary LOW
1576 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301577 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_HIGH_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001578 break;
1579 // secondary HIGH
1580 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301581 cbIniValue = eCSR_INI_DOUBLE_CHANNEL_LOW_PRIMARY;
Jeff Johnsone7245742012-09-05 17:12:55 -07001582 break;
1583#ifdef WLAN_FEATURE_11AC
1584 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301585 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001586 break;
1587 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301588 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001589 break;
1590 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301591 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -07001592 break;
1593 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301594 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001595 break;
1596 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301597 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
Jeff Johnsone7245742012-09-05 17:12:55 -07001598 break;
1599 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301600 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001601 break;
1602 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301603 cbIniValue = eCSR_INI_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
Jeff Johnsone7245742012-09-05 17:12:55 -07001604 break;
1605#endif
1606 default:
1607 // return some invalid value
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301608 cbIniValue = eCSR_INI_CHANNEL_BONDING_STATE_MAX;
Jeff Johnsone7245742012-09-05 17:12:55 -07001609 break;
1610 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301611
Jeff Johnsone7245742012-09-05 17:12:55 -07001612 return cbIniValue;
1613}
Jeff Johnson295189b2012-06-20 16:38:30 -07001614
1615eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1616{
1617 eHalStatus status = eHAL_STATUS_SUCCESS;
1618
1619 if(pParam)
1620 {
1621 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1622 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1623 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1624 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1625 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1626 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1627
1628 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001629 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1630
Jeff Johnsone7245742012-09-05 17:12:55 -07001631 /* channelBondingMode5GHz plays a dual role right now
1632 * INFRA STA will use this non zero value as CB enabled and SOFTAP will use this non-zero value to determine the secondary channel offset
1633 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1634 */
1635 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1636 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001637 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001638 }
1639 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1640 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1641 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001642 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001643 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301644#ifdef WLAN_FEATURE_AP_HT40_24G
1645 pMac->roam.configParam.channelBondingAPMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingAPMode24GHz);
1646#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001647 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1649 pMac->roam.configParam.phyMode = pParam->phyMode;
1650 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1651 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1652 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1653 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1654 pMac->roam.configParam.TxRate = pParam->TxRate;
1655 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1656 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1657 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1658 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1659 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001660 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001661 //if HDD passed down non zero values then only update,
1662 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301663 if (pParam->nInitialDwellTime)
1664 {
1665 pMac->roam.configParam.nInitialDwellTime =
1666 pParam->nInitialDwellTime;
1667 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001668 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 {
1670 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301671 cfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1672 pParam->nActiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001674 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001675 {
1676 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301677 cfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1678 pParam->nActiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001679 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001680 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001681 {
1682 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301683 cfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1684 pParam->nPassiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001685 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001686 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001687 {
1688 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301689 cfgSetInt(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1690 pParam->nPassiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001691 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001692 if (pParam->nActiveMaxChnTimeBtc)
1693 {
1694 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1695 }
1696 if (pParam->nActiveMinChnTimeBtc)
1697 {
1698 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1699 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001700#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001701 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001702 {
1703 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1704 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001705 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001706 {
1707 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1708 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001709 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001710 {
1711 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1712 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001713 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001714 {
1715 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1716 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001717 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001718 {
1719 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1720 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001721 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001722 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001723 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1724 }
1725 if (pParam->nNumP2PChanCombinedConc)
1726 {
1727 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001728 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001729#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001730 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001731 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001732 {
1733 //Change the unit from second to microsecond
1734 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001735 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1736 {
1737 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1738 }
1739 else
1740 {
1741 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1742 }
1743 }
1744 else
1745 {
1746 pMac->roam.configParam.impsSleepTime = 0;
1747 }
1748 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001749 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1750 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001751 //if HDD passed down non zero values for age params, then only update,
1752 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001753 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 {
1755 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001757 if(pParam->scanAgeTimeNCNPS)
1758 {
1759 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1760 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 if(pParam->scanAgeTimeNCPS)
1762 {
1763 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1764 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001765 if(pParam->scanAgeTimeCNPS)
1766 {
1767 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1768 }
1769 if(pParam->scanAgeTimeCPS)
1770 {
1771 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1772 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301773 if (pParam->initialScanSkipDFSCh)
1774 {
1775 pMac->roam.configParam.initialScanSkipDFSCh =
1776 pParam->initialScanSkipDFSCh;
1777 }
1778
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001779 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001780 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1781 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1782 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1783 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1784 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001785 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1786 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001787 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1788 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1789 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1790 //Assign this before calling CsrInit11dInfo
1791 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001792 if( csrIs11dSupported( pMac ) )
1793 {
1794 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1795 }
1796 else
1797 {
1798 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1799 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001800
1801 /* Initialize the power + channel information if 11h is enabled.
1802 If 11d is enabled this information has already been initialized */
1803 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1804 {
1805 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1806 }
1807
1808
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301809#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301810 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1811 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001812 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001813#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001814#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001815 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001816 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001817 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001818 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001819 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001820 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001821 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001822 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001823 pMac->roam.configParam.nProbes = pParam->nProbes;
1824 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001825#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001826#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1827 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001828 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001829#endif
1830#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001831 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001832 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001833#endif
1834
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001835#ifdef FEATURE_WLAN_ESE
1836 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001837#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001838#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301839 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1840 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001841 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1842 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1843 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1844 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1845 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1846 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1847 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1848 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Mukul Sharma20aa6582014-08-07 21:36:12 +05301849 smsLog( pMac, LOG1, "nNeighborInitialForcedRoamTo5GhEnable = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001850 {
1851 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001852 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 -07001853 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1854 {
1855 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1856 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 }
1858#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001859 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1860 pMac->scan.fValidateList = pParam->fValidateList;
1861 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1862 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001863 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001864 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001865 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
Peng Xu2446a892014-09-05 17:21:18 +05301866 pMac->scan.scanBandPreference = pParam->scanBandPreference;
Jeff Johnsone7245742012-09-05 17:12:55 -07001867 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1868 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1869 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1870 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1871 * single session
1872 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001873 //Remove this code once SLM_Sessionization is supported
1874 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001875 pMac->roam.configParam.doBMPSWorkaround = 0;
1876
Jeff Johnsone7245742012-09-05 17:12:55 -07001877#ifdef WLAN_FEATURE_11AC
1878 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001879 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001880 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001881 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301882 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1883 if ( pParam->enableTxBF )
1884 pMac->roam.configParam.txMuBformee= pParam->enableMuBformee;
1885 else
1886 pMac->roam.configParam.txMuBformee= 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001887#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001888 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001889
1890 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001891 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001892 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1893 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301894 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05301895 pMac->roam.configParam.sendDeauthBeforeCon = pParam->sendDeauthBeforeCon;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301896#ifdef WLAN_FEATURE_AP_HT40_24G
1897 pMac->roam.configParam.apHT40_24GEnabled = pParam->apHT40_24GEnabled;
1898#endif
1899
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 }
1901
1902 return status;
1903}
1904
Jeff Johnson295189b2012-06-20 16:38:30 -07001905eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1906{
1907 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001908 if(pParam)
1909 {
1910 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1911 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1912 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1913 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1914 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1915 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001916 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05301917#ifdef WLAN_FEATURE_AP_HT40_24G
1918 pParam->channelBondingAPMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingAPMode24GHz);
1919#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001920 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001921 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1922 pParam->phyMode = pMac->roam.configParam.phyMode;
1923 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1924 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1925 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1926 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1927 pParam->TxRate = pMac->roam.configParam.TxRate;
1928 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1929 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1930 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1931 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1932 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001933 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1934 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1935 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1936 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001937 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1938 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1939 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001940#ifdef WLAN_AP_STA_CONCURRENCY
1941 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1942 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1943 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1944 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1945 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001946 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1947 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001948#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001949 //Change the unit from microsecond to second
1950 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1951 pParam->eBand = pMac->roam.configParam.eBand;
1952 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1953 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1954 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1955 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1956 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1957 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1958 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1959 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1960 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1961 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1962 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1963 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1964 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1966 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1967 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1968 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001969 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1970 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1971 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1972 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1973 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001974 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001975 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001976 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001977 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Peng Xu2446a892014-09-05 17:21:18 +05301978 pParam->scanBandPreference = pMac->scan.scanBandPreference;
Jeff Johnson295189b2012-06-20 16:38:30 -07001979#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301980 vos_mem_copy(&pParam->neighborRoamConfig,
1981 &pMac->roam.configParam.neighborRoamConfig,
1982 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001983#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001984#ifdef WLAN_FEATURE_11AC
1985 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001986 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001987 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001988 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301989 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1990 if ( pParam->enableTxBF )
1991 pParam->enableMuBformee = pMac->roam.configParam.txMuBformee;
1992 else
1993 pParam->enableMuBformee = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001994#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001995#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301996 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1997 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001998#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001999#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002000 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
2001 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
2002 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
2003 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
2004 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07002005 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07002006 pParam->nProbes = pMac->roam.configParam.nProbes;
2007 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002008#endif
2009#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2010 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
2011 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
2012#endif
2013#ifdef FEATURE_WLAN_LFR
2014 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
2015#endif
2016
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002017#ifdef FEATURE_WLAN_ESE
2018 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002019#endif
2020#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302021 vos_mem_copy(&pParam->neighborRoamConfig,
2022 &pMac->roam.configParam.neighborRoamConfig,
2023 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002024 {
2025 int i;
2026 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
2027 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2028 {
2029 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2030 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002031 }
2032#endif
2033
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07002034 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07002035
krunal soni5afa96c2013-09-06 22:19:02 -07002036 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002037 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07002038
krunal sonie9002db2013-11-25 14:24:17 -08002039 pParam->isCoalesingInIBSSAllowed =
2040 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302041 pParam->allowDFSChannelRoam =
2042 pMac->roam.configParam.allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302043 pParam->sendDeauthBeforeCon = pMac->roam.configParam.sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07002044 csrSetChannels(pMac, pParam);
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +05302045#ifdef WLAN_FEATURE_AP_HT40_24G
2046 pParam->apHT40_24GEnabled = pMac->roam.configParam.apHT40_24GEnabled;
2047#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002048
2049 status = eHAL_STATUS_SUCCESS;
2050 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002051 return (status);
2052}
2053
Jeff Johnson295189b2012-06-20 16:38:30 -07002054eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
2055{
2056 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2057 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2058 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
2059 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 do
2061 {
2062 if(eCSR_BAND_24 == eBand)
2063 {
2064 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
2065 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
2066 }
2067 if(eCSR_BAND_5G == eBand)
2068 {
2069 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
2070 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
2071 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
2072 )
2073 {
2074 break;
2075 }
2076 }
2077 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2078 {
2079 newPhyMode = eCSR_DOT11_MODE_TAURUS;
2080 }
2081 else if(eCSR_DOT11_MODE_AUTO & phyMode)
2082 {
2083 newPhyMode = eCSR_DOT11_MODE_AUTO;
2084 }
2085 else
2086 {
2087 //Check for dual band and higher capability first
2088 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2089 {
2090 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2091 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2092 }
2093 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2094 {
2095 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2096 if(eCSR_BAND_24 == eBand) break;
2097 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2098 eBand = eCSR_BAND_5G;
2099 }
2100 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2101 {
2102 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2103 if(eCSR_BAND_5G == eBand) break;
2104 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2105 eBand = eCSR_BAND_24;
2106 }
2107 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2108 {
2109 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2110 if(eCSR_BAND_5G == eBand) break;
2111 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2112 eBand = eCSR_BAND_24;
2113 }
2114 else if(eCSR_DOT11_MODE_11n & phyMode)
2115 {
2116 newPhyMode = eCSR_DOT11_MODE_11n;
2117 }
2118 else if(eCSR_DOT11_MODE_abg & phyMode)
2119 {
2120 newPhyMode = eCSR_DOT11_MODE_abg;
2121 }
2122 else if(eCSR_DOT11_MODE_11a & phyMode)
2123 {
2124 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2125 {
2126 if(eCSR_BAND_ALL == eBand)
2127 {
2128 newPhyMode = eCSR_DOT11_MODE_abg;
2129 }
2130 else
2131 {
2132 //bad setting
2133 break;
2134 }
2135 }
2136 else
2137 {
2138 newPhyMode = eCSR_DOT11_MODE_11a;
2139 eBand = eCSR_BAND_5G;
2140 }
2141 }
2142 else if(eCSR_DOT11_MODE_11g & phyMode)
2143 {
2144 newPhyMode = eCSR_DOT11_MODE_11g;
2145 eBand = eCSR_BAND_24;
2146 }
2147 else if(eCSR_DOT11_MODE_11b & phyMode)
2148 {
2149 newPhyMode = eCSR_DOT11_MODE_11b;
2150 eBand = eCSR_BAND_24;
2151 }
2152 else
2153 {
2154 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002155 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 newPhyMode = eCSR_DOT11_MODE_AUTO;
2157 }
2158 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 //Done validating
2160 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 //Now we need to check whether a restart is needed.
2162 if(eBand != pMac->roam.configParam.eBand)
2163 {
2164 fRestartNeeded = eANI_BOOLEAN_TRUE;
2165 break;
2166 }
2167 if(newPhyMode != pMac->roam.configParam.phyMode)
2168 {
2169 fRestartNeeded = eANI_BOOLEAN_TRUE;
2170 break;
2171 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 if(HAL_STATUS_SUCCESS(status))
2174 {
2175 pMac->roam.configParam.eBand = eBand;
2176 pMac->roam.configParam.phyMode = newPhyMode;
2177 if(pfRestartNeeded)
2178 {
2179 *pfRestartNeeded = fRestartNeeded;
2180 }
2181 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002182 return (status);
2183}
2184
Jeff Johnson295189b2012-06-20 16:38:30 -07002185void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2186{
2187 tANI_U8 Index;
2188 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 // for dual band NICs, don't need to trim the channel list....
2190 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2191 {
2192 // 2.4 GHz band operation requires the channel list to be trimmed to
2193 // the 2.4 GHz channels only...
2194 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2195 {
2196 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2197 Index++ )
2198 {
2199 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2200 {
2201 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2202 cChannels++;
2203 }
2204 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002205 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2206 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2207 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2208 // only if we need to.
2209 //
2210 // The amount of memory to clear is the number of channesl that we trimmed
2211 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2212
2213 if ( pChannelList->numChannels > cChannels )
2214 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302215 vos_mem_set(&pChannelList->channelList[ cChannels ],
2216 sizeof( pChannelList->channelList[ 0 ] ) *
2217 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002218 }
2219
2220 pChannelList->numChannels = cChannels;
2221 }
2222 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2223 {
2224 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2225 {
2226 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2227 {
2228 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2229 cChannels++;
2230 }
2231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2233 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2234 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2235 // only if we need to.
2236 //
2237 // The amount of memory to clear is the number of channesl that we trimmed
2238 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2239 if ( pChannelList->numChannels > cChannels )
2240 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302241 vos_mem_set(&pChannelList->channelList[ cChannels ],
2242 sizeof( pChannelList->channelList[ 0 ] ) *
2243 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002244 }
2245
2246 pChannelList->numChannels = cChannels;
2247 }
2248 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002249}
Jeff Johnson295189b2012-06-20 16:38:30 -07002250#define INFRA_AP_DEFAULT_CHANNEL 6
2251eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2252{
2253 tANI_U8 index= 0;
2254 eHalStatus status = eHAL_STATUS_FAILURE;
2255 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2256 {
2257 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2258 status = eHAL_STATUS_SUCCESS;
2259 break;
2260 }
2261 }
2262 return status;
2263}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002264
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002265
Jeff Johnson295189b2012-06-20 16:38:30 -07002266eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2267{
2268 eHalStatus status = eHAL_STATUS_SUCCESS;
2269 tANI_U8 num20MHzChannelsFound = 0;
2270 VOS_STATUS vosStatus;
2271 tANI_U8 Index = 0;
2272 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002273
Jeff Johnson295189b2012-06-20 16:38:30 -07002274
2275 //TODO: this interface changed to include the 40MHz channel list
2276 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2277 // Read the scan channel list (including the power limit) from EEPROM
2278 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2279 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2280 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2281 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002282 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002283 status = eHAL_STATUS_FAILURE;
2284 }
2285 else
2286 {
2287 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2288 {
2289 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2290 }
2291 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2292 // Move the channel list to the global data
2293 // structure -- this will be used as the scan list
2294 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2295 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002296 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002297 }
2298 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2299 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2300 {
2301 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2302 }
2303 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2304 {
2305 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2306 }
2307 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2308 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002309 return (status);
2310}
Jeff Johnson295189b2012-06-20 16:38:30 -07002311eHalStatus csrInitChannelList( tHalHandle hHal )
2312{
2313 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2314 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2316 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002317 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2318 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002319 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002320 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Atul Mittalb849d5a2014-07-29 12:08:39 +05302321 limInitOperatingClasses(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002322 return (status);
2323}
Jeff Johnson295189b2012-06-20 16:38:30 -07002324eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2325 tCsrUpdateConfigParam *pUpdateConfigParam)
2326{
2327 eHalStatus status = eHAL_STATUS_FAILURE;
2328 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2330 status = CsrInit11dInfo(pMac, ps11dinfo);
2331 return status;
2332}
2333
Jeff Johnson295189b2012-06-20 16:38:30 -07002334static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2335{
2336 eHalStatus status = eHAL_STATUS_FAILURE;
2337 tANI_U8 index;
2338 tANI_U32 count=0;
2339 tSirMacChanInfo *pChanInfo;
2340 tSirMacChanInfo *pChanInfoStart;
2341 tANI_BOOLEAN applyConfig = TRUE;
2342
Mihir Shetebc866f62014-02-13 16:08:53 +05302343 pMac->scan.currentCountryRSSI = -128;
2344
Jeff Johnson295189b2012-06-20 16:38:30 -07002345 if(!ps11dinfo)
2346 {
2347 return (status);
2348 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002349 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2350 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302351 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2352 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2353 ps11dinfo->Channels.channelList,
2354 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 }
2356 else
2357 {
2358 //No change
2359 return (eHAL_STATUS_SUCCESS);
2360 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002361 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302362
2363 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2364 WNI_CFG_COUNTRY_CODE_LEN);
2365
2366
Jeff Johnson295189b2012-06-20 16:38:30 -07002367 //Tush: at csropen get this initialized with default, during csr reset if this
2368 // already set with some value no need initilaize with default again
2369 if(0 == pMac->scan.countryCodeCurrent[0])
2370 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302371 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2372 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002373 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002374 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302375 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2376 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002377 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302378 vos_mem_set(pChanInfo,
2379 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2380 0);
2381
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002383 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2384 {
2385 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2386 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2387 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2388 pChanInfo++;
2389 count++;
2390 }
2391 if(count)
2392 {
2393 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2394 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302395 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002396 }
2397 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2398 if( HAL_STATUS_SUCCESS(status) )
2399 {
2400 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2401 {
2402 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2403 {
2404 applyConfig = FALSE;
2405 }
2406 }
2407
2408 if(TRUE == applyConfig)
2409 {
2410 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002411 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002412 }
2413
2414 }
2415 return (status);
2416}
2417/* Initialize the Channel + Power List in the local cache and in the CFG */
2418eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2419{
2420 tANI_U8 index;
2421 tANI_U32 count=0;
2422 tSirMacChanInfo *pChanInfo;
2423 tSirMacChanInfo *pChanInfoStart;
2424
2425 if(!ps11dinfo || !pMac)
2426 {
2427 return eHAL_STATUS_FAILURE;
2428 }
2429
Kiet Lam64c1b492013-07-12 13:56:44 +05302430 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2431 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002432 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302433 vos_mem_set(pChanInfo,
2434 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2435 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002436 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002437
2438 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2439 {
2440 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2441 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2442 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2443 pChanInfo++;
2444 count++;
2445 }
2446 if(count)
2447 {
2448 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2449 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302450 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002451 }
2452
Jeff Johnsone7245742012-09-05 17:12:55 -07002453 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002454}
2455
2456//pCommand may be NULL
2457//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2458void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2459{
2460 tListElem *pEntry, *pNextEntry;
2461 tSmeCmd *pDupCommand;
2462 tDblLinkList localList;
2463
2464 vos_mem_zero(&localList, sizeof(tDblLinkList));
2465 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2466 {
2467 smsLog(pMac, LOGE, FL(" failed to open list"));
2468 return;
2469 }
2470 csrLLLock( &pMac->sme.smeCmdPendingList );
2471 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2472 while( pEntry )
2473 {
2474 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2475 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002476 // Remove the previous command if..
2477 // - the new roam command is for the same RoamReason...
2478 // - the new roam command is a NewProfileList.
2479 // - the new roam command is a Forced Dissoc
2480 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2481 if (
2482 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2483 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002484 /* This peermac check is requried for Softap/GO scenarios
2485 * For STA scenario below OR check will suffice as pCommand will
2486 * always be NULL for STA scenarios
2487 */
2488 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002489 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2490 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2491 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2492 ||
2493 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002494 ( (sessionId == pDupCommand->sessionId) &&
2495 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 ((eCsrForcedDisassoc == eRoamReason) ||
2497 (eCsrHddIssued == eRoamReason))
2498 )
2499 )
2500 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002501 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002502 // Remove the 'stale' roam command from the pending list...
2503 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2504 {
2505 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2506 }
2507 }
2508 pEntry = pNextEntry;
2509 }
2510 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2511
2512 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2513 {
2514 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2515 //Tell caller that the command is cancelled
2516 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2517 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2518 csrReleaseCommandRoam(pMac, pDupCommand);
2519 }
2520 csrLLClose(&localList);
2521}
Jeff Johnson295189b2012-06-20 16:38:30 -07002522eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2523 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2524{
2525 eHalStatus status = eHAL_STATUS_SUCCESS;
2526#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2527 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2528#endif
2529 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2531 {
2532 pSession = CSR_GET_SESSION( pMac, sessionId );
2533 }
2534 else
2535 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002536 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002537 VOS_ASSERT(0);
2538 return eHAL_STATUS_FAILURE;
2539 }
krunal soni587bf012014-02-04 12:35:11 -08002540
2541 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2542 {
2543 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2544 return eHAL_STATUS_FAILURE;
2545 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002546
krunal soni587bf012014-02-04 12:35:11 -08002547 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2548
krunal soni7f7d2c92014-02-06 15:08:43 -08002549 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002551 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002553 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2554 /*
2555 * Decrement bRefAssocStartCnt for FT reassoc failure.
2556 * Reason: For FT reassoc failures, we first call
2557 * csrRoamCallCallback before notifying a failed roam
2558 * completion through csrRoamComplete. The latter in
2559 * turn calls csrRoamProcessResults which tries to
2560 * once again call csrRoamCallCallback if bRefAssocStartCnt
2561 * is non-zero. Since this is redundant for FT reassoc
2562 * failure, decrement bRefAssocStartCnt.
2563 */
2564 pSession->bRefAssocStartCnt--;
2565 }
2566
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 if(NULL != pSession->callback)
2568 {
2569 if( pRoamInfo )
2570 {
2571 pRoamInfo->sessionId = (tANI_U8)sessionId;
2572 }
2573
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302574 /* avoid holding the global lock when making the roaming callback, original change came
2575 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2576 is possible on other OS ports where the callback may need to take locks to protect
2577 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002578 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2579 that may actually depend on the lock being held */
2580 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2581 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2582 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2583 }
2584 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2585 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2586#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302587 vos_mem_set(&connectionStatus,
2588 sizeof(vos_event_wlan_status_payload_type), 0);
2589
krunal soni7f7d2c92014-02-06 15:08:43 -08002590 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002591 {
2592 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2593 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2594 if(NULL != pRoamInfo->pBssDesc)
2595 {
2596 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2597 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2598 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002599 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2600 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2601 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302602 vos_mem_copy(connectionStatus.ssid,
2603 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2604
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2606 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2607 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002608 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2609 {
2610 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2611 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2612 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2613 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 if(eCSR_ROAM_RESULT_FORCED == u2)
2615 {
2616 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2617 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2618 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2619 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2621 {
2622 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2623 connectionStatus.reason = eCSR_REASON_DISASSOC;
2624 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2625 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2627 {
2628 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2629 connectionStatus.reason = eCSR_REASON_DEAUTH;
2630 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2631 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002632#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2633
2634 return (status);
2635}
Jeff Johnson295189b2012-06-20 16:38:30 -07002636// Returns whether handoff is currently in progress or not
2637tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2638{
2639#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2640 return csrNeighborRoamIsHandoffInProgress(pMac);
2641#else
2642 return eANI_BOOLEAN_FALSE;
2643#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002644}
Jeff Johnson295189b2012-06-20 16:38:30 -07002645eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2646 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2647{
2648 eHalStatus status = eHAL_STATUS_SUCCESS;
2649 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2650 tANI_U16 reasonCode;
2651 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002652
2653 if(!pSession)
2654 {
2655 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2656 return eHAL_STATUS_FAILURE;
2657 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002658
2659 //Restore AC weight in case we change it
2660 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2661 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002662 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 -07002663 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2664 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2665 }
2666
2667 if ( fMICFailure )
2668 {
2669 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2670 }
2671 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2672 {
2673 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002674 }
2675 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002676 {
2677 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2678 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002679#ifdef WLAN_FEATURE_VOWIFI_11R
2680 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2681 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2682 {
2683 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302684 vos_mem_copy(&bssId,
2685 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2686 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002687 }
2688 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002689#endif
2690 if(pSession->pConnectBssDesc)
2691 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302692 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002693 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002694
Jeff Johnson295189b2012-06-20 16:38:30 -07002695
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302696 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2697 " subState = %s reason=%d"),
2698 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2699 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002700
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2702
2703 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2704
2705 if(HAL_STATUS_SUCCESS(status))
2706 {
2707 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002708#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2709 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2710 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2711 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002712 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2714 }
2715#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002716 }
2717 else
2718 {
2719 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2720 }
2721
Jeff Johnson295189b2012-06-20 16:38:30 -07002722 return (status);
2723}
Jeff Johnson295189b2012-06-20 16:38:30 -07002724
Jeff Johnson295189b2012-06-20 16:38:30 -07002725/* ---------------------------------------------------------------------------
2726 \fn csrRoamIssueDisassociateStaCmd
2727 \brief csr function that HDD calls to disassociate a associated station
2728 \param sessionId - session Id for Soft AP
2729 \param pPeerMacAddr - MAC of associated station to delete
2730 \param reason - reason code, be one of the tSirMacReasonCodes
2731 \return eHalStatus
2732 ---------------------------------------------------------------------------*/
2733eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2734 tANI_U32 sessionId,
2735 tANI_U8 *pPeerMacAddr,
2736 tANI_U32 reason)
2737{
2738 eHalStatus status = eHAL_STATUS_SUCCESS;
2739 tSmeCmd *pCommand;
2740
2741 do
2742 {
2743 pCommand = csrGetCommandBuffer( pMac );
2744 if ( !pCommand )
2745 {
2746 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2747 status = eHAL_STATUS_RESOURCES;
2748 break;
2749 }
2750 pCommand->command = eSmeCommandRoam;
2751 pCommand->sessionId = (tANI_U8)sessionId;
2752 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2753 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2754 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2755 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2756 if( !HAL_STATUS_SUCCESS( status ) )
2757 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002758 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002759 csrReleaseCommandRoam( pMac, pCommand );
2760 }
2761 }while(0);
2762
2763 return status;
2764}
2765
2766
Jeff Johnson295189b2012-06-20 16:38:30 -07002767/* ---------------------------------------------------------------------------
2768 \fn csrRoamIssueDeauthSta
2769 \brief csr function that HDD calls to delete a associated station
2770 \param sessionId - session Id for Soft AP
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302771 \param pDelStaParams- Pointer to parameters of the station to deauthenticate
Jeff Johnson295189b2012-06-20 16:38:30 -07002772 \return eHalStatus
2773 ---------------------------------------------------------------------------*/
2774eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302775 tANI_U32 sessionId,
2776 struct tagCsrDelStaParams *pDelStaParams)
Jeff Johnson295189b2012-06-20 16:38:30 -07002777{
2778 eHalStatus status = eHAL_STATUS_SUCCESS;
2779 tSmeCmd *pCommand;
2780
2781 do
2782 {
2783 pCommand = csrGetCommandBuffer( pMac );
2784 if ( !pCommand )
2785 {
2786 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2787 status = eHAL_STATUS_RESOURCES;
2788 break;
2789 }
2790 pCommand->command = eSmeCommandRoam;
2791 pCommand->sessionId = (tANI_U8)sessionId;
2792 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
Hanumantha Reddy Pothulaf57da152014-10-31 13:02:08 +05302793 vos_mem_copy(pCommand->u.roamCmd.peerMac, pDelStaParams->peerMacAddr,
2794 sizeof(tSirMacAddr));
2795 pCommand->u.roamCmd.reason =
2796 (tSirMacReasonCodes)pDelStaParams->reason_code;
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2798 if( !HAL_STATUS_SUCCESS( status ) )
2799 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002800 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002801 csrReleaseCommandRoam( pMac, pCommand );
2802 }
2803 }while(0);
2804
2805 return status;
2806}
Jeff Johnson295189b2012-06-20 16:38:30 -07002807eHalStatus
2808csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2809 tANI_BOOLEAN bEnable )
2810{
2811 eHalStatus status = eHAL_STATUS_FAILURE;
2812 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2813 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002814 if (!pSession)
2815 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002816 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 return (status);
2818 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 if (pSession->pConnectBssDesc)
2820 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302821 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002822 }
2823 else
2824 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002825 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 return (status);
2827 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002828 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2829 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2831 return (status);
2832}
Jeff Johnson295189b2012-06-20 16:38:30 -07002833eHalStatus
2834csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2835 VOS_MODULE_ID modId, void *pUsrContext,
2836 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2837{
2838 eHalStatus status = eHAL_STATUS_SUCCESS;
2839 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2840 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002841 if (!pSession)
2842 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002843 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002844 return (status);
2845 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 if(pSession->pConnectBssDesc)
2847 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302848 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002849 }
2850 else
2851 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002852 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 return (status);
2854 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002855 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2856 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002857 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2858 return (status);
2859}
Jeff Johnson295189b2012-06-20 16:38:30 -07002860eHalStatus
2861csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2862 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2863{
2864 eHalStatus status = eHAL_STATUS_SUCCESS;
2865 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2866 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2867
2868 if (!pSession)
2869 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002870 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 return (status);
2872 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 if(pSession->pConnectBssDesc)
2874 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302875 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002876 }
2877 else
2878 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002879 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002880 return (status);
2881 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002882 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2883 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002884
2885 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2886
2887 return (status);
2888}
Jeff Johnson295189b2012-06-20 16:38:30 -07002889eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2890{
2891 eHalStatus status = eHAL_STATUS_SUCCESS;
2892 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2893 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002894
2895 if (!pSession)
2896 {
2897 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2898 return eHAL_STATUS_FAILURE;
2899 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002900
2901 if(pSession->pConnectBssDesc)
2902 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302903 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002904 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002905 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2906 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2908
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302909 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Mukul Sharma45049182014-06-17 23:34:10 +05302910 if(HAL_STATUS_SUCCESS(status))
2911 {
2912 csrRoamLinkDown(pMac, sessionId);
2913 }
2914 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002915 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302916 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2917 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002918 }
2919
Jeff Johnson295189b2012-06-20 16:38:30 -07002920 return (status);
2921}
2922
Jeff Johnson295189b2012-06-20 16:38:30 -07002923eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2924{
2925 eHalStatus status = eHAL_STATUS_SUCCESS;
2926 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2927 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002928
2929 if(!pSession)
2930 {
2931 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2932 return eHAL_STATUS_FAILURE;
2933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002934
2935 // If no BSS description was found in this connection (happens with start IBSS), then
2936 // nix the BSS description that we keep around for the connected BSS) and get out...
2937 if(NULL == pBssDesc)
2938 {
2939 csrFreeConnectBssDesc(pMac, sessionId);
2940 }
2941 else
2942 {
2943 size = pBssDesc->length + sizeof( pBssDesc->length );
2944 if(NULL != pSession->pConnectBssDesc)
2945 {
2946 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2947 {
2948 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2949 csrFreeConnectBssDesc(pMac, sessionId);
2950 }
2951 }
2952 if(NULL == pSession->pConnectBssDesc)
2953 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302954 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002955 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302956 if (NULL == pSession->pConnectBssDesc)
2957 status = eHAL_STATUS_FAILURE;
2958 else
2959 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002961 return (status);
2962}
2963
Jeff Johnson295189b2012-06-20 16:38:30 -07002964eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2965 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2966 tDot11fBeaconIEs *pIes)
2967{
2968 eHalStatus status = eHAL_STATUS_SUCCESS;
2969 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002970 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302971 if (pIes == NULL)
2972 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002973
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 do
2975 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302976 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2977 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002978 //get qos
2979 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2980 //get SSID
2981 if(pIes->SSID.present)
2982 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302983 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002984 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2985 }
2986 else
2987 pBssConfig->SSID.length = 0;
2988 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2989 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002990 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002991 //Return failed if profile doesn't have an SSID either.
2992 if(pProfile->SSIDs.numOfSSIDs == 0)
2993 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002994 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002995 status = eHAL_STATUS_FAILURE;
2996 break;
2997 }
2998 }
2999 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
3000 {
3001 pBssConfig->eBand = eCSR_BAND_5G;
3002 }
3003 else
3004 {
3005 pBssConfig->eBand = eCSR_BAND_24;
3006 }
3007 //phymode
3008 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
3009 {
3010 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
3011 }
3012 else
3013 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003014 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07003015 //force it
3016 if(eCSR_BAND_24 == pBssConfig->eBand)
3017 {
3018 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
3019 }
3020 else
3021 {
3022 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
3023 }
3024 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003025 //Qos
3026 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
3027 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
3028 {
3029 //Joining BSS is not 11n capable and WMM is disabled on client.
3030 //Disable QoS and WMM
3031 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3032 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303033
3034 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05303035 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303036 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
3037 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
3038 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
3039 {
3040 //Joining BSS is 11n capable and WMM is disabled on AP.
3041 //Assume all HT AP's are QOS AP's and enable WMM
3042 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3043 }
3044
Jeff Johnson295189b2012-06-20 16:38:30 -07003045 //auth type
3046 switch( pProfile->negotiatedAuthType )
3047 {
3048 default:
3049 case eCSR_AUTH_TYPE_WPA:
3050 case eCSR_AUTH_TYPE_WPA_PSK:
3051 case eCSR_AUTH_TYPE_WPA_NONE:
3052 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3053 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3054 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003055 case eCSR_AUTH_TYPE_SHARED_KEY:
3056 pBssConfig->authType = eSIR_SHARED_KEY;
3057 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 case eCSR_AUTH_TYPE_AUTOSWITCH:
3059 pBssConfig->authType = eSIR_AUTO_SWITCH;
3060 break;
3061 }
3062 //short slot time
3063 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3064 {
3065 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3066 }
3067 else
3068 {
3069 pBssConfig->uShortSlotTime = 0;
3070 }
3071 if(pBssConfig->BssCap.ibss)
3072 {
3073 //We don't support 11h on IBSS
3074 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3075 }
3076 else
3077 {
3078 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3079 }
3080 //power constraint
3081 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3082 //heartbeat
3083 if ( CSR_IS_11A_BSS( pBssDesc ) )
3084 {
3085 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3086 }
3087 else
3088 {
3089 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3090 }
3091 //Join timeout
3092 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07003093 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07003094 if ( pBssDesc->beaconInterval )
3095 {
3096 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07003097 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 }
3099 else
3100 {
3101 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3102 }
3103 //validate CB
3104 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sandeep Puligilla60342762014-01-30 21:05:37 +05303105
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003107 return (status);
3108}
3109
Jeff Johnson295189b2012-06-20 16:38:30 -07003110static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3111 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3112{
3113 eHalStatus status = eHAL_STATUS_SUCCESS;
3114 tANI_U8 operationChannel = 0;
3115 tANI_U8 qAPisEnabled = FALSE;
3116 //SSID
3117 pBssConfig->SSID.length = 0;
3118 if(pProfile->SSIDs.numOfSSIDs)
3119 {
3120 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303121 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3122 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 }
3124 else
3125 {
3126 //SSID must present
3127 return eHAL_STATUS_FAILURE;
3128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 //Settomg up the capabilities
3130 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3131 {
3132 pBssConfig->BssCap.ibss = 1;
3133 }
3134 else
3135 {
3136 pBssConfig->BssCap.ess = 1;
3137 }
3138 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3139 {
3140 pBssConfig->BssCap.privacy = 1;
3141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 pBssConfig->eBand = pMac->roam.configParam.eBand;
3143 //phymode
3144 if(pProfile->ChannelInfo.ChannelList)
3145 {
3146 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3147 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003148 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3149 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003150 //QOS
3151 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 if ( pBssConfig->BssCap.ess == 1 )
3153 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003154 /*For Softap case enable WMM*/
3155 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3156 qAPisEnabled = TRUE;
3157 }
3158 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3160 qAPisEnabled = TRUE;
3161 } else {
3162 qAPisEnabled = FALSE;
3163 }
3164 } else {
3165 qAPisEnabled = TRUE;
3166 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003167 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3168 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3169 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3170 )
3171 {
3172 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3173 } else {
3174 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3175 }
3176
3177 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003178 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003179 {
3180 default:
3181 case eCSR_AUTH_TYPE_WPA:
3182 case eCSR_AUTH_TYPE_WPA_PSK:
3183 case eCSR_AUTH_TYPE_WPA_NONE:
3184 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3185 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3186 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 case eCSR_AUTH_TYPE_SHARED_KEY:
3188 pBssConfig->authType = eSIR_SHARED_KEY;
3189 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 case eCSR_AUTH_TYPE_AUTOSWITCH:
3191 pBssConfig->authType = eSIR_AUTO_SWITCH;
3192 break;
3193 }
3194 //short slot time
3195 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3196 {
3197 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3198 }
3199 else
3200 {
3201 pBssConfig->uShortSlotTime = 0;
3202 }
3203 //power constraint. We don't support 11h on IBSS
3204 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3205 pBssConfig->uPowerLimit = 0;
3206 //heartbeat
3207 if ( eCSR_BAND_5G == pBssConfig->eBand )
3208 {
3209 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3210 }
3211 else
3212 {
3213 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3214 }
3215 //Join timeout
3216 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003217
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 return (status);
3219}
Jeff Johnson295189b2012-06-20 16:38:30 -07003220static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3221{
3222 eHalStatus status = eHAL_STATUS_FAILURE;
3223 tDot11fBeaconIEs *pIes = NULL;
3224
3225 do
3226 {
3227 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3228 {
3229 //err msg
3230 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003231 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003232 break;
3233 }
3234 //check if the AP is QAP & it supports APSD
3235 if( CSR_IS_QOS_BSS(pIes) )
3236 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303237 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 }
3239 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303240
3241 if (NULL != pIes)
3242 {
3243 vos_mem_free(pIes);
3244 }
3245
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 return status;
3247}
3248
Jeff Johnson295189b2012-06-20 16:38:30 -07003249void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3250{
Jeff Johnson295189b2012-06-20 16:38:30 -07003251 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3252 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3253 // See !!Note: below in this function...
3254 tANI_U32 PrivacyEnabled = 0;
3255 tANI_U32 RsnEnabled = 0;
3256 tANI_U32 WepDefaultKeyId = 0;
3257 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3258 tANI_U32 Key0Length = 0;
3259 tANI_U32 Key1Length = 0;
3260 tANI_U32 Key2Length = 0;
3261 tANI_U32 Key3Length = 0;
3262
3263 // Reserve for the biggest key
3264 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3265 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3266 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3267 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3268
3269 switch ( pProfile->negotiatedUCEncryptionType )
3270 {
3271 case eCSR_ENCRYPT_TYPE_NONE:
3272
3273 // for NO encryption, turn off Privacy and Rsn.
3274 PrivacyEnabled = 0;
3275 RsnEnabled = 0;
3276
3277 // WEP key length and Wep Default Key ID don't matter in this case....
3278
3279 // clear out the WEP keys that may be hanging around.
3280 Key0Length = 0;
3281 Key1Length = 0;
3282 Key2Length = 0;
3283 Key3Length = 0;
3284
3285 break;
3286
3287 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303288 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003289
3290 // Privacy is ON. NO RSN for Wep40 static key.
3291 PrivacyEnabled = 1;
3292 RsnEnabled = 0;
3293
3294 // Set the Wep default key ID.
3295 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003296 // Wep key size if 5 bytes (40 bits).
3297 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3298
3299 // set encryption keys in the CFG database or clear those that are not present in this profile.
3300 if ( pProfile->Keys.KeyLength[0] )
3301 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303302 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3303 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3305 }
3306 else
3307 {
3308 Key0Length = 0;
3309 }
3310
3311 if ( pProfile->Keys.KeyLength[1] )
3312 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303313 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3314 WNI_CFG_WEP_KEY_LENGTH_5);
3315 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003316 }
3317 else
3318 {
3319 Key1Length = 0;
3320 }
3321
3322 if ( pProfile->Keys.KeyLength[2] )
3323 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303324 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3325 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003326 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3327 }
3328 else
3329 {
3330 Key2Length = 0;
3331 }
3332
3333 if ( pProfile->Keys.KeyLength[3] )
3334 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303335 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3336 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3338 }
3339 else
3340 {
3341 Key3Length = 0;
3342 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003343 break;
3344
3345 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303346 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003347
3348 // Privacy is ON. NO RSN for Wep40 static key.
3349 PrivacyEnabled = 1;
3350 RsnEnabled = 0;
3351
3352 // Set the Wep default key ID.
3353 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3354
3355 // Wep key size if 13 bytes (104 bits).
3356 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3357
3358 // set encryption keys in the CFG database or clear those that are not present in this profile.
3359 if ( pProfile->Keys.KeyLength[0] )
3360 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303361 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3362 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003363 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3364 }
3365 else
3366 {
3367 Key0Length = 0;
3368 }
3369
3370 if ( pProfile->Keys.KeyLength[1] )
3371 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303372 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3373 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003374 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3375 }
3376 else
3377 {
3378 Key1Length = 0;
3379 }
3380
3381 if ( pProfile->Keys.KeyLength[2] )
3382 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303383 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3384 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3386 }
3387 else
3388 {
3389 Key2Length = 0;
3390 }
3391
3392 if ( pProfile->Keys.KeyLength[3] )
3393 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303394 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3395 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3397 }
3398 else
3399 {
3400 Key3Length = 0;
3401 }
3402
3403 break;
3404
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 case eCSR_ENCRYPT_TYPE_TKIP:
3406 case eCSR_ENCRYPT_TYPE_AES:
3407#ifdef FEATURE_WLAN_WAPI
3408 case eCSR_ENCRYPT_TYPE_WPI:
3409#endif /* FEATURE_WLAN_WAPI */
3410 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3411 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3412 PrivacyEnabled = (0 != fPrivacy);
3413
3414 // turn on RSN enabled for WPA associations
3415 RsnEnabled = 1;
3416
3417 // WEP key length and Wep Default Key ID don't matter in this case....
3418
3419 // clear out the static WEP keys that may be hanging around.
3420 Key0Length = 0;
3421 Key1Length = 0;
3422 Key2Length = 0;
3423 Key3Length = 0;
3424
3425 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 default:
3427 PrivacyEnabled = 0;
3428 RsnEnabled = 0;
3429 break;
3430 }
3431
3432 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3433 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3434 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3435 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3436 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3437 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3438 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3439 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3440}
3441
Jeff Johnson295189b2012-06-20 16:38:30 -07003442static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3443{
3444 tANI_U32 len = 0;
3445 if(pSSID->length <= WNI_CFG_SSID_LEN)
3446 {
3447 len = pSSID->length;
3448 }
3449 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3450}
3451
Jeff Johnson295189b2012-06-20 16:38:30 -07003452eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3453{
3454 eHalStatus status = eHAL_STATUS_SUCCESS;
3455 tANI_U32 QoSEnabled;
3456 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 // set the CFG enable/disable variables based on the qosType being configured...
3458 switch( qosType )
3459 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3461 QoSEnabled = FALSE;
3462 WmeEnabled = TRUE;
3463 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3465 QoSEnabled = FALSE;
3466 WmeEnabled = TRUE;
3467 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3469 QoSEnabled = FALSE;
3470 WmeEnabled = TRUE;
3471 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3473 QoSEnabled = TRUE;
3474 WmeEnabled = FALSE;
3475 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003476 case eCSR_MEDIUM_ACCESS_11e_HCF:
3477 QoSEnabled = TRUE;
3478 WmeEnabled = FALSE;
3479 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003480 default:
3481 case eCSR_MEDIUM_ACCESS_DCF:
3482 QoSEnabled = FALSE;
3483 WmeEnabled = FALSE;
3484 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 }
3486 //save the WMM setting for later use
3487 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303488 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 return (status);
3490}
Jeff Johnson295189b2012-06-20 16:38:30 -07003491static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3492 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3493{
3494 eHalStatus status = eHAL_STATUS_FAILURE;
3495 int i;
3496 eCsrCfgDot11Mode cfgDot11Mode;
3497 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303498 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3499 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003500 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003501
3502 if( NULL != pIes )
3503 {
3504 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 // Originally, we thought that for 11a networks, the 11a rates are always
3506 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3507 // appear in the Operational Rate set. Consequently, in either case, we
3508 // would blindly put the rates we support into our Operational Rate set
3509 // (including the basic rates, which we have already verified are
3510 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 // However, it turns out that this is not always the case. Some AP's
3512 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3513 // too. Now, we're a little more careful:
3514 pDstRate = pOpRateSet->rate;
3515 if(pIes->SuppRates.present)
3516 {
3517 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3518 {
3519 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3520 {
3521 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003522 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003523 }
3524 }
3525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003526 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3527 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3528 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3529 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3530 {
3531 // If there are Extended Rates in the beacon, we will reflect those
3532 // extended rates that we support in out Extended Operational Rate
3533 // set:
3534 pDstRate = pExRateSet->rate;
3535 if(pIes->ExtSuppRates.present)
3536 {
3537 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3538 {
3539 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3540 {
3541 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3542 pExRateSet->numRates++;
3543 }
3544 }
3545 }
3546 }
3547 }//Parsing BSSDesc
3548 else
3549 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003550 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003551 }
3552 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3553 return status;
3554}
3555
3556static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3557 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3558{
3559 int i;
3560 tANI_U8 *pDstRate;
3561 eCsrCfgDot11Mode cfgDot11Mode;
3562 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3563 tANI_U32 OperationalRatesLength = 0;
3564 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3565 tANI_U32 ExtendedOperationalRatesLength = 0;
3566 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3567 tANI_U32 ProprietaryOperationalRatesLength = 0;
3568 tANI_U32 PropRatesEnable = 0;
3569 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3570 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003571 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003572 if( NULL != pIes )
3573 {
3574 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003575 // Originally, we thought that for 11a networks, the 11a rates are always
3576 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3577 // appear in the Operational Rate set. Consequently, in either case, we
3578 // would blindly put the rates we support into our Operational Rate set
3579 // (including the basic rates, which we have already verified are
3580 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 // However, it turns out that this is not always the case. Some AP's
3582 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3583 // too. Now, we're a little more careful:
3584 pDstRate = OperationalRates;
3585 if(pIes->SuppRates.present)
3586 {
3587 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3588 {
3589 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3590 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3591 {
3592 *pDstRate++ = pIes->SuppRates.rates[ i ];
3593 OperationalRatesLength++;
3594 }
3595 }
3596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003597 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3598 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3599 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3600 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3601 {
3602 // If there are Extended Rates in the beacon, we will reflect those
3603 // extended rates that we support in out Extended Operational Rate
3604 // set:
3605 pDstRate = ExtendedOperationalRates;
3606 if(pIes->ExtSuppRates.present)
3607 {
3608 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3609 {
3610 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3611 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3612 {
3613 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3614 ExtendedOperationalRatesLength++;
3615 }
3616 }
3617 }
3618 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003619 // Enable proprietary MAC features if peer node is Airgo node and STA
3620 // user wants to use them
3621 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3622 {
3623 PropRatesEnable = 1;
3624 }
3625 else
3626 {
3627 PropRatesEnable = 0;
3628 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003629 // For ANI network companions, we need to populate the proprietary rate
3630 // set with any proprietary rates we found in the beacon, only if user
3631 // allows them...
3632 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3633 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3634 {
3635 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3636 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3637 {
3638 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3639 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303640 vos_mem_copy(ProprietaryOperationalRates,
3641 pIes->Airgo.PropSuppRates.rates,
3642 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003643 }
3644 else {
3645 // No proprietary modes...
3646 ProprietaryOperationalRatesLength = 0;
3647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003648 /* Get MCS Rate */
3649 pDstRate = MCSRateIdxSet;
3650 if ( pIes->HTCaps.present )
3651 {
3652 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3653 {
3654 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3655 {
3656 MCSRateLength++;
3657 *pDstRate++ = i;
3658 }
3659 }
3660 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003661 // Set the operational rate set CFG variables...
3662 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3663 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3664 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3665 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3666 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3667 ProprietaryOperationalRates,
3668 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3669 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3670 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3671 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3672 }//Parsing BSSDesc
3673 else
3674 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003675 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003676 }
3677}
3678
Jeff Johnson295189b2012-06-20 16:38:30 -07003679static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3680 tCsrRoamProfile *pProfile )
3681{
3682 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3683 { 8,
3684 { SIR_MAC_RATE_6,
3685 SIR_MAC_RATE_9,
3686 SIR_MAC_RATE_12,
3687 SIR_MAC_RATE_18,
3688 SIR_MAC_RATE_24,
3689 SIR_MAC_RATE_36,
3690 SIR_MAC_RATE_48,
3691 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003692 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3693 { 4,
3694 { SIR_MAC_RATE_1,
3695 SIR_MAC_RATE_2,
3696 SIR_MAC_RATE_5_5,
3697 SIR_MAC_RATE_11 } } };
3698
3699
3700 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3701 { SIR_MAC_RATE_72,
3702 SIR_MAC_RATE_96,
3703 SIR_MAC_RATE_108 } };
3704 eCsrCfgDot11Mode cfgDot11Mode;
3705 eCsrBand eBand;
3706 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3707 tANI_U32 OperationalRatesLength = 0;
3708 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3709 tANI_U32 ExtendedOperationalRatesLength = 0;
3710 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3711 tANI_U32 ProprietaryOperationalRatesLength = 0;
3712 tANI_U32 PropRatesEnable = 0;
3713 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 if(pProfile->ChannelInfo.ChannelList)
3715 {
3716 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003718 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003719 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3720 // networks, the 11b rates appear in the Operational Rate set. In either case,
3721 // we can blindly put the rates we support into our Operational Rate set
3722 // (including the basic rates, which we have already verified are supported
3723 // earlier in the roaming decision).
3724 if ( eCSR_BAND_5G == eBand )
3725 {
3726 // 11a rates into the Operational Rate Set.
3727 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3728 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303729 vos_mem_copy(OperationalRates,
3730 DefaultSupportedRates11a.supportedRateSet.rate,
3731 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003732
3733 // Nothing in the Extended rate set.
3734 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 // populate proprietary rates if user allows them
3736 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3737 {
3738 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3739 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303740 vos_mem_copy(ProprietaryOperationalRates,
3741 DefaultSupportedPropRates.propRate,
3742 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003743 }
3744 else
3745 {
3746 // No proprietary modes
3747 ProprietaryOperationalRatesLength = 0;
3748 }
3749 }
3750 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3751 {
3752 // 11b rates into the Operational Rate Set.
3753 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3754 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303755 vos_mem_copy(OperationalRates,
3756 DefaultSupportedRates11b.supportedRateSet.rate,
3757 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003758 // Nothing in the Extended rate set.
3759 ExtendedOperationalRatesLength = 0;
3760 // No proprietary modes
3761 ProprietaryOperationalRatesLength = 0;
3762 }
3763 else
3764 {
3765 // 11G
3766
3767 // 11b rates into the Operational Rate Set.
3768 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3769 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303770 vos_mem_copy(OperationalRates,
3771 DefaultSupportedRates11b.supportedRateSet.rate,
3772 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003773
3774 // 11a rates go in the Extended rate set.
3775 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3776 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303777 vos_mem_copy(ExtendedOperationalRates,
3778 DefaultSupportedRates11a.supportedRateSet.rate,
3779 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003780
3781 // populate proprietary rates if user allows them
3782 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3783 {
3784 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3785 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303786 vos_mem_copy(ProprietaryOperationalRates,
3787 DefaultSupportedPropRates.propRate,
3788 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 }
3790 else
3791 {
3792 // No proprietary modes
3793 ProprietaryOperationalRatesLength = 0;
3794 }
3795 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3797 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3798 {
3799 PropRatesEnable = 1;
3800 }
3801 else
3802 {
3803 PropRatesEnable = 0;
3804 }
3805
3806 // Set the operational rate set CFG variables...
3807 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3808 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3809 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3810 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3811 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3812 ProprietaryOperationalRates,
3813 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3814 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003815}
Jeff Johnson295189b2012-06-20 16:38:30 -07003816void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3817{
3818 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003819
Jeff Johnson295189b2012-06-20 16:38:30 -07003820 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3821 tANI_U32 sessionId;
3822 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 if(NULL == pEntry)
3824 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003825 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003826 return;
3827 }
3828 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3829 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05303830 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
3831 " current state : %d sub state : %d "),
3832 result, pMac->roam.curState[sessionId],
3833 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003834 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3835 {
3836 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3837 }
3838}
3839
Jeff Johnson295189b2012-06-20 16:38:30 -07003840//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3841tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3842{
3843 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3844 {
3845 return (WNI_CFG_PHY_MODE_11B);
3846 }
3847 else
3848 {
3849 if(eCSR_BAND_24 == band)
3850 return (WNI_CFG_PHY_MODE_11G);
3851 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003852 return (WNI_CFG_PHY_MODE_11A);
3853}
Jeff Johnson295189b2012-06-20 16:38:30 -07003854
Jeff Johnsone7245742012-09-05 17:12:55 -07003855
3856#ifdef WLAN_FEATURE_11AC
3857ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3858{
3859 switch ( aniCBMode )
3860 {
3861 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3862 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3863 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3864 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3865 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3866 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3867 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3868 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3869 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003870 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003871 return PHY_SINGLE_CHANNEL_CENTERED;
3872 }
3873}
3874#endif
3875
Jeff Johnson295189b2012-06-20 16:38:30 -07003876//pIes may be NULL
3877eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3878 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303879 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003880{
3881 eHalStatus status = eHAL_STATUS_SUCCESS;
3882 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3883 tANI_U8 channel = 0;
3884 //Make sure we have the domain info for the BSS we try to connect to.
3885 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303886 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003887 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05303888 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003889 {
3890 //Make sure the 11d info from this BSSDesc can be applied
3891 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303892 if (VOS_TRUE == resetCountry)
3893 {
3894 csrApplyCountryInformation(pMac, FALSE);
3895 }
3896 else
3897 {
3898 csrApplyCountryInformation(pMac, TRUE);
3899 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003900 }
Kiran4a17ebe2013-01-31 10:43:43 -08003901 if ((csrIs11dSupported (pMac)) && pIes)
3902 {
3903 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003904 {
Kiran4a17ebe2013-01-31 10:43:43 -08003905 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003906 }
3907 else
3908 {
3909 //Let's also update the below to make sure we don't update CC while
3910 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303911 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003912 pBssDesc->bssId, sizeof(tSirMacAddr));
3913 }
Kiran4a17ebe2013-01-31 10:43:43 -08003914 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 //Qos
3917 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3918 //SSID
3919 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3920 //fragment threshold
3921 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3922 //RTS threshold
3923 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3924
3925 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 //Auth type
3927 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3928 //encryption type
3929 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3930 //short slot time
3931 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003932 //11d
3933 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3934 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3935 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 /*//11h
3937 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3938 */
3939 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3940 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003941
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003942 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003943 {
3944 channel = pProfile->operationChannel;
3945 }
3946 else
3947 {
3948 if(pBssDesc)
3949 {
3950 channel = pBssDesc->channelId;
3951 }
3952 }
3953 if(0 != channel)
3954 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05303955 if(CSR_IS_CHANNEL_24GHZ(channel) &&
3956 !pMac->roam.configParam.channelBondingMode24GHz &&
3957 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
3958 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05303960 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
3961 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
3962 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07003963 }
3964 else
3965 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003966 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 }
3968 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003969#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003970 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3971 // in function csrConvertCBIniValueToPhyCBState()
3972 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3973 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003974 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003975 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003976 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003977 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05303978 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003979 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003980 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003981 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003982 }
3983 else
3984#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003985 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3986 //Rate
3987 //Fixed Rate
3988 if(pBssDesc)
3989 {
3990 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3991 }
3992 else
3993 {
3994 csrSetCfgRateSetFromProfile(pMac, pProfile);
3995 }
3996 //Make this the last CFG to set. The callback will trigger a join_req
3997 //Join time out
3998 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3999
4000 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004001 return (status);
4002}
4003
Jeff Johnson295189b2012-06-20 16:38:30 -07004004eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
4005 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
4006{
4007 eHalStatus status;
4008 tBssConfigParam *pBssConfig;
4009 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004010
4011 if(!pSession)
4012 {
4013 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4014 return eHAL_STATUS_FAILURE;
4015 }
4016
Kiet Lam64c1b492013-07-12 13:56:44 +05304017 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
4018 if ( NULL == pBssConfig )
4019 status = eHAL_STATUS_FAILURE;
4020 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304022 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004023 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
4024 if(HAL_STATUS_SUCCESS(status))
4025 {
4026 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004027 /* This will allow to pass cbMode during join req */
4028 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 //For IBSS, we need to prepare some more information
4030 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004031 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004032 )
4033 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004034 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 }
4036 // If we are in an IBSS, then stop the IBSS...
4037 ////Not worry about WDS connection for now
4038 if ( csrIsConnStateIbss( pMac, sessionId ) )
4039 {
4040 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
4041 }
4042 else
4043 {
4044 // if we are in an Infrastructure association....
4045 if ( csrIsConnStateInfra( pMac, sessionId ) )
4046 {
4047 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
4048 // across SSIDs (roaming to a new SSID)... //
4049 //Not worry about WDS connection for now
4050 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304051 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 {
4053 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304054 status = csrRoamIssueDisassociate( pMac, sessionId,
4055 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004056 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304057 else
4058 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4060 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304061 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304063 // Set parameters for this Bss.
4064 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4065 pBssDesc, pBssConfig,
4066 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304070 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004071 {
4072 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4073 // Nothing to stop.
4074 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304076 )
4077 {
4078 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4079 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4080 // Set parameters for this Bss.
4081 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4082 pBssDesc, pBssConfig,
4083 pIes, is11rRoamingFlag);
4084 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 }
4086 }
4087 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304088 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 return (status);
4091}
4092
Jeff Johnson295189b2012-06-20 16:38:30 -07004093eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4094 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4095{
4096 eCsrJoinState eRoamState = eCsrContinueRoaming;
4097 eHalStatus status;
4098 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4099 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4100 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004101
4102 if(!pSession)
4103 {
4104 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4105 return (eCsrStopRoaming);
4106 }
4107
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 if( CSR_IS_WDS_STA( pProfile ) )
4109 {
4110 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4111 if( !HAL_STATUS_SUCCESS( status ) )
4112 {
4113 eRoamState = eCsrStopRoaming;
4114 }
4115 }
4116 else
4117 {
4118 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4119 {
4120 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4121 return (eCsrStopRoaming);
4122 }
4123 if ( csrIsInfraBssDesc( pBssDesc ) )
4124 {
4125 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4126 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4127 // have changed and handle the changes (without disturbing the current association).
4128
4129 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4130 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4131 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4132 )
4133 {
4134 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4135 // with Authenticating first. To force this, stop the current association (Disassociate) and
4136 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4137 // a new Association.
4138 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4139 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004140 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4142 {
4143 eRoamState = eCsrReassocToSelfNoCapChange;
4144 }
4145 else
4146 {
4147 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004148 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304149 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4151 if(HAL_STATUS_SUCCESS(status))
4152 {
4153 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004154 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004155 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304156 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4157 pBssDesc, &bssConfig,
4158 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004159 if(!HAL_STATUS_SUCCESS(status))
4160 {
4161 eRoamState = eCsrStopRoaming;
4162 }
4163 }
4164 else
4165 {
4166 eRoamState = eCsrStopRoaming;
4167 }
4168 }//same profile
4169 }
4170 else
4171 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304172 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4174 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304175 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4176 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004177 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304180 }
4181 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004182 {
4183 // 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 -07004184 // stop the existing network before attempting to join the new network...
4185 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4186 {
4187 eRoamState = eCsrStopRoaming;
4188 }
4189 }
4190 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304191 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004192 {
4193 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4194 {
4195 eRoamState = eCsrStopRoaming;
4196 }
4197 }
4198 if( pIesLocal && !pScanResult->pvIes )
4199 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304200 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004201 }
4202 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004203 return( eRoamState );
4204}
4205
Jeff Johnson295189b2012-06-20 16:38:30 -07004206eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4207 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4208{
4209 eHalStatus status = eHAL_STATUS_SUCCESS;
4210 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304211 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004212 roamInfo.pBssDesc = pBssDesc;
4213 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4214 return (status);
4215}
Jeff Johnson295189b2012-06-20 16:38:30 -07004216//In case no matching BSS is found, use whatever default we can find
4217static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4218{
4219 //Need to get all negotiated types in place first
4220 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004221 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004222 {
4223 default:
4224 case eCSR_AUTH_TYPE_WPA:
4225 case eCSR_AUTH_TYPE_WPA_PSK:
4226 case eCSR_AUTH_TYPE_WPA_NONE:
4227 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4228 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4229 break;
4230
4231 case eCSR_AUTH_TYPE_SHARED_KEY:
4232 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4233 break;
4234
4235 case eCSR_AUTH_TYPE_AUTOSWITCH:
4236 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4237 break;
4238 }
4239 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4240 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4241 //In this case, the multicast encryption needs to follow the uncast ones.
4242 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4243 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4244}
4245
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004246
4247static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4248{
4249 switch(pCommand->u.roamCmd.roamReason)
4250 {
4251 case eCsrLostLink1:
4252 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4253 break;
4254 case eCsrLostLink2:
4255 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4256 break;
4257 case eCsrLostLink3:
4258 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4259 break;
4260 default:
4261 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4262 pCommand->u.roamCmd.roamReason);
4263 break;
4264 }
4265}
4266
Jeff Johnson295189b2012-06-20 16:38:30 -07004267static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4268{
4269 eHalStatus status;
4270 tCsrScanResult *pScanResult = NULL;
4271 eCsrJoinState eRoamState = eCsrStopRoaming;
4272 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4273 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4274 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4275#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4276 v_U8_t acm_mask = 0;
4277#endif
4278 tANI_U32 sessionId = pCommand->sessionId;
4279 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4280 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4281 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004282
4283 if(!pSession)
4284 {
4285 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4286 return (eCsrStopRoaming);
4287 }
4288
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 do
4290 {
4291 // Check for Cardbus eject condition, before trying to Roam to any BSS
4292 //***if( !balIsCardPresent(pAdapter) ) break;
4293
Kiet Lam64c1b492013-07-12 13:56:44 +05304294 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304295 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 if(NULL != pBSSList)
4297 {
4298 // When handling AP's capability change, continue to associate to
4299 // same BSS and make sure pRoamBssEntry is not Null.
4300 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4301 {
4302 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4303 {
4304 //Try the first BSS
4305 pCommand->u.roamCmd.pLastRoamBss = NULL;
4306 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4307 }
4308 else
4309 {
4310 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4311 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4312 {
4313 //Done with all the BSSs
4314 //In this case, will tell HDD the completion
4315 break;
4316 }
4317 else
4318 {
4319 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304320 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004321 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4322 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4323 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4324 pRoamInfo = &roamInfo;
4325 }
4326 }
4327 while(pCommand->u.roamCmd.pRoamBssEntry)
4328 {
4329 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004330 /*If concurrency enabled take the concurrent connected channel first. */
4331 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304332 if (vos_concurrent_open_sessions_running() &&
4333 !csrIsValidMcConcurrentSession(pMac, sessionId,
4334 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004335 {
4336 concurrentChannel =
4337 csrGetConcurrentOperationChannel(pMac);
4338 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004339 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004340 if ((concurrentChannel) &&
4341 (concurrentChannel ==
4342 pScanResult->Result.BssDescriptor.channelId))
4343 {
4344 //make this 0 because we do not want the
4345 //below check to pass as we don't want to
4346 //connect on other channel
4347 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4348 FL("Concurrent channel match =%d"),
4349 concurrentChannel);
4350 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004351 }
4352 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004353
4354 if (!concurrentChannel)
4355 {
4356
4357 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4358 sessionId, &pScanResult->Result.BssDescriptor,
4359 pCommand->u.roamCmd.roamId)))
4360 {
4361 //Ok to roam this
4362 break;
4363 }
4364 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004365 else
4366 {
4367 eRoamState = eCsrStopRoamingDueToConcurrency;
4368 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4370 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4371 {
4372 //Done with all the BSSs
4373 fDone = eANI_BOOLEAN_TRUE;
4374 break;
4375 }
4376 }
4377 if(fDone)
4378 {
4379 break;
4380 }
4381 }
4382 }
4383 //We have something to roam, tell HDD when it is infra.
4384 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4385 //For WDS, the indication is eCSR_ROAM_WDS_IND
4386 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4387 {
4388 if(pRoamInfo)
4389 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004390 if(pSession->bRefAssocStartCnt)
4391 {
4392 pSession->bRefAssocStartCnt--;
4393 //Complete the last association attemp because a new one is about to be tried
4394 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4395 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004397 }
4398 }
4399 /* If the roaming has stopped, not to continue the roaming command*/
4400 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4401 {
4402 //No need to complete roaming here as it already completes
4403 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4404 pCommand->u.roamCmd.roamReason);
4405 eRoamState = eCsrStopRoaming;
4406 csrSetAbortRoamingCommand(pMac, pCommand);
4407 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004408 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304409 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 if(pScanResult)
4411 {
4412 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004413 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4414 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004415 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004416 fDone = eANI_BOOLEAN_TRUE;
4417 eRoamState = eCsrStopRoaming;
4418 break;
4419 }
4420 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4421 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4422 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4423 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4424 CSR_IS_QOS_BSS(pIesLocal) &&
4425 CSR_IS_UAPSD_BSS(pIesLocal) )
4426 {
4427#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004428 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4429 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004430#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004431 }
4432 else
4433 {
4434 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4435 }
4436 if( pIesLocal && !pScanResult->Result.pvIes)
4437 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304438 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 }
4440 }
4441 else
4442 {
4443 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4444 }
4445 roamInfo.pProfile = pProfile;
4446 pSession->bRefAssocStartCnt++;
4447 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4448 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4449 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4451 {
4452 // If this is a start IBSS profile, then we need to start the IBSS.
4453 if ( CSR_IS_START_IBSS(pProfile) )
4454 {
4455 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004456 // Attempt to start this IBSS...
4457 csrRoamAssignDefaultParam( pMac, pCommand );
4458 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4459 if(HAL_STATUS_SUCCESS(status))
4460 {
4461 if ( fSameIbss )
4462 {
4463 eRoamState = eCsrStartIbssSameIbss;
4464 }
4465 else
4466 {
4467 eRoamState = eCsrContinueRoaming;
4468 }
4469 }
4470 else
4471 {
4472 //it somehow fail need to stop
4473 eRoamState = eCsrStopRoaming;
4474 }
4475 break;
4476 }
4477 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004479 )
4480 {
4481 // Attempt to start this WDS...
4482 csrRoamAssignDefaultParam( pMac, pCommand );
4483 /* For AP WDS, we dont have any BSSDescription */
4484 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4485 if(HAL_STATUS_SUCCESS(status))
4486 {
4487 eRoamState = eCsrContinueRoaming;
4488 }
4489 else
4490 {
4491 //it somehow fail need to stop
4492 eRoamState = eCsrStopRoaming;
4493 }
4494 }
4495 else
4496 {
4497 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004498 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 eRoamState = eCsrStopRoaming;
4500 break;
4501 }
4502 }
4503 else //We have BSS
4504 {
4505 //Need to assign these value because they are used in csrIsSameProfile
4506 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004507 /* The OSEN IE doesn't provide the cipher suite.
4508 * Therefore set to constant value of AES */
4509 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4510 {
4511 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4512 eCSR_ENCRYPT_TYPE_AES;
4513 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4514 eCSR_ENCRYPT_TYPE_AES;
4515 }
4516 else
4517 {
4518 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4519 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4520 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4521 pScanResult->mcEncryptionType;
4522 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4524 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4525 {
4526 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4527 {
4528 eRoamState = eCsrStartIbssSameIbss;
4529 break;
4530 }
4531 }
4532 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4533 {
4534 //trying to connect to the one already connected
4535 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4536 eRoamState = eCsrReassocToSelfNoCapChange;
4537 break;
4538 }
4539 // Attempt to Join this Bss...
4540 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4541 break;
4542 }
4543
4544 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4546 {
4547 //Need to indicate association_completion if association_start has been done
4548 if(pSession->bRefAssocStartCnt > 0)
4549 {
4550 pSession->bRefAssocStartCnt--;
4551 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004552 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004553 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4554 eCSR_ROAM_ASSOCIATION_COMPLETION,
4555 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4556 }
4557 }
4558
4559 return( eRoamState );
4560}
4561
Jeff Johnson295189b2012-06-20 16:38:30 -07004562static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4563{
4564 eHalStatus status = eHAL_STATUS_SUCCESS;
4565 eCsrJoinState RoamState;
4566 tANI_U32 sessionId = pCommand->sessionId;
4567
Jeff Johnson295189b2012-06-20 16:38:30 -07004568 //***if( hddIsRadioStateOn( pAdapter ) )
4569 {
4570 // Attept to join a Bss...
4571 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004572
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004574 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 {
4576 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004577 // and if connected in Infrastructure mode...
4578 if ( csrIsConnStateInfra(pMac, sessionId) )
4579 {
4580 //... then we need to issue a disassociation
4581 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4582 if(!HAL_STATUS_SUCCESS(status))
4583 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004584 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004585 //roam command is completed by caller in the failed case
4586 fComplete = eANI_BOOLEAN_TRUE;
4587 }
4588 }
4589 else if( csrIsConnStateIbss(pMac, sessionId) )
4590 {
4591 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4592 if(!HAL_STATUS_SUCCESS(status))
4593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004594 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004595 //roam command is completed by caller in the failed case
4596 fComplete = eANI_BOOLEAN_TRUE;
4597 }
4598 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004599 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4600 {
4601 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4602 if(!HAL_STATUS_SUCCESS(status))
4603 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004604 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004605 //roam command is completed by caller in the failed case
4606 fComplete = eANI_BOOLEAN_TRUE;
4607 }
4608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004609 else
4610 {
4611 fComplete = eANI_BOOLEAN_TRUE;
4612 }
4613 if(fComplete)
4614 {
4615 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004616 if(eCsrStopRoamingDueToConcurrency == RoamState)
4617 {
4618 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4619 }
4620 else
4621 {
4622 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4623 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004624 }
4625 }
4626 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4627 {
4628 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4629 }
4630 else if ( eCsrStartIbssSameIbss == RoamState )
4631 {
4632 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4633 }
4634 }//hddIsRadioStateOn
4635
4636 return status;
4637}
Jeff Johnson295189b2012-06-20 16:38:30 -07004638eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4639{
4640 tANI_U32 sessionId;
4641 tCsrRoamSession *pSession;
4642 tCsrScanResult *pScanResult = NULL;
4643 tSirBssDescription *pBssDesc = NULL;
4644 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 sessionId = pCommand->sessionId;
4646 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004647
4648 if(!pSession)
4649 {
4650 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4651 return eHAL_STATUS_FAILURE;
4652 }
4653
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4655 {
4656 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004657 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004658 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4659 return eHAL_STATUS_FAILURE;
4660 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004661 if (pCommand->u.roamCmd.pRoamBssEntry)
4662 {
4663 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4664 pBssDesc = &pScanResult->Result.BssDescriptor;
4665 }
4666 else
4667 {
4668 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004669 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004670 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4671 return eHAL_STATUS_FAILURE;
4672 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4674 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4675 return status;
4676}
4677
Jeff Johnson295189b2012-06-20 16:38:30 -07004678eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4679{
4680 eHalStatus status = eHAL_STATUS_SUCCESS;
4681 tCsrRoamInfo roamInfo;
4682 tANI_U32 sessionId = pCommand->sessionId;
4683 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004684
4685 if(!pSession)
4686 {
4687 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4688 return eHAL_STATUS_FAILURE;
4689 }
Abhishek Singhf4669da2014-05-26 15:07:49 +05304690
Jeff Johnson295189b2012-06-20 16:38:30 -07004691 switch ( pCommand->u.roamCmd.roamReason )
4692 {
4693 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004695 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004696 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004697 case eCsrSmeIssuedDisassocForHandoff:
4698 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4699#if 0 // TODO : Confirm this change
4700 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4701#else
4702 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4703#endif
4704
4705 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004706 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004707 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004708 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004710 case eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004711 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004712 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004713 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004714 case eCsrHddIssuedReassocToSameAP:
4715 case eCsrSmeIssuedReassocToSameAP:
4716 {
4717 tDot11fBeaconIEs *pIes = NULL;
4718
Jeff Johnson295189b2012-06-20 16:38:30 -07004719 if( pSession->pConnectBssDesc )
4720 {
4721 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4722 if(!HAL_STATUS_SUCCESS(status) )
4723 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004724 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004725 }
4726 else
4727 {
4728 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4729 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4730 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004731 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4732 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4733 pSession->bRefAssocStartCnt++;
4734 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4735 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4736
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004737 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004738 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4739 &pCommand->u.roamCmd.roamProfile );
4740 if(!HAL_STATUS_SUCCESS(status))
4741 {
4742 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004743 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004744 }
4745
Kiet Lam64c1b492013-07-12 13:56:44 +05304746 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004747 pIes = NULL;
4748 }
4749 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05304750 else
4751 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004752 break;
4753 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004755 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004756 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4757 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4758 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004760 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004761 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4762 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004763
Jeff Johnson295189b2012-06-20 16:38:30 -07004764 case eCsrStopBss:
4765 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4766 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4767 break;
4768
4769 case eCsrForcedDisassocSta:
4770 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4771 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4772 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4773 pCommand->u.roamCmd.reason);
4774 break;
4775
4776 case eCsrForcedDeauthSta:
4777 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4778 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4779 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4780 pCommand->u.roamCmd.reason);
4781 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004782
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004783 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004784 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004785 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4786 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004787 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004788
4789 default:
4790 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4791
4792 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4793 {
4794 //Remember the roaming profile
4795 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304796 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4797 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004798 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304799 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004800 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4801 }
4802 }
4803
4804 //At this point, original uapsd_mask is saved in pCurRoamProfile
4805 //uapsd_mask in the pCommand may change from this point on.
4806
4807 // Attempt to roam with the new scan results (if we need to..)
4808 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004809 if(!HAL_STATUS_SUCCESS(status))
4810 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004811 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004812 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004813 break;
4814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004815 return (status);
4816}
4817
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004818void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4819{
4820 pCommand->u.roamCmd.pLastRoamBss = NULL;
4821 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4822 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304823 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004824}
4825
Jeff Johnson295189b2012-06-20 16:38:30 -07004826void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4827{
4828 if(pCommand->u.roamCmd.fReleaseBssList)
4829 {
4830 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4831 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4832 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4833 }
4834 if(pCommand->u.roamCmd.fReleaseProfile)
4835 {
4836 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4837 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4838 }
4839 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4840 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304841 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004842}
4843
Jeff Johnson295189b2012-06-20 16:38:30 -07004844void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4845{
Kiet Lam64c1b492013-07-12 13:56:44 +05304846 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004847}
Jeff Johnson295189b2012-06-20 16:38:30 -07004848void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4849{
4850 tListElem *pEntry;
4851 tSmeCmd *pCommand;
4852 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004853 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004854 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4855 if ( pEntry )
4856 {
4857 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 // If the head of the queue is Active and it is a ROAM command, remove
4859 // and put this on the Free queue.
4860 if ( eSmeCommandRoam == pCommand->command )
4861 {
4862 //we need to process the result first before removing it from active list because state changes
4863 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4864 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4865 if( fReleaseCommand )
4866 {
4867 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4868 {
4869 csrReleaseCommandRoam( pMac, pCommand );
4870 }
4871 else
4872 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004873 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004874 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004875 }
4876 }
4877 else
4878 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004879 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004880 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004881 }
4882 }
4883 else
4884 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004885 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004886 }
4887 }
4888 else
4889 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004890 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004892 if( fReleaseCommand )
4893 {
4894 smeProcessPendingQueue( pMac );
4895 }
4896}
4897
Jeff Johnson295189b2012-06-20 16:38:30 -07004898void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4899{
4900 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004901 if(!pSession)
4902 {
4903 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4904 return;
4905 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304906 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4907 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 pSession->NumPmkidCandidate = 0;
4909}
Jeff Johnson295189b2012-06-20 16:38:30 -07004910#ifdef FEATURE_WLAN_WAPI
4911void csrResetBKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4912{
4913 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004914 if(!pSession)
4915 {
4916 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4917 return;
4918 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304919 vos_mem_set(&(pSession->BkidCandidateInfo[0]),
4920 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004921 pSession->NumBkidCandidate = 0;
4922}
4923#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004924extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4925
Jeff Johnson295189b2012-06-20 16:38:30 -07004926static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4927 tSirBssDescription *pSirBssDesc,
4928 tDot11fBeaconIEs *pIes)
4929{
4930 eHalStatus status = eHAL_STATUS_SUCCESS;
4931 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4932 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004933
4934 if(!pSession)
4935 {
4936 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4937 return eHAL_STATUS_FAILURE;
4938 }
4939
Jeff Johnson295189b2012-06-20 16:38:30 -07004940 if((eCSR_AUTH_TYPE_WPA == authType) ||
4941 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4942 (eCSR_AUTH_TYPE_RSN == authType) ||
4943 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4944#if defined WLAN_FEATURE_VOWIFI_11R
4945 ||
4946 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4947 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4948#endif /* FEATURE_WLAN_WAPI */
4949#ifdef FEATURE_WLAN_WAPI
4950 ||
4951 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4952 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4953#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004954#ifdef WLAN_FEATURE_11W
4955 ||
Abhishek Singhae408032014-09-25 17:22:04 +05304956 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4957 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
Chet Lanctot186b5732013-03-18 10:26:30 -07004958#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004959 )
4960 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004961 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4962 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004963 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004964 }
4965 if( pIesLocal )
4966 {
4967 tANI_U32 nIeLen;
4968 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 if((eCSR_AUTH_TYPE_RSN == authType) ||
4970#if defined WLAN_FEATURE_VOWIFI_11R
4971 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4972 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4973#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004974#if defined WLAN_FEATURE_11W
4975 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
Abhishek Singhae408032014-09-25 17:22:04 +05304976 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType) ||
Chet Lanctot186b5732013-03-18 10:26:30 -07004977#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004978 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4979 {
4980 if(pIesLocal->RSN.present)
4981 {
4982 //Calculate the actual length
4983 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4984 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4985 + 2 //akm_suite_count
4986 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4987 + 2; //reserved
4988 if( pIesLocal->RSN.pmkid_count )
4989 {
4990 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4991 }
4992 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304993 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4994 if (NULL == pSession->pWpaRsnRspIE)
4995 status = eHAL_STATUS_FAILURE;
4996 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004997 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304998 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004999 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
5000 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5001 //copy upto akm_suites
5002 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05305003 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
5004 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005005 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05305006 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
5007 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005008 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05305009 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
5010 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07005011 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07005012 if( pIesLocal->RSN.pwise_cipher_suite_count )
5013 {
5014 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305015 vos_mem_copy(pIeBuf,
5016 pIesLocal->RSN.pwise_cipher_suites,
5017 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005018 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
5019 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305020 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005021 pIeBuf += 2;
5022 if( pIesLocal->RSN.akm_suite_count )
5023 {
5024 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305025 vos_mem_copy(pIeBuf,
5026 pIesLocal->RSN.akm_suites,
5027 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005028 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
5029 }
5030 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05305031 vos_mem_copy(pIeBuf,
5032 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
5033 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005034 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5035 }
5036 }
5037 }
5038 else if((eCSR_AUTH_TYPE_WPA == authType) ||
5039 (eCSR_AUTH_TYPE_WPA_PSK == authType))
5040 {
5041 if(pIesLocal->WPA.present)
5042 {
5043 //Calculate the actual length
5044 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
5045 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
5046 + 2 //auth_suite_count
5047 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
5048 // The WPA capabilities follows the Auth Suite (two octects)--
5049 // this field is optional, and we always "send" zero, so just
5050 // remove it. This is consistent with our assumptions in the
5051 // frames compiler; c.f. bug 15234:
5052 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305053
5054 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5055 if ( NULL == pSession->pWpaRsnRspIE )
5056 status = eHAL_STATUS_FAILURE;
5057 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005058 {
5059 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5060 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5061 pIeBuf = pSession->pWpaRsnRspIE + 2;
5062 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305063 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005064 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305065 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5066 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005067 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305068 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5069 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005070 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5071 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5072 }
5073 }
5074 }
5075#ifdef FEATURE_WLAN_WAPI
5076 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5077 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5078 {
5079 if(pIesLocal->WAPI.present)
5080 {
5081 //Calculate the actual length
5082 nIeLen = 4 //version + akm_suite_count
5083 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5084 + 2 //pwise_cipher_suite_count
5085 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5086 + 6; //gp_cipher_suite + preauth + reserved
5087 if( pIesLocal->WAPI.bkid_count )
5088 {
5089 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5090 }
5091
5092 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305093 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5094 if ( NULL == pSession->pWapiRspIE )
5095 status = eHAL_STATUS_FAILURE;
5096 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005097 {
5098 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5099 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5100 pIeBuf = pSession->pWapiRspIE + 2;
5101 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305102 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005103 pIeBuf += 4;
5104 if( pIesLocal->WAPI.akm_suite_count )
5105 {
5106 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305107 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5108 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005109 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305110 }
5111 vos_mem_copy(pIeBuf,
5112 &pIesLocal->WAPI.unicast_cipher_suite_count,
5113 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005114 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005115 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5116 {
5117 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305118 vos_mem_copy( pIeBuf,
5119 pIesLocal->WAPI.unicast_cipher_suites,
5120 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005121 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5122 }
lukez3c809222013-05-03 10:23:02 -07005123 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305124 vos_mem_copy(pIeBuf,
5125 pIesLocal->WAPI.multicast_cipher_suite,
5126 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005127 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305128 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305129 vos_mem_copy(pIeBuf,
5130 pIesLocal->WAPI.multicast_cipher_suite + 4,
5131 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005132 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305133 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305134 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5135
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005136 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005137 if( pIesLocal->WAPI.bkid_count )
5138 {
5139 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305140 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5141 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005142 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5143 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305144 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005145 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005146 }
5147 }
5148#endif /* FEATURE_WLAN_WAPI */
5149 if( !pIes )
5150 {
5151 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305152 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005153 }
5154 }
5155 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005156 return (status);
5157}
5158
Jeff Johnson295189b2012-06-20 16:38:30 -07005159static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5160{
5161 v_U8_t bACWeights[WLANTL_MAX_AC];
5162 v_U8_t paramBk, paramBe, paramVi, paramVo;
5163 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005164 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5165 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5166 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5167 //This doesn't address the case where the lower AC needs a real higher weight
5168 if( pIEs->WMMParams.present )
5169 {
5170 //no change to the lowest ones
5171 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5172 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5173 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5174 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5175 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5176 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5177 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5178 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5179 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5180 {
5181 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5182 fWeightChange = VOS_TRUE;
5183 }
5184 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5185 {
5186 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5187 fWeightChange = VOS_TRUE;
5188 }
5189 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5190 {
5191 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5192 fWeightChange = VOS_TRUE;
5193 }
5194 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5195 {
5196 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5197 fWeightChange = VOS_TRUE;
5198 }
5199 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5200 {
5201 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5202 fWeightChange = VOS_TRUE;
5203 }
5204 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5205 {
5206 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5207 fWeightChange = VOS_TRUE;
5208 }
5209 if(fWeightChange)
5210 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005211 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005212 bACWeights[2], bACWeights[3]);
5213 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5214 }
5215 }
5216}
Jeff Johnson295189b2012-06-20 16:38:30 -07005217#ifdef WLAN_FEATURE_VOWIFI_11R
5218//Returns whether the current association is a 11r assoc or not
5219tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5220{
5221#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5222 return csrNeighborRoamIs11rAssoc(pMac);
5223#else
5224 return eANI_BOOLEAN_FALSE;
5225#endif
5226}
5227#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005228#ifdef FEATURE_WLAN_ESE
5229//Returns whether the current association is a ESE assoc or not
5230tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005231{
5232#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005233 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005234#else
5235 return eANI_BOOLEAN_FALSE;
5236#endif
5237}
5238#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005239#ifdef FEATURE_WLAN_LFR
5240//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305241tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005242{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305243 tCsrRoamSession *pSession = NULL;
5244
5245 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5246 {
5247 pSession = CSR_GET_SESSION( pMac, sessionId );
5248 if (NULL != pSession->pCurRoamProfile)
5249 {
5250 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5251 {
5252 return eANI_BOOLEAN_FALSE;
5253 }
5254 }
5255 }
5256
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005257#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5258 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5259 {
5260 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5261 }
5262 else
5263#endif
5264 {
5265 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005266 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005267 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005268}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005269
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005270#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005271/* ---------------------------------------------------------------------------
5272
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005273 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005274
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005275 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005276
5277 \param pMac - The handle returned by macOpen.
5278
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005279 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005280
5281---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005282tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005283{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005284 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005285}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005286#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005287
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005288#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5289//Returns whether "FW based BG scan" is currently enabled...or not
5290tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5291{
5292 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5293}
5294#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005295#endif
5296
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005297#if defined(FEATURE_WLAN_ESE)
5298tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005299{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005300 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005301}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005302#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005303
Jeff Johnson295189b2012-06-20 16:38:30 -07005304//Return true means the command can be release, else not
5305static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5306 eCsrRoamCompleteResult Result, void *Context )
5307{
5308 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5309 tSirBssDescription *pSirBssDesc = NULL;
5310 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5311 tCsrScanResult *pScanResult = NULL;
5312 tCsrRoamInfo roamInfo;
5313 sme_QosAssocInfo assocInfo;
5314 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5315 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5316 tDot11fBeaconIEs *pIes = NULL;
5317 tANI_U32 sessionId = pCommand->sessionId;
5318 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5319 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5320 eRoamCmdStatus roamStatus;
5321 eCsrRoamResult roamResult;
5322 eHalStatus status;
5323 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005324 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005325
Jeff Johnson32d95a32012-09-10 13:15:23 -07005326 if(!pSession)
5327 {
5328 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5329 return eANI_BOOLEAN_FALSE;
5330 }
5331
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005332 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 switch( Result )
5334 {
5335 case eCsrJoinSuccess:
5336 // reset the IDLE timer
5337 // !!
5338 // !! fall through to the next CASE statement here is intentional !!
5339 // !!
5340 case eCsrReassocSuccess:
5341 if(eCsrReassocSuccess == Result)
5342 {
5343 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5344 }
5345 else
5346 {
5347 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5348 }
5349 // Success Join Response from LIM. Tell NDIS we are connected and save the
5350 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005351 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305352 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 //always free the memory here
5354 if(pSession->pWpaRsnRspIE)
5355 {
5356 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305357 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005358 pSession->pWpaRsnRspIE = NULL;
5359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005360#ifdef FEATURE_WLAN_WAPI
5361 if(pSession->pWapiRspIE)
5362 {
5363 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305364 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005365 pSession->pWapiRspIE = NULL;
5366 }
5367#endif /* FEATURE_WLAN_WAPI */
5368#ifdef FEATURE_WLAN_BTAMP_UT_RF
5369 //Reset counter so no join retry is needed.
5370 pSession->maxRetryCount = 0;
5371 csrRoamStopJoinRetryTimer(pMac, sessionId);
5372#endif
5373 /* This creates problem since we have not saved the connected profile.
5374 So moving this after saving the profile
5375 */
5376 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305377
5378 /* Reset remainInPowerActiveTillDHCP as it might have been set
5379 * by last failed secured connection.
5380 * It should be set only for secured connection.
5381 */
5382 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005383 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5384 {
5385 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5386 }
5387 else
5388 {
5389 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5390 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005391 //Use the last connected bssdesc for reassoc-ing to the same AP.
5392 //NOTE: What to do when reassoc to a different AP???
5393 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5394 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5395 {
5396 pSirBssDesc = pSession->pConnectBssDesc;
5397 if(pSirBssDesc)
5398 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305399 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5400 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005401 }
5402 }
5403 else
5404 {
5405
5406 if(pCommand->u.roamCmd.pRoamBssEntry)
5407 {
5408 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5409 if(pScanResult != NULL)
5410 {
5411 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5412 //this can be NULL
5413 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305414 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5415 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005416 }
5417 }
5418 }
5419 if( pSirBssDesc )
5420 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005421 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005422 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5423 //Save WPA/RSN IE
5424 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005425#ifdef FEATURE_WLAN_ESE
5426 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005427#endif
Mukul Sharma9ca96b22014-11-15 19:40:04 +05305428#ifdef WLAN_FEATURE_VOWIFI_11R
5429 if (pSirBssDesc->mdiePresent)
5430 {
5431 if(csrIsAuthType11r(pProfile->negotiatedAuthType, VOS_TRUE)
5432#ifdef FEATURE_WLAN_ESE
5433 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
5434 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
5435#endif
5436 )
5437 {
5438 // is11Rconnection;
5439 roamInfo.is11rAssoc = VOS_TRUE;
5440 }
5441 else
5442 {
5443 // is11Rconnection;
5444 roamInfo.is11rAssoc = VOS_FALSE;
5445 }
5446 }
5447#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005448 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5449 // substate change.
5450 // Moving even save profile above so that below mentioned conditon is also met.
5451 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5452 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005453 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5454 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5455 // will be dropped for the security context may not be set properly.
5456 //
5457 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5458 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5459 //
5460 // this reordering was done on titan_prod_usb branch and is being replicated here.
5461 //
5462
5463 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5464 !pProfile->bWPSAssociation)
5465 {
5466 // Issue the set Context request to LIM to establish the Unicast STA context
5467 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5468 pProfile->negotiatedUCEncryptionType,
5469 pSirBssDesc, &(pSirBssDesc->bssId),
5470 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5471 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005472 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005473 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5474 }
5475 // Issue the set Context request to LIM to establish the Broadcast STA context
5476 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5477 pSirBssDesc, &BroadcastMac,
5478 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5479 }
5480 else
5481 {
5482 //Need to wait for supplicant authtication
5483 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005484 //Set the subestate to WaitForKey in case authentiation is needed
5485 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5486
Jeff Johnson295189b2012-06-20 16:38:30 -07005487 if(pProfile->bWPSAssociation)
5488 {
5489 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5490 }
5491 else
5492 {
5493 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5494 }
5495
5496 //Save sessionId in case of timeout
5497 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5498 //This time should be long enough for the rest of the process plus setting key
5499 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5500 {
5501 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005502 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005503 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5504 }
5505 }
5506
5507 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5508 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 if(Context)
5510 {
5511 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5512 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005513 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5514 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5515#ifdef WLAN_FEATURE_VOWIFI_11R
5516 len += pJoinRsp->parsedRicRspLen;
5517#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005518#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005519 len += pJoinRsp->tspecIeLen;
5520#endif
5521 if(len)
5522 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305523 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5524 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005525 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305526 vos_mem_copy(pSession->connectedInfo.pbFrames,
5527 pJoinRsp->frames, len);
5528 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5529 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5530 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005531#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305532 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005533#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005534#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305535 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005536#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305537 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5538 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5539 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5540 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005541 }
5542 }
5543 if(pCommand->u.roamCmd.fReassoc)
5544 {
5545 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5546 }
5547 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5548 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5549 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5550 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305551 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005552 }
5553 else
5554 {
5555 if(pCommand->u.roamCmd.fReassoc)
5556 {
5557 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5558 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5559 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5560 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5561 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5562 }
5563 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305564 /* Update the staId from the previous connected profile info
5565 as the reassociation is triggred at SME/HDD */
5566 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5567 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5568 {
5569 roamInfo.staId = pSession->connectedInfo.staId;
5570 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005571#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5572 // Indicate SME-QOS with reassoc success event, only after
5573 // copying the frames
5574 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5575#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005576 roamInfo.pBssDesc = pSirBssDesc;
5577 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5578 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5579#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5580 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5581#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5582 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005583 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5584 //It may be better to let QoS do this????
5585 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5586 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005587 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005588 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5589 pmcStartUapsd( pMac, NULL, NULL );
5590 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305591 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005592 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5593 if( pSession->bRefAssocStartCnt > 0 )
5594 {
5595 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005596 //Remove this code once SLM_Sessionization is supported
5597 //BMPS_WORKAROUND_NOT_NEEDED
5598 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005599 {
5600 pMac->roam.configParam.doBMPSWorkaround = 1;
5601 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005602 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5603 }
5604
5605 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005606 // reset the PMKID candidate list
5607 csrResetPMKIDCandidateList( pMac, sessionId );
5608 //Update TL's AC weight base on the current EDCA parameters
5609 //These parameters may change in the course of the connection, that sictuation
5610 //is not taken care here. This change is mainly to address a WIFI WMM test where
5611 //BE has a equal or higher TX priority than VI.
5612 //We only do this for infra link
5613 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5614 {
5615 csrCheckAndUpdateACWeight(pMac, pIes);
5616 }
5617#ifdef FEATURE_WLAN_WAPI
5618 // reset the BKID candidate list
5619 csrResetBKIDCandidateList( pMac, sessionId );
5620#endif /* FEATURE_WLAN_WAPI */
5621 }
5622 else
5623 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005624 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005625 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005626 csrScanCancelIdleScan(pMac);
5627 //Not to signal link up because keys are yet to be set.
5628 //The linkup function will overwrite the sub-state that we need to keep at this point.
5629 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5630 {
5631 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5632 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5634 //enough to let security and DHCP handshake succeed before entry into BMPS
5635 if (pmcShouldBmpsTimerRun(pMac))
5636 {
Abhishek Singh65d939e2014-04-25 13:33:07 +05305637 /* Set remainInPowerActiveTillDHCP to make sure we wait for
5638 * until keys are set before going into BMPS.
5639 */
5640 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5641 {
5642 pMac->pmc.remainInPowerActiveTillDHCP = TRUE;
5643 smsLog(pMac, LOG1, FL("Set remainInPowerActiveTillDHCP "
5644 "to make sure we wait until keys are set before"
5645 " going to BMPS"));
5646 }
5647
Jeff Johnson295189b2012-06-20 16:38:30 -07005648 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5649 != eHAL_STATUS_SUCCESS)
5650 {
5651 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5652 }
5653 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5654 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 break;
5656
Jeff Johnson295189b2012-06-20 16:38:30 -07005657 case eCsrStartBssSuccess:
5658 // on the StartBss Response, LIM is returning the Bss Description that we
5659 // are beaconing. Add this Bss Description to our scan results and
5660 // chain the Profile to this Bss Description. On a Start BSS, there was no
5661 // detected Bss description (no partner) so we issued the Start Bss to
5662 // start the Ibss without any Bss description. Lim was kind enough to return
5663 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005664 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005665 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005666 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305667 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005668 if( CSR_IS_IBSS( pProfile ) )
5669 {
5670 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005672 else if (CSR_IS_INFRA_AP(pProfile))
5673 {
5674 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5675 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005676 else
5677 {
5678 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5679 }
5680 if( !CSR_IS_WDS_STA( pProfile ) )
5681 {
5682 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005683 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005684 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5685 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305686 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005687 roamInfo.pBssDesc = pSirBssDesc;
5688 //We need to associate_complete it first, becasue Associate_start already indicated.
5689 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5690 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5691 break;
5692 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005693 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005694 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005695 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 }
5697 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5698 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5699 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5700 if(pSirBssDesc)
5701 {
5702 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305703 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5704 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005705 }
5706 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305707 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005708#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5709 {
5710 vos_log_ibss_pkt_type *pIbssLog;
5711 tANI_U32 bi;
5712
5713 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5714 if(pIbssLog)
5715 {
5716 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5717 {
5718 //We start the IBSS (didn't find any matched IBSS out there)
5719 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5720 }
5721 else
5722 {
5723 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5724 }
5725 if(pSirBssDesc)
5726 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305727 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005728 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5729 }
5730 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5731 {
5732 //***U8 is not enough for beacon interval
5733 pIbssLog->beaconInterval = (v_U8_t)bi;
5734 }
5735 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5736 }
5737 }
5738#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5739 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5740 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005741 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5742 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005743 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5744 csrRoamIssueSetContextReq( pMac, sessionId,
5745 pProfile->negotiatedMCEncryptionType,
5746 pSirBssDesc, &BroadcastMac,
5747 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5748 }
5749 }
5750 else
5751 {
5752 //Keep the state to eCSR_ROAMING_STATE_JOINING
5753 //Need to send join_req.
5754 if(pCommand->u.roamCmd.pRoamBssEntry)
5755 {
5756 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5757 {
5758 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5759 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5760 // Set the roaming substate to 'join attempt'...
5761 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005762 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005763 }
5764 }
5765 else
5766 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005767 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005768 VOS_ASSERT( 0 );
5769 }
5770 }
5771 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5772 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5773 //trigger the connection start indication in Vista
5774 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5775 {
5776 roamStatus = eCSR_ROAM_IBSS_IND;
5777 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5778 if( CSR_IS_WDS( pProfile ) )
5779 {
5780 roamStatus = eCSR_ROAM_WDS_IND;
5781 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5782 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005783 if( CSR_IS_INFRA_AP( pProfile ) )
5784 {
5785 roamStatus = eCSR_ROAM_INFRA_IND;
5786 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5787 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005788
5789 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5790 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5791 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305792 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005793 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5794 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005795 //We start the IBSS (didn't find any matched IBSS out there)
5796 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005797 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305798 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5799 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005800 //Remove this code once SLM_Sessionization is supported
5801 //BMPS_WORKAROUND_NOT_NEEDED
5802 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005803 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005804 {
5805 pMac->roam.configParam.doBMPSWorkaround = 1;
5806 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005807
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5809 }
5810
5811 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005812
5813 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005814 {
5815 //need to send stop BSS because we fail to send join_req
5816 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5817 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5818 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005820 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005821 case eCsrStartBssFailure:
5822#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5823 {
5824 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005825 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5826 if(pIbssLog)
5827 {
5828 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5829 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5830 }
5831 }
5832#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005833 roamStatus = eCSR_ROAM_IBSS_IND;
5834 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5835 if( CSR_IS_WDS( pProfile ) )
5836 {
5837 roamStatus = eCSR_ROAM_WDS_IND;
5838 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 if( CSR_IS_INFRA_AP( pProfile ) )
5841 {
5842 roamStatus = eCSR_ROAM_INFRA_IND;
5843 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5844 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005845 if(Context)
5846 {
5847 pSirBssDesc = (tSirBssDescription *)Context;
5848 }
5849 else
5850 {
5851 pSirBssDesc = NULL;
5852 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305853 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005854 roamInfo.pBssDesc = pSirBssDesc;
5855 //We need to associate_complete it first, becasue Associate_start already indicated.
5856 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5857 csrSetDefaultDot11Mode( pMac );
5858 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005859 case eCsrSilentlyStopRoaming:
5860 // We are here because we try to start the same IBSS
5861 //No message to PE
5862 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005863 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005864 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5865 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305866 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005867 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5868 if( roamInfo.pBssDesc )
5869 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305870 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5871 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005872 }
5873 //Since there is no change in the current state, simply pass back no result otherwise
5874 //HDD may be mistakenly mark to disconnected state.
5875 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5876 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005877 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005878 case eCsrSilentlyStopRoamingSaveState:
5879 //We are here because we try to connect to the same AP
5880 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005881 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305882 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005883
5884 //to aviod resetting the substate to NONE
5885 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5886 //No need to change substate to wai_for_key because there is no state change
5887 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5888 if( roamInfo.pBssDesc )
5889 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305890 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5891 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005892 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5894 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5895 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5896 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5897 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5898 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5899 roamInfo.staId = pSession->connectedInfo.staId;
5900 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005901 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005902 pSession->bRefAssocStartCnt--;
5903 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5904 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5905 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5906 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005907 case eCsrReassocFailure:
5908#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5909 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5910#endif
5911 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005912 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005913 csrFreeConnectBssDesc(pMac, sessionId);
5914 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5915 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305916 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005917 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5918 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5919 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5920 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5921 eCSR_ROAM_WDS_IND,
5922 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5923 //Need to issue stop_bss
5924 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005925 case eCsrJoinFailure:
5926 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005927 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005928 default:
5929 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005930 smsLog(pMac, LOGW, FL("receives no association indication"));
5931 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005932 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005933 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5934 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5935 {
5936 //do not free for the other profiles as we need to send down stop BSS later
5937 csrFreeConnectBssDesc(pMac, sessionId);
5938 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5939 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5940 csrSetDefaultDot11Mode( pMac );
5941 }
5942
5943 switch( pCommand->u.roamCmd.roamReason )
5944 {
5945 // If this transition is because of an 802.11 OID, then we transition
5946 // back to INIT state so we sit waiting for more OIDs to be issued and
5947 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005948 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005949 case eCsrSmeIssuedAssocToSimilarAP:
5950 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005951 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005952 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305953 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005954 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5955 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5956 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305957 vos_mem_copy(&roamInfo.bssid,
5958 &pSession->joinFailStatusCode.bssId,
5959 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005960
Jeff Johnson295189b2012-06-20 16:38:30 -07005961 /* Defeaturize this later if needed */
5962#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5963 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5964 if (csrRoamIsHandoffInProgress(pMac))
5965 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005966 /* Should indicate neighbor roam algorithm about the connect failure here */
5967 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5968 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005969#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005970 if(pSession->bRefAssocStartCnt > 0)
5971 {
5972 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005973 if(eCsrJoinFailureDueToConcurrency == Result)
5974 {
5975 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5976 eCSR_ROAM_ASSOCIATION_COMPLETION,
5977 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5978 }
5979 else
5980 {
5981 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 eCSR_ROAM_ASSOCIATION_COMPLETION,
5983 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005984 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005985 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005986 else
5987 {
5988 /* bRefAssocStartCnt is not incremented when
5989 * eRoamState == eCsrStopRoamingDueToConcurrency
5990 * in csrRoamJoinNextBss API. so handle this in
5991 * else case by sending assoc failure
5992 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005993 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005994 pCommand->u.scanCmd.roamId,
5995 eCSR_ROAM_ASSOCIATION_FAILURE,
5996 eCSR_ROAM_RESULT_FAILURE);
5997 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005998 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005999#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05306000 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006001 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6002#endif
6003 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6004 csrScanStartIdleScan(pMac);
6005#ifdef FEATURE_WLAN_BTAMP_UT_RF
6006 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
6007 //BT activity and not able to recevie WLAN traffic. Retry the join
6008 if( CSR_IS_WDS_STA(pProfile) )
6009 {
6010 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
6011 }
6012#endif
6013 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006014 case eCsrHddIssuedReassocToSameAP:
6015 case eCsrSmeIssuedReassocToSameAP:
6016 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6017
6018 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6019#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6020 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6021#endif
6022 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6023 csrScanStartIdleScan(pMac);
6024 break;
6025 case eCsrForcedDisassoc:
6026 case eCsrForcedDeauth:
6027 case eCsrSmeIssuedIbssJoinFailure:
6028 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
6029
6030 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
6031 {
6032 // Notify HDD that IBSS join failed
6033 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
6034 }
6035 else
6036 {
6037 csrRoamCallCallback(pMac, sessionId, NULL,
6038 pCommand->u.roamCmd.roamId,
6039 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6040 }
6041#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6042 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6043#endif
6044 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006045 /*
6046 *DelSta not done FW still in conneced state so dont
6047 *issue IMPS req
6048 */
6049 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
6050 {
6051 smsLog(pMac, LOGW, FL("FW still in connected state "));
6052 break;
6053 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006054 csrScanStartIdleScan(pMac);
6055 break;
6056 case eCsrForcedIbssLeave:
6057 csrRoamCallCallback(pMac, sessionId, NULL,
6058 pCommand->u.roamCmd.roamId,
6059 eCSR_ROAM_IBSS_LEAVE,
6060 eCSR_ROAM_RESULT_IBSS_STOP);
6061 break;
6062 case eCsrForcedDisassocMICFailure:
6063 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6064
6065 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
6066#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6067 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
6068#endif
6069 csrScanStartIdleScan(pMac);
6070 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006071 case eCsrStopBss:
6072 csrRoamCallCallback(pMac, sessionId, NULL,
6073 pCommand->u.roamCmd.roamId,
6074 eCSR_ROAM_INFRA_IND,
6075 eCSR_ROAM_RESULT_INFRA_STOPPED);
6076 break;
6077 case eCsrForcedDisassocSta:
6078 case eCsrForcedDeauthSta:
6079 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
6080 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
6081 {
6082 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006083
6084 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6085 {
6086 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05306087 vos_mem_copy(roamInfo.peerMac,
6088 pCommand->u.roamCmd.peerMac,
6089 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07006090 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6091 roamInfo.statusCode = eSIR_SME_SUCCESS;
6092 status = csrRoamCallCallback(pMac, sessionId,
6093 &roamInfo, pCommand->u.roamCmd.roamId,
6094 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
6095 }
6096 }
6097 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006098 case eCsrLostLink1:
6099 // if lost link roam1 failed, then issue lost link Scan2 ...
6100 csrScanRequestLostLink2(pMac, sessionId);
6101 break;
6102 case eCsrLostLink2:
6103 // if lost link roam2 failed, then issue lost link scan3 ...
6104 csrScanRequestLostLink3(pMac, sessionId);
6105 break;
6106 case eCsrLostLink3:
6107 default:
6108 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6109
6110 //We are done with one round of lostlink roaming here
6111 csrScanHandleFailedLostlink3(pMac, sessionId);
6112 break;
6113 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006114 break;
6115 }
6116 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 return ( fReleaseCommand );
6118}
6119
Jeff Johnson295189b2012-06-20 16:38:30 -07006120eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6121{
6122 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006123 return (status);
6124}
6125
Jeff Johnson295189b2012-06-20 16:38:30 -07006126eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6127{
6128 eHalStatus status = eHAL_STATUS_SUCCESS;
6129 tANI_U32 size = 0;
6130
6131 do
6132 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306133 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006134 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6135 {
6136 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306137 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6138 if ( NULL == pDstProfile->BSSIDs.bssid )
6139 status = eHAL_STATUS_FAILURE;
6140 else
6141 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006142 if(!HAL_STATUS_SUCCESS(status))
6143 {
6144 break;
6145 }
6146 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306147 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6148 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006149 }
6150 if(pSrcProfile->SSIDs.numOfSSIDs)
6151 {
6152 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306153 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6154 if ( NULL == pDstProfile->SSIDs.SSIDList )
6155 status = eHAL_STATUS_FAILURE;
6156 else
6157 status = eHAL_STATUS_SUCCESS;
6158 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006159 {
6160 break;
6161 }
6162 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306163 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6164 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006165 }
6166 if(pSrcProfile->nWPAReqIELength)
6167 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306168 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6169 if ( NULL == pDstProfile->pWPAReqIE )
6170 status = eHAL_STATUS_FAILURE;
6171 else
6172 status = eHAL_STATUS_SUCCESS;
6173
6174 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006175 {
6176 break;
6177 }
6178 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306179 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6180 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 }
6182 if(pSrcProfile->nRSNReqIELength)
6183 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306184 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6185 if ( NULL == pDstProfile->pRSNReqIE )
6186 status = eHAL_STATUS_FAILURE;
6187 else
6188 status = eHAL_STATUS_SUCCESS;
6189
6190 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006191 {
6192 break;
6193 }
6194 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306195 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6196 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006197 }
6198#ifdef FEATURE_WLAN_WAPI
6199 if(pSrcProfile->nWAPIReqIELength)
6200 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306201 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6202 if ( NULL == pDstProfile->pWAPIReqIE )
6203 status = eHAL_STATUS_FAILURE;
6204 else
6205 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006206 if(!HAL_STATUS_SUCCESS(status))
6207 {
6208 break;
6209 }
6210 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306211 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6212 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006213 }
6214#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006215 if(pSrcProfile->nAddIEScanLength)
6216 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306217 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6218 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006219 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306220 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306221 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306222 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6223 }
6224 else
6225 {
6226 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6227 FL(" AddIEScanLength is not valid %u"),
6228 pSrcProfile->nAddIEScanLength);
6229 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006230 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006231 if(pSrcProfile->nAddIEAssocLength)
6232 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306233 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6234 if ( NULL == pDstProfile->pAddIEAssoc )
6235 status = eHAL_STATUS_FAILURE;
6236 else
6237 status = eHAL_STATUS_SUCCESS;
6238
Jeff Johnson295189b2012-06-20 16:38:30 -07006239 if(!HAL_STATUS_SUCCESS(status))
6240 {
6241 break;
6242 }
6243 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306244 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6245 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006246 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006247 if(pSrcProfile->ChannelInfo.ChannelList)
6248 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306249 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6250 pSrcProfile->ChannelInfo.numOfChannels);
6251 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6252 status = eHAL_STATUS_FAILURE;
6253 else
6254 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006255 if(!HAL_STATUS_SUCCESS(status))
6256 {
6257 break;
6258 }
6259 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306260 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6261 pSrcProfile->ChannelInfo.ChannelList,
6262 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006263 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006264 pDstProfile->AuthType = pSrcProfile->AuthType;
6265 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6266 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6267 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6268 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6269 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006270#ifdef WLAN_FEATURE_11W
6271 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6272 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6273 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6274#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006275 pDstProfile->BSSType = pSrcProfile->BSSType;
6276 pDstProfile->phyMode = pSrcProfile->phyMode;
6277 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6278
6279#ifdef FEATURE_WLAN_WAPI
6280 if(csrIsProfileWapi(pSrcProfile))
6281 {
6282 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6283 {
6284 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6285 }
6286 }
6287#endif /* FEATURE_WLAN_WAPI */
6288 pDstProfile->CBMode = pSrcProfile->CBMode;
6289 /*Save the WPS info*/
6290 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006291 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006292 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006293 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006294 pDstProfile->privacy = pSrcProfile->privacy;
6295 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6296 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6297 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6298 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6299 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6300 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6301 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6302 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6303 pDstProfile->wps_state = pSrcProfile->wps_state;
6304 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306305 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6306 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006307#ifdef WLAN_FEATURE_VOWIFI_11R
6308 if (pSrcProfile->MDID.mdiePresent)
6309 {
6310 pDstProfile->MDID.mdiePresent = 1;
6311 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6312 }
6313#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006314 }while(0);
6315
6316 if(!HAL_STATUS_SUCCESS(status))
6317 {
6318 csrReleaseProfile(pMac, pDstProfile);
6319 pDstProfile = NULL;
6320 }
6321
6322 return (status);
6323}
Jeff Johnson295189b2012-06-20 16:38:30 -07006324eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6325{
6326 eHalStatus status = eHAL_STATUS_SUCCESS;
6327 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6328 do
6329 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306330 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006331 if(pSrcProfile->bssid)
6332 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306333 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6334 if ( NULL == pDstProfile->BSSIDs.bssid )
6335 status = eHAL_STATUS_FAILURE;
6336 else
6337 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006338 if(!HAL_STATUS_SUCCESS(status))
6339 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306340 smsLog( pMac, LOGE,
6341 FL("failed to allocate memory for BSSID"
6342 "%02x:%02x:%02x:%02x:%02x:%02x"),
6343 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6344 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006345 break;
6346 }
6347 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306348 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6349 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006350 }
6351 if(pSrcProfile->SSID.ssId)
6352 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306353 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6354 if ( NULL == pDstProfile->SSIDs.SSIDList )
6355 status = eHAL_STATUS_FAILURE;
6356 else
6357 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006358 if(!HAL_STATUS_SUCCESS(status))
6359 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306360 smsLog( pMac, LOGE,
6361 FL("failed to allocate memory for SSIDList"
6362 "%02x:%02x:%02x:%02x:%02x:%02x"),
6363 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6364 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006365 break;
6366 }
6367 pDstProfile->SSIDs.numOfSSIDs = 1;
6368 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6369 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306370 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6371 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006372 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006373 if(pSrcProfile->nAddIEAssocLength)
6374 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306375 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6376 if ( NULL == pDstProfile->pAddIEAssoc)
6377 status = eHAL_STATUS_FAILURE;
6378 else
6379 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006380 if(!HAL_STATUS_SUCCESS(status))
6381 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006382 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006383 break;
6384 }
6385 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306386 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6387 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006388 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306389 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6390 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6391 status = eHAL_STATUS_FAILURE;
6392 else
6393 status = eHAL_STATUS_SUCCESS;
6394
Jeff Johnson295189b2012-06-20 16:38:30 -07006395 if(!HAL_STATUS_SUCCESS(status))
6396 {
6397 break;
6398 }
6399 pDstProfile->ChannelInfo.numOfChannels = 1;
6400 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006401 pDstProfile->AuthType.numEntries = 1;
6402 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6403 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6404 pDstProfile->EncryptionType.numEntries = 1;
6405 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6406 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6407 pDstProfile->mcEncryptionType.numEntries = 1;
6408 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6409 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6410 pDstProfile->BSSType = pSrcProfile->BSSType;
6411 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306412 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6413 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006414#ifdef WLAN_FEATURE_VOWIFI_11R
6415 if (pSrcProfile->MDID.mdiePresent)
6416 {
6417 pDstProfile->MDID.mdiePresent = 1;
6418 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6419 }
6420#endif
6421
6422 }while(0);
6423
6424 if(!HAL_STATUS_SUCCESS(status))
6425 {
6426 csrReleaseProfile(pMac, pDstProfile);
6427 pDstProfile = NULL;
6428 }
6429
6430 return (status);
6431}
6432
Jeff Johnson295189b2012-06-20 16:38:30 -07006433eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6434 tScanResultHandle hBSSList,
6435 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6436 tANI_BOOLEAN fClearScan)
6437{
6438 eHalStatus status = eHAL_STATUS_SUCCESS;
6439 tSmeCmd *pCommand;
6440
6441 pCommand = csrGetCommandBuffer(pMac);
6442 if(NULL == pCommand)
6443 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006444 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006445 status = eHAL_STATUS_RESOURCES;
6446 }
6447 else
6448 {
6449 if( fClearScan )
6450 {
6451 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306452 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006453 }
6454 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6455 if(NULL == pProfile)
6456 {
6457 //We can roam now
6458 //Since pProfile is NULL, we need to build our own profile, set everything to default
6459 //We can only support open and no encryption
6460 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6461 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6462 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6463 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6464 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6465 }
6466 else
6467 {
6468 //make a copy of the profile
6469 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6470 if(HAL_STATUS_SUCCESS(status))
6471 {
6472 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6473 }
6474 }
6475 pCommand->command = eSmeCommandRoam;
6476 pCommand->sessionId = (tANI_U8)sessionId;
6477 pCommand->u.roamCmd.hBSSList = hBSSList;
6478 pCommand->u.roamCmd.roamId = roamId;
6479 pCommand->u.roamCmd.roamReason = reason;
6480 //We need to free the BssList when the command is done
6481 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6482 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006483 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6484 FL("CSR PERSONA=%d"),
6485 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006486 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6487 if( !HAL_STATUS_SUCCESS( status ) )
6488 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006489 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006490 csrReleaseCommandRoam( pMac, pCommand );
6491 }
6492 }
6493
6494 return (status);
6495}
Jeff Johnson295189b2012-06-20 16:38:30 -07006496eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6497 tCsrRoamModifyProfileFields *pMmodProfileFields,
6498 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6499{
6500 eHalStatus status = eHAL_STATUS_SUCCESS;
6501 tSmeCmd *pCommand;
6502
6503 pCommand = csrGetCommandBuffer(pMac);
6504 if(NULL == pCommand)
6505 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006506 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006507 status = eHAL_STATUS_RESOURCES;
6508 }
6509 else
6510 {
6511 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306512 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006513 if(pProfile)
6514 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006515 //This is likely trying to reassoc to different profile
6516 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6517 //make a copy of the profile
6518 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6519 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006520 }
6521 else
6522 {
6523 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6524 //how to update WPA/WPA2 info in roamProfile??
6525 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006526 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006527 if(HAL_STATUS_SUCCESS(status))
6528 {
6529 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6530 }
6531 pCommand->command = eSmeCommandRoam;
6532 pCommand->sessionId = (tANI_U8)sessionId;
6533 pCommand->u.roamCmd.roamId = roamId;
6534 pCommand->u.roamCmd.roamReason = reason;
6535 //We need to free the BssList when the command is done
6536 //For reassoc there is no BSS list, so the boolean set to false
6537 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6538 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6539 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006540 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6541 if( !HAL_STATUS_SUCCESS( status ) )
6542 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006543 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006544 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6545 csrReleaseCommandRoam( pMac, pCommand );
6546 }
6547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006548 return (status);
6549}
6550
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006551eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6552 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306553// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006554{
6555 eHalStatus status = eHAL_STATUS_SUCCESS;
6556 tSmeCmd *pCommand;
6557
6558 pCommand = csrGetCommandBuffer(pMac);
6559 if(NULL == pCommand)
6560 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006561 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006562 status = eHAL_STATUS_RESOURCES;
6563 }
6564 else
6565 {
6566 if(pBssDescription)
6567 {
6568 //copy over the parameters we need later
6569 pCommand->command = eSmeCommandRoam;
6570 pCommand->sessionId = (tANI_U8)sessionId;
6571 pCommand->u.roamCmd.roamReason = reason;
6572 //this is the important parameter
6573 //in this case we are using this field for the "next" BSS
6574 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6575 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6576 if( !HAL_STATUS_SUCCESS( status ) )
6577 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006578 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006579 csrReleaseCommandPreauth( pMac, pCommand );
6580 }
6581 }
6582 else
6583 {
6584 //Return failure
6585 status = eHAL_STATUS_RESOURCES;
6586 }
6587 }
6588 return (status);
6589}
6590
6591eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6592{
6593 tListElem *pEntry;
6594 tSmeCmd *pCommand;
6595 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6596 if ( pEntry )
6597 {
6598 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6599 if ( (eSmeCommandRoam == pCommand->command) &&
6600 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6601 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006602 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006603 pCommand->command, pCommand->u.roamCmd.roamReason);
6604 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6605 csrReleaseCommandPreauth( pMac, pCommand );
6606 }
6607 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006608 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006609 pCommand->command, pCommand->u.roamCmd.roamReason);
6610 }
6611 }
6612 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006613 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006614 }
6615 smeProcessPendingQueue( pMac );
6616 return eHAL_STATUS_SUCCESS;
6617}
6618
Jeff Johnson295189b2012-06-20 16:38:30 -07006619eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6620 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6621{
6622 eHalStatus status = eHAL_STATUS_FAILURE;
6623 tScanResultHandle hBSSList;
6624 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006625 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6626 if(HAL_STATUS_SUCCESS(status))
6627 {
6628 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6629 if(pRoamId)
6630 {
6631 *pRoamId = roamId;
6632 }
6633 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6634 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6635 if(!HAL_STATUS_SUCCESS(status))
6636 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006637 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006638 csrScanResultPurge(pMac, hBSSList);
6639 }
6640 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006641 return (status);
6642}
6643
Jeff Johnson295189b2012-06-20 16:38:30 -07006644eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6645 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6646{
6647 eHalStatus status = eHAL_STATUS_SUCCESS;
6648 tScanResultHandle hBSSList;
6649 tCsrScanResultFilter *pScanFilter;
6650 tANI_U32 roamId = 0;
6651 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6652 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006653 if (NULL == pProfile)
6654 {
6655 smsLog(pMac, LOGP, FL("No profile specified"));
6656 return eHAL_STATUS_FAILURE;
6657 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306658 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6659 "encryType = %d"),
6660 lim_BssTypetoString(pProfile->BSSType),
6661 pProfile->BSSType,
6662 pProfile->AuthType.authType[0],
6663 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006664 if( CSR_IS_WDS( pProfile ) &&
6665 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6666 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006667 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006668 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006669 return status;
6670 }
6671 csrRoamCancelRoaming(pMac, sessionId);
6672 csrScanRemoveFreshScanCommand(pMac, sessionId);
6673 csrScanCancelIdleScan(pMac);
6674 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306675 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306676
6677 if (!vos_concurrent_open_sessions_running() &&
6678 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07006679 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306680 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07006681 csrScanDisable(pMac);
6682 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306683
Jeff Johnson295189b2012-06-20 16:38:30 -07006684 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6685 //Check whether ssid changes
6686 if(csrIsConnStateConnected(pMac, sessionId))
6687 {
6688 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6689 {
6690 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6691 }
6692 }
6693#ifdef FEATURE_WLAN_BTAMP_UT_RF
6694 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6695#endif
6696 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6697 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006698 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006699 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6700 if(pRoamId)
6701 {
6702 roamId = *pRoamId;
6703 }
6704 if(!HAL_STATUS_SUCCESS(status))
6705 {
6706 fCallCallback = eANI_BOOLEAN_TRUE;
6707 }
6708 }
6709 else
6710 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306711 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6712 if ( NULL == pScanFilter )
6713 status = eHAL_STATUS_FAILURE;
6714 else
6715 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006716 if(HAL_STATUS_SUCCESS(status))
6717 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306718 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006719 //Try to connect to any BSS
6720 if(NULL == pProfile)
6721 {
6722 //No encryption
6723 pScanFilter->EncryptionType.numEntries = 1;
6724 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6725 }//we don't have a profile
6726 else
6727 {
6728 //Here is the profile we need to connect to
6729 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6730 }//We have a profile
6731 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6732 if(pRoamId)
6733 {
6734 *pRoamId = roamId;
6735 }
6736
6737 if(HAL_STATUS_SUCCESS(status))
6738 {
6739 /*Save the WPS info*/
6740 if(NULL != pProfile)
6741 {
6742 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006743 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006744 }
6745 else
6746 {
6747 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006748 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006750 do
6751 {
6752 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006753 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006754 )
6755 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006756 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006757 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6758 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6759 if(!HAL_STATUS_SUCCESS(status))
6760 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006761 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006762 fCallCallback = eANI_BOOLEAN_TRUE;
6763 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006764 else
6765 {
6766 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6767 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006768 break;
6769 }
6770 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006771 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006772 if(HAL_STATUS_SUCCESS(status))
6773 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006774 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6775 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6776 if(!HAL_STATUS_SUCCESS(status))
6777 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006778 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006779 csrScanResultPurge(pMac, hBSSList);
6780 fCallCallback = eANI_BOOLEAN_TRUE;
6781 }
6782 }//Have scan result
6783 else if(NULL != pProfile)
6784 {
6785 //Check whether it is for start ibss
6786 if(CSR_IS_START_IBSS(pProfile))
6787 {
6788 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6789 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6790 if(!HAL_STATUS_SUCCESS(status))
6791 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006792 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006793 fCallCallback = eANI_BOOLEAN_TRUE;
6794 }
6795 }
6796 else
6797 {
6798 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006799 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006800 if(!HAL_STATUS_SUCCESS(status))
6801 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006802 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006803 fCallCallback = eANI_BOOLEAN_TRUE;
6804 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006805 else
6806 {
6807 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6808 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006809 }
6810 }
6811 else
6812 {
6813 fCallCallback = eANI_BOOLEAN_TRUE;
6814 }
6815 } while (0);
6816 if(NULL != pProfile)
6817 {
6818 //we need to free memory for filter if profile exists
6819 csrFreeScanFilter(pMac, pScanFilter);
6820 }
6821 }//Got the scan filter from profile
6822
Kiet Lam64c1b492013-07-12 13:56:44 +05306823 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006824 }//allocated memory for pScanFilter
6825 }//No Bsslist coming in
6826 //tell the caller if we fail to trigger a join request
6827 if( fCallCallback )
6828 {
6829 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6830 }
6831
6832 return (status);
6833}
Jeff Johnson295189b2012-06-20 16:38:30 -07006834eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6835 tCsrRoamModifyProfileFields modProfileFields,
6836 tANI_U32 *pRoamId)
6837{
6838 eHalStatus status = eHAL_STATUS_SUCCESS;
6839 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6840 tANI_U32 roamId = 0;
6841 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006842 if (NULL == pProfile)
6843 {
6844 smsLog(pMac, LOGP, FL("No profile specified"));
6845 return eHAL_STATUS_FAILURE;
6846 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306847 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6848 "encryType = %d"),
6849 lim_BssTypetoString(pProfile->BSSType),
6850 pProfile->BSSType,
6851 pProfile->AuthType.authType[0],
6852 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006853 csrRoamCancelRoaming(pMac, sessionId);
6854 csrScanRemoveFreshScanCommand(pMac, sessionId);
6855 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306856 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006857 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006858 if(csrIsConnStateConnected(pMac, sessionId))
6859 {
6860 if(pProfile)
6861 {
6862 if(pProfile->SSIDs.numOfSSIDs &&
6863 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6864 {
6865 fCallCallback = eANI_BOOLEAN_FALSE;
6866 }
6867 else
6868 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006869 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006870 }
6871 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306872 else if (!vos_mem_compare(&modProfileFields,
6873 &pSession->connectedProfile.modifyProfileFields,
6874 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006875 {
6876 fCallCallback = eANI_BOOLEAN_FALSE;
6877 }
6878 else
6879 {
6880 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006881 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006882 }
6883 }
6884 else
6885 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006886 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006887 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006888 if(!fCallCallback)
6889 {
6890 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6891 if(pRoamId)
6892 {
6893 *pRoamId = roamId;
6894 }
6895
Jeff Johnson295189b2012-06-20 16:38:30 -07006896 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6897 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006898 }
6899 else
6900 {
6901 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6902 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006904 return status;
6905}
Jeff Johnson295189b2012-06-20 16:38:30 -07006906eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6907{
6908 eHalStatus status = eHAL_STATUS_FAILURE;
6909 tScanResultHandle hBSSList = NULL;
6910 tCsrScanResultFilter *pScanFilter = NULL;
6911 tANI_U32 roamId;
6912 tCsrRoamProfile *pProfile = NULL;
6913 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006914
6915 if(!pSession)
6916 {
6917 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6918 return eHAL_STATUS_FAILURE;
6919 }
6920
Jeff Johnson295189b2012-06-20 16:38:30 -07006921 do
6922 {
6923 if(pSession->pCurRoamProfile)
6924 {
6925 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306926 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006927 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306928 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6929 if ( NULL == pProfile )
6930 status = eHAL_STATUS_FAILURE;
6931 else
6932 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006933 if(!HAL_STATUS_SUCCESS(status))
6934 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306935 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006936 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306937 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006938 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306939 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6940 if ( NULL == pScanFilter )
6941 status = eHAL_STATUS_FAILURE;
6942 else
6943 status = eHAL_STATUS_SUCCESS;
6944
Jeff Johnson295189b2012-06-20 16:38:30 -07006945 if(!HAL_STATUS_SUCCESS(status))
6946 {
6947 break;
6948 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306949 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006950 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6951 if(!HAL_STATUS_SUCCESS(status))
6952 {
6953 break;
6954 }
6955 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6956 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6957 if(HAL_STATUS_SUCCESS(status))
6958 {
6959 //we want to put the last connected BSS to the very beginning, if possible
6960 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6961 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6962 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6963 if(!HAL_STATUS_SUCCESS(status))
6964 {
6965 csrScanResultPurge(pMac, hBSSList);
6966 break;
6967 }
6968 }
6969 else
6970 {
6971 //Do a scan on this profile
6972 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006973 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006974 if(!HAL_STATUS_SUCCESS(status))
6975 {
6976 break;
6977 }
6978 }
6979 }//We have a profile
6980 else
6981 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006982 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006983 break;
6984 }
6985 }while(0);
6986 if(pScanFilter)
6987 {
6988 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306989 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006990 }
6991 if(NULL != pProfile)
6992 {
6993 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306994 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006995 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006996 return (status);
6997}
Jeff Johnson295189b2012-06-20 16:38:30 -07006998eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6999{
7000 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007001 if(csrIsConnStateConnected(pMac, sessionId))
7002 {
7003 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
7004 if(HAL_STATUS_SUCCESS(status))
7005 {
7006 status = csrRoamJoinLastProfile(pMac, sessionId);
7007 }
7008 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007009 return (status);
7010}
7011
Jeff Johnson295189b2012-06-20 16:38:30 -07007012eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
7013{
7014 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007015 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007016 csrRoamCancelRoaming(pMac, sessionId);
7017 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
7018 if(csrIsConnStateDisconnected(pMac, sessionId))
7019 {
7020 status = csrRoamJoinLastProfile(pMac, sessionId);
7021 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007022 return (status);
7023}
7024
Jeff Johnson295189b2012-06-20 16:38:30 -07007025eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
7026{
7027 eHalStatus status = eHAL_STATUS_SUCCESS;
7028 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
7029 eCsrRoamSubState NewSubstate;
7030 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05307031
7032 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7033 {
7034 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
7035 " eCSR_ROAM_SUBSTATE_NONE"));
7036 csrRoamStopWaitForKeyTimer( pMac );
7037 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7038 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007039 // change state to 'Roaming'...
7040 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
7041
7042 if ( csrIsConnStateIbss( pMac, sessionId ) )
7043 {
7044 // If we are in an IBSS, then stop the IBSS...
7045 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7046 fComplete = (!HAL_STATUS_SUCCESS(status));
7047 }
7048 else if ( csrIsConnStateInfra( pMac, sessionId ) )
7049 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007050 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 -07007051 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
7052 //Restore AC weight in case we change it
7053 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
7054 // in Infrasturcture, we need to disassociate from the Infrastructure network...
7055 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7056 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
7057 {
7058 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7059 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307060 else
7061 {
7062 // If we are in neighbor preauth done state then on receiving
7063 // disassoc or deauth we dont roam instead we just disassoc
7064 // from current ap and then go to disconnected state
7065 // This happens for ESE and 11r FT connections ONLY.
7066#ifdef WLAN_FEATURE_VOWIFI_11R
7067 if (csrRoamIs11rAssoc(pMac) &&
7068 (csrNeighborRoamStatePreauthDone(pMac)))
7069 {
7070 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7071 }
7072#endif
7073#ifdef FEATURE_WLAN_ESE
7074 if (csrRoamIsESEAssoc(pMac) &&
7075 (csrNeighborRoamStatePreauthDone(pMac)))
7076 {
7077 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7078 }
7079#endif
7080#ifdef FEATURE_WLAN_LFR
7081 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7082 (csrNeighborRoamStatePreauthDone(pMac)))
7083 {
7084 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7085 }
7086#endif
7087 }
7088
Jeff Johnson295189b2012-06-20 16:38:30 -07007089 if( fDisassoc )
7090 {
7091 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05307092#ifdef DEBUG_ROAM_DELAY
7093 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7094#endif /* DEBUG_ROAM_DELAY */
Jeff Johnson295189b2012-06-20 16:38:30 -07007095 }
7096 else
7097 {
7098 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7099 }
7100 fComplete = (!HAL_STATUS_SUCCESS(status));
7101 }
7102 else if ( csrIsConnStateWds( pMac, sessionId ) )
7103 {
7104 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7105 {
7106 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7107 fComplete = (!HAL_STATUS_SUCCESS(status));
7108 }
7109 //This has to be WDS station
7110 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7111 {
7112
7113 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7114 if( fDisassoc )
7115 {
7116 status = csrRoamIssueDisassociate( pMac, sessionId,
7117 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7118 fComplete = (!HAL_STATUS_SUCCESS(status));
7119 }
7120 }
7121 } else {
7122 // we got a dis-assoc request while not connected to any peer
7123 // just complete the command
7124 fComplete = eANI_BOOLEAN_TRUE;
7125 status = eHAL_STATUS_FAILURE;
7126 }
7127 if(fComplete)
7128 {
7129 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7130 }
7131
7132 if(HAL_STATUS_SUCCESS(status))
7133 {
7134 if ( csrIsConnStateInfra( pMac, sessionId ) )
7135 {
7136 //Set the state to disconnect here
7137 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7138 }
7139 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007140 else
7141 {
7142 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7143 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007144 return (status);
7145}
7146
Jeff Johnson295189b2012-06-20 16:38:30 -07007147/* This is been removed from latest code base */
7148/*
7149static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7150{
7151 eHalStatus status;
7152 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007153 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7154 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007155 return ( status );
7156}
7157*/
7158
Jeff Johnson295189b2012-06-20 16:38:30 -07007159eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7160{
7161 eHalStatus status = eHAL_STATUS_SUCCESS;
7162 tSmeCmd *pCommand;
7163 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007164 do
7165 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08007166 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007167 pCommand = csrGetCommandBuffer( pMac );
7168 if ( !pCommand )
7169 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007170 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007171 status = eHAL_STATUS_RESOURCES;
7172 break;
7173 }
7174 //Change the substate in case it is wait-for-key
7175 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7176 {
7177 csrRoamStopWaitForKeyTimer( pMac );
7178 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7179 }
7180 pCommand->command = eSmeCommandRoam;
7181 pCommand->sessionId = (tANI_U8)sessionId;
7182 switch ( reason )
7183 {
7184 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7185 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7186 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007187 case eCSR_DISCONNECT_REASON_DEAUTH:
7188 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7189 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007190 case eCSR_DISCONNECT_REASON_HANDOFF:
7191 fHighPriority = eANI_BOOLEAN_TRUE;
7192 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7193 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007194 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7195 case eCSR_DISCONNECT_REASON_DISASSOC:
7196 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7197 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007198 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7199 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7200 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007201 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7202 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7203 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007204 default:
7205 break;
7206 }
7207 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7208 if( !HAL_STATUS_SUCCESS( status ) )
7209 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007210 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007211 csrReleaseCommandRoam( pMac, pCommand );
7212 }
7213 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007214 return( status );
7215}
7216
Jeff Johnson295189b2012-06-20 16:38:30 -07007217eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7218{
7219 eHalStatus status = eHAL_STATUS_SUCCESS;
7220 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007221 pCommand = csrGetCommandBuffer( pMac );
7222 if ( NULL != pCommand )
7223 {
7224 //Change the substate in case it is wait-for-key
7225 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7226 {
7227 csrRoamStopWaitForKeyTimer( pMac );
7228 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7229 }
7230 pCommand->command = eSmeCommandRoam;
7231 pCommand->sessionId = (tANI_U8)sessionId;
7232 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7233 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7234 if( !HAL_STATUS_SUCCESS( status ) )
7235 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007236 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007237 csrReleaseCommandRoam( pMac, pCommand );
7238 }
7239 }
7240 else
7241 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007242 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007243 status = eHAL_STATUS_RESOURCES;
7244 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007245 return ( status );
7246}
7247
Jeff Johnson295189b2012-06-20 16:38:30 -07007248eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7249{
7250 eHalStatus status = eHAL_STATUS_SUCCESS;
7251 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007252
7253 if(!pSession)
7254 {
7255 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7256 return eHAL_STATUS_FAILURE;
7257 }
7258
Jeff Johnson295189b2012-06-20 16:38:30 -07007259#ifdef FEATURE_WLAN_BTAMP_UT_RF
7260 //Stop te retry
7261 pSession->maxRetryCount = 0;
7262 csrRoamStopJoinRetryTimer(pMac, sessionId);
7263#endif
7264 //Not to call cancel roaming here
7265 //Only issue disconnect when necessary
7266 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7267 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7268 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7269
7270 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007271 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007272 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7273 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307274 else
7275 {
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307276 csrScanAbortScanForSSID(pMac, sessionId);
7277 status = eHAL_STATUS_CMD_NOT_QUEUED;
7278 smsLog( pMac, LOG1, FL(" Disconnect cmd not queued, Roam command is not present"
7279 " return with status %d"), status);
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307280 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007281 return (status);
7282}
7283
Jeff Johnson295189b2012-06-20 16:38:30 -07007284eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7285{
7286 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007287
7288 if(!pSession)
7289 {
7290 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7291 return eHAL_STATUS_FAILURE;
7292 }
7293
Jeff Johnson295189b2012-06-20 16:38:30 -07007294 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007295 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7296
7297 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7298}
7299
Jeff Johnson295189b2012-06-20 16:38:30 -07007300eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7301 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7302{
7303 eHalStatus status = eHAL_STATUS_SUCCESS;
7304 tDot11fBeaconIEs *pIesTemp = pIes;
7305 tANI_U8 index;
7306 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7307 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007308
7309 if(!pSession)
7310 {
7311 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7312 return eHAL_STATUS_FAILURE;
7313 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007314 if(pConnectProfile->pAddIEAssoc)
7315 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307316 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007317 pConnectProfile->pAddIEAssoc = NULL;
7318 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307319 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007320 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7321 pConnectProfile->AuthInfo = pProfile->AuthType;
7322 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7323 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7324 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7325 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7326 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7327 pConnectProfile->BSSType = pProfile->BSSType;
7328 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7329 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007330 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307331 if (!pConnectProfile->beaconInterval)
7332 {
7333 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7334 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307335 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007336 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7337 if(pProfile->nAddIEAssocLength)
7338 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307339 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7340 if ( NULL == pConnectProfile->pAddIEAssoc )
7341 status = eHAL_STATUS_FAILURE;
7342 else
7343 status = eHAL_STATUS_SUCCESS;
7344 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007345 {
7346 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7347 return eHAL_STATUS_FAILURE;
7348 }
7349 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307350 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7351 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007352 }
7353
Jeff Johnson295189b2012-06-20 16:38:30 -07007354 //Save bssid
7355 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7356#ifdef WLAN_FEATURE_VOWIFI_11R
7357 if (pSirBssDesc->mdiePresent)
7358 {
7359 pConnectProfile->MDID.mdiePresent = 1;
7360 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7361 }
7362#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007363 if( NULL == pIesTemp )
7364 {
7365 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7366 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007367#ifdef FEATURE_WLAN_ESE
7368 if ((csrIsProfileESE(pProfile) ||
7369 ((pIesTemp->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307370 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7371 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7372 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7373 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
7374#ifdef WLAN_FEATURE_11W
7375 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +05307376 || (pProfile->negotiatedAuthType ==
7377 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307378#endif
7379 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007380 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007381 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007382 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007383 }
7384#endif
7385 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007386 if(HAL_STATUS_SUCCESS(status))
7387 {
7388 if(pIesTemp->SSID.present)
7389 {
7390 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307391 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7392 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007393 }
7394
7395 //Save the bss desc
7396 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307397
7398 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007399 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307400 //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 -07007401 pConnectProfile->qap = TRUE;
7402 }
7403 else
7404 {
7405 pConnectProfile->qap = FALSE;
7406 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007407 if ( NULL == pIes )
7408 {
7409 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307410 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007411 }
7412 }
7413 //Save Qos connection
7414 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7415
7416 if(!HAL_STATUS_SUCCESS(status))
7417 {
7418 csrFreeConnectBssDesc(pMac, sessionId);
7419 }
7420 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7421 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307422 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7423 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7424 pConnectProfile->SSID.ssId,
7425 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007426 {
7427 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7428 break;
7429 }
7430 pConnectProfile->handoffPermitted = FALSE;
7431 }
7432
7433 return (status);
7434}
7435
Jeff Johnson295189b2012-06-20 16:38:30 -07007436static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7437{
7438 tListElem *pEntry = NULL;
7439 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007440 //The head of the active list is the request we sent
7441 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7442 if(pEntry)
7443 {
7444 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007446 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7447 {
7448 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7449 {
7450#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7451 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7452#endif
7453 }
7454 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7455 }
7456 else
7457 {
7458 tANI_U32 roamId = 0;
7459 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007460 if(!pSession)
7461 {
7462 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7463 return;
7464 }
7465
Jeff Johnson295189b2012-06-20 16:38:30 -07007466
7467 //The head of the active list is the request we sent
7468 //Try to get back the same profile and roam again
7469 if(pCommand)
7470 {
7471 roamId = pCommand->u.roamCmd.roamId;
7472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007473 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7474 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007475 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007476#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7477 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7478 if (csrRoamIsHandoffInProgress(pMac))
7479 {
7480 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7481 /* Should indicate neighbor roam algorithm about the connect failure here */
7482 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7483 }
7484#endif
7485 if (pCommand)
7486 {
7487 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7488 {
7489 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7490 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7491 csrRoamReissueRoamCommand(pMac);
7492 }
7493 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7494 {
7495 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7496 }
7497 else
7498 {
7499 csrRoam(pMac, pCommand);
7500 }
7501 }
7502 else
7503 {
7504 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7505 }
7506 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7507}
7508
Jeff Johnson295189b2012-06-20 16:38:30 -07007509eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7510 tDot11fBeaconIEs *pIes,
7511 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7512{
7513 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007514 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7515 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007516
7517 // Set the roaming substate to 'join attempt'...
7518 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007519 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007520 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007521 return (status);
7522}
7523
Jeff Johnson295189b2012-06-20 16:38:30 -07007524static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7525 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7526{
7527 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007528 // Set the roaming substate to 'join attempt'...
7529 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7530
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307531 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7532 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05307533#ifdef DEBUG_ROAM_DELAY
7534 //HACK usign buff len as Auth type
7535 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
7536 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
7537#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007538 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007539 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007540}
7541
Jeff Johnson295189b2012-06-20 16:38:30 -07007542void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7543{
7544 tListElem *pEntry;
7545 tSmeCmd *pCommand;
7546 tCsrRoamInfo roamInfo;
7547 tANI_U32 sessionId;
7548 tCsrRoamSession *pSession;
7549
7550 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7551 if(pEntry)
7552 {
7553 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7554 if ( eSmeCommandRoam == pCommand->command )
7555 {
7556 sessionId = pCommand->sessionId;
7557 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007558
7559 if(!pSession)
7560 {
7561 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7562 return;
7563 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307564 /* While switching between two AP, csr will reissue roam command again
7565 to the nextbss if it was interrupted by the dissconnect req for the
7566 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7567 so reset the bRefAssocStartCnt.
7568 */
7569 if(pSession->bRefAssocStartCnt > 0)
7570 {
7571 pSession->bRefAssocStartCnt--;
7572 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007573 if( pCommand->u.roamCmd.fStopWds )
7574 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307575 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007576 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7577 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7578 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007579 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007580 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7581 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7582 eCSR_ROAM_WDS_IND,
7583 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007584 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7585 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7586 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7587 eCSR_ROAM_INFRA_IND,
7588 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7589 }
7590
Jeff Johnson295189b2012-06-20 16:38:30 -07007591
Jeff Johnson295189b2012-06-20 16:38:30 -07007592 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7593 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007594 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007595 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7596 }
7597 }
7598 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7599 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007600 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007601 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7602 }
7603 }
7604 else
7605 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007606 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007607 }
7608 }
7609 else
7610 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007611 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007612 }
7613}
7614
Jeff Johnson295189b2012-06-20 16:38:30 -07007615tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7616{
7617 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7618 tListElem *pEntry;
7619 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007620 //alwasy lock active list before locking pending list
7621 csrLLLock( &pMac->sme.smeCmdActiveList );
7622 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7623 if(pEntry)
7624 {
7625 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7626 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7627 {
7628 fRet = eANI_BOOLEAN_TRUE;
7629 }
7630 }
7631 if(eANI_BOOLEAN_FALSE == fRet)
7632 {
7633 csrLLLock(&pMac->sme.smeCmdPendingList);
7634 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7635 while(pEntry)
7636 {
7637 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7638 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7639 {
7640 fRet = eANI_BOOLEAN_TRUE;
7641 break;
7642 }
7643 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7644 }
7645 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7646 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307647 if (eANI_BOOLEAN_FALSE == fRet)
7648 {
7649 csrLLLock(&pMac->roam.roamCmdPendingList);
7650 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7651 while (pEntry)
7652 {
7653 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7654 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7655 {
7656 fRet = eANI_BOOLEAN_TRUE;
7657 break;
7658 }
7659 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7660 }
7661 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7662 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007663 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007664 return (fRet);
7665}
7666
Jeff Johnson295189b2012-06-20 16:38:30 -07007667tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7668{
7669 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7670 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007671 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7672 {
7673 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7674 {
7675 break;
7676 }
7677 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007678 return ( fRet );
7679}
7680
Jeff Johnson295189b2012-06-20 16:38:30 -07007681tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7682{
7683 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007684 //alwasy lock active list before locking pending list
7685 csrLLLock( &pMac->sme.smeCmdActiveList );
7686 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7687 if(eANI_BOOLEAN_FALSE == fRet)
7688 {
7689 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7690 }
7691 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007692 return (fRet);
7693}
7694
Jeff Johnson295189b2012-06-20 16:38:30 -07007695tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7696{
7697 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7698 tListElem *pEntry;
7699 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007700 //alwasy lock active list before locking pending list
7701 csrLLLock( &pMac->sme.smeCmdActiveList );
7702 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7703 if( pEntry )
7704 {
7705 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7706 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7707 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7708 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7709 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7710 {
7711 fRet = eANI_BOOLEAN_TRUE;
7712 }
7713 }
7714 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007715 return (fRet);
7716}
Jeff Johnson295189b2012-06-20 16:38:30 -07007717eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7718{
7719 eHalStatus status = eHAL_STATUS_SUCCESS;
7720 tSmeCmd *pCommand = NULL;
7721 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7722 tANI_BOOLEAN fRemoveCmd = FALSE;
7723 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007724 // Delete the old assoc command. All is setup for reassoc to be serialized
7725 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7726 if ( pEntry )
7727 {
7728 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7729 if ( !pCommand )
7730 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007731 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007732 return eHAL_STATUS_RESOURCES;
7733 }
7734 if ( eSmeCommandRoam == pCommand->command )
7735 {
7736 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7737 {
7738 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7739 }
7740 else
7741 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007742 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007743 }
7744 if (fRemoveCmd == FALSE)
7745 {
7746 // Implies we did not get the serialized assoc command we
7747 // were expecting
7748 pCommand = NULL;
7749 }
7750 }
7751 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007752 if(NULL == pCommand)
7753 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007754 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007755 return eHAL_STATUS_RESOURCES;
7756 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007757 do
7758 {
7759 //Change the substate in case it is wait-for-key
7760 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7761 {
7762 csrRoamStopWaitForKeyTimer( pMac );
7763 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7764 }
7765 pCommand->command = eSmeCommandRoam;
7766 pCommand->sessionId = (tANI_U8)sessionId;
7767 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007768 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7769 if( !HAL_STATUS_SUCCESS( status ) )
7770 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007771 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007772 csrReleaseCommandRoam( pMac, pCommand );
7773 }
7774 } while( 0 );
7775
Jeff Johnson295189b2012-06-20 16:38:30 -07007776 return( status );
7777}
7778static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7779{
7780 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7781 tCsrScanResult *pScanResult = NULL;
7782 tSirBssDescription *pBssDesc = NULL;
7783 tSmeCmd *pCommand = NULL;
7784 tANI_U32 sessionId;
7785 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007786 if(NULL == pEntry)
7787 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307788 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007789 return;
7790 }
7791 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7792 sessionId = pCommand->sessionId;
7793 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007794
7795 if(!pSession)
7796 {
7797 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7798 return;
7799 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307800 smsLog(pMac, LOG1, FL("CFG return value is %d "
7801 " current state is : %d substate is : %d "),
7802 result, pMac->roam.curState[sessionId],
7803 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007804 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7805 {
7806 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007807 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007808 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7809 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007810 /* If the roaming has stopped, not to continue the roaming command*/
7811 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7812 {
7813 //No need to complete roaming here as it already completes
7814 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7815 pCommand->u.roamCmd.roamReason);
7816 csrSetAbortRoamingCommand( pMac, pCommand );
7817 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7818 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007819 else
7820 {
7821 if ( CCM_IS_RESULT_SUCCESS(result) )
7822 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307823 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007824 // Successfully set the configuration parameters for the new Bss. Attempt to
7825 // join the roaming Bss.
7826 if(pCommand->u.roamCmd.pRoamBssEntry)
7827 {
7828 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7829 pBssDesc = &pScanResult->Result.BssDescriptor;
7830 }
7831 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7832 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007833 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007834 )
7835 {
7836 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7837 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7838 pBssDesc, pCommand->u.roamCmd.roamId )))
7839 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307840 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007841 //We need to complete the command
7842 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7843 }
7844 }
7845 else
7846 {
7847 if (!pCommand->u.roamCmd.pRoamBssEntry)
7848 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307849 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007850 //We need to complete the command
7851 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7852 return;
7853 }
7854 // If we are roaming TO an Infrastructure BSS...
7855 VOS_ASSERT(pScanResult != NULL);
7856 if ( csrIsInfraBssDesc( pBssDesc ) )
7857 {
7858 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307859 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007860 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7861 {
7862 // ..and currently in an Infrastructure connection....
7863 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7864 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307865 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007866 // ...and the SSIDs are equal, then we Reassoc.
7867 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7868 pIesLocal ) )
7869 // ..and currently in an infrastructure connection
7870 {
7871 // then issue a Reassoc.
7872 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7873 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7874 &pCommand->u.roamCmd.roamProfile );
7875 }
7876 else
7877 {
7878
7879 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7880 // previously associated AP.
7881 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7882 pIesLocal,
7883 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7884 {
7885 //try something else
7886 csrRoam( pMac, pCommand );
7887 }
7888 }
7889 }
7890 else
7891 {
7892 eHalStatus status = eHAL_STATUS_SUCCESS;
7893
7894 /* We need to come with other way to figure out that this is because of HO in BMP
7895 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007896 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07007897 * use join request */
7898#ifdef WLAN_FEATURE_VOWIFI_11R
7899 if (csrRoamIsHandoffInProgress(pMac) &&
7900 csrRoamIs11rAssoc(pMac))
7901 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307902 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07007903 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7904 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7905 }
7906 else
7907#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007908#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007909 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007910 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07007911 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307912 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07007913 // Now serialize the reassoc command.
7914 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7915 }
7916 else
7917#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007918#ifdef FEATURE_WLAN_LFR
7919 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307920 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007921 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307922 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007923 // Now serialize the reassoc command.
7924 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7925 }
7926 else
7927#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007928 // else we are not connected and attempting to Join. Issue the
7929 // Join request.
7930 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307931 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07007932 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7933 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7934 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7935 }
7936 if(!HAL_STATUS_SUCCESS(status))
7937 {
7938 //try something else
7939 csrRoam( pMac, pCommand );
7940 }
7941 }
7942 if( !pScanResult->Result.pvIes )
7943 {
7944 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307945 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007946 }
7947 }
7948 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7949 else
7950 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007951 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007952 }
7953 }//else
7954 }//if ( WNI_CFG_SUCCESS == result )
7955 else
7956 {
7957 // In the event the configuration failed, for infra let the roam processor
7958 //attempt to join something else...
7959 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7960 {
7961 csrRoam(pMac, pCommand);
7962 }
7963 else
7964 {
7965 //We need to complete the command
7966 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7967 {
7968 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7969 }
7970 else
7971 {
7972 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7973 }
7974 }
7975 }
7976 }//we have active entry
7977}
7978
Jeff Johnson295189b2012-06-20 16:38:30 -07007979static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7980{
7981 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007982 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007983 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7984 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007985 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007986 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7987 // join the new one...
7988 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007989 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7990 }
7991 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007992 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007993 /***profHandleLostLinkAfterReset(pAdapter);
7994 // In the event the authenticate fails, let the roam processor attempt to join something else...
7995 roamRoam( pAdapter );***/
7996 }
7997}
7998
Jeff Johnson295189b2012-06-20 16:38:30 -07007999static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
8000{
8001 eCsrRoamCompleteResult result;
8002 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
8003 tCsrRoamInfo roamInfo;
8004 tANI_U32 roamId = 0;
8005
8006 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
8007 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008008 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008009 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07008010 /* Defeaturize this part later if needed */
8011#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
8012 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
8013 * we need the response contents while processing the result in csrRoamProcessResults() */
8014 if (csrRoamIsHandoffInProgress(pMac))
8015 {
8016 /* Need to dig more on indicating events to SME QoS module */
8017 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
8018 csrRoamComplete( pMac, result, pSmeJoinRsp);
8019 }
8020 else
8021#endif
8022 {
8023 csrRoamComplete( pMac, result, NULL );
8024 }
8025 }
8026 /* Should we handle this similar to handling the join failure? Is it ok
8027 * to call csrRoamComplete() with state as CsrJoinFailure */
8028 else
8029 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008030 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008031 result = eCsrReassocFailure;
8032#ifdef WLAN_FEATURE_VOWIFI_11R
8033 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +05308034 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode) ||
8035 (eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA == pSmeJoinRsp->statusCode))
Jeff Johnson295189b2012-06-20 16:38:30 -07008036 {
8037 // Inform HDD to turn off FT flag in HDD
8038 if (pNeighborRoamInfo)
8039 {
8040 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8041 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
8042 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07008043 /*
8044 * Since the above callback sends a disconnect
8045 * to HDD, we should clean-up our state
8046 * machine as well to be in sync with the upper
8047 * layers. There is no need to send a disassoc
8048 * since: 1) we will never reassoc to the current
8049 * AP in LFR, and 2) there is no need to issue a
8050 * disassoc to the AP with which we were trying
8051 * to reassoc.
8052 */
8053 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8054 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008055 }
8056 }
8057#endif
8058 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
8059 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
8060 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
8061 //The disassoc rsp message will remove the command from active list
8062 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
8063 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
8064 {
8065 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8066 }
8067 }
8068}
8069
Jeff Johnson295189b2012-06-20 16:38:30 -07008070static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
8071{
Jeff Johnson295189b2012-06-20 16:38:30 -07008072#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8073 {
8074 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008075 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8076 if(pIbssLog)
8077 {
8078 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8079 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
8080 {
8081 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8082 }
8083 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8084 }
8085 }
8086#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008087 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8088 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8089 {
8090 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8091 }
8092 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8093 {
8094 csrRoamReissueRoamCommand(pMac);
8095 }
8096}
8097
Jeff Johnson295189b2012-06-20 16:38:30 -07008098void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8099{
8100 tSirResultCodes statusCode;
8101#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8102 tScanResultHandle hBSSList;
8103 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8104 eHalStatus status;
8105 tCsrRoamInfo roamInfo;
8106 tCsrScanResultFilter *pScanFilter = NULL;
8107 tANI_U32 roamId = 0;
8108 tCsrRoamProfile *pCurRoamProfile = NULL;
8109 tListElem *pEntry = NULL;
8110 tSmeCmd *pCommand = NULL;
8111#endif
8112 tANI_U32 sessionId;
8113 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07008114
Jeff Johnson295189b2012-06-20 16:38:30 -07008115 tSirSmeDisassocRsp SmeDisassocRsp;
8116
8117 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8118 sessionId = SmeDisassocRsp.sessionId;
8119 statusCode = SmeDisassocRsp.statusCode;
8120
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008121 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008122
8123 if ( csrIsConnStateInfra( pMac, sessionId ) )
8124 {
8125 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8126 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008127 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008128
8129 if(!pSession)
8130 {
8131 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8132 return;
8133 }
8134
Jeff Johnson295189b2012-06-20 16:38:30 -07008135 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8136 {
8137 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8138 }
8139 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8140 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8141 {
8142 if ( eSIR_SME_SUCCESS == statusCode )
8143 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008144 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008145 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8146 }
8147 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8148 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008149 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8150 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308151 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8152 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008153#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008154 /*
8155 * First ensure if the roam profile is in the scan cache.
8156 * If not, post a reassoc failure and disconnect.
8157 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308158 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8159 if ( NULL == pScanFilter )
8160 status = eHAL_STATUS_FAILURE;
8161 else
8162 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008163 if(HAL_STATUS_SUCCESS(status))
8164 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308165 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008166 status = csrRoamPrepareFilterFromProfile(pMac,
8167 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8168 if(!HAL_STATUS_SUCCESS(status))
8169 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008170 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008171 __func__, status);
8172 goto POST_ROAM_FAILURE;
8173 }
8174 else
8175 {
8176 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8177 if (!HAL_STATUS_SUCCESS(status))
8178 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008179 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008180 __func__, status);
8181 goto POST_ROAM_FAILURE;
8182 }
8183 }
8184 }
8185 else
8186 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008187 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008188 __func__, status);
8189 goto POST_ROAM_FAILURE;
8190 }
8191
8192 /*
8193 * After ensuring that the roam profile is in the scan result list,
8194 * dequeue the command from the active list.
8195 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008196 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8197 if ( pEntry )
8198 {
8199 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008200 /* If the head of the queue is Active and it is a ROAM command, remove
8201 * and put this on the Free queue.
8202 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008203 if ( eSmeCommandRoam == pCommand->command )
8204 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008205
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008206 /*
8207 * we need to process the result first before removing it from active list
8208 * because state changes still happening insides roamQProcessRoamResults so
8209 * no other roam command should be issued.
8210 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008211 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8212 if(pCommand->u.roamCmd.fReleaseProfile)
8213 {
8214 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8215 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008217 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008218 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008219 else
8220 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008221 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008222 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008223 }
8224 }
8225 else
8226 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008227 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008228 }
8229 }
8230 else
8231 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008232 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008233 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008234
8235 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008236 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8237
Kiet Lam64c1b492013-07-12 13:56:44 +05308238 vos_mem_copy(roamInfo.bssid,
8239 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8240 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008241
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008242 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8243 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008244
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008245 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308246 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8247 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008248 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308249 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008250 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8251 //make sure to put it at the head of the cmd queue
8252 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8253 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8254 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8255
Jeff Johnson295189b2012-06-20 16:38:30 -07008256 if(!HAL_STATUS_SUCCESS(status))
8257 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008258 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008259 __func__, status);
8260 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008261 }
8262
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008263 /* Notify sub-modules like QoS etc. that handoff happening */
8264 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008265 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308266 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008267 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308268 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008269 return;
8270 }
8271
8272POST_ROAM_FAILURE:
8273 if (pScanFilter)
8274 {
8275 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308276 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008277 }
8278 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308279 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008280
8281 /* Inform the upper layers that the reassoc failed */
8282 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8283 csrRoamCallCallback(pMac, sessionId,
8284 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8285
8286 /*
8287 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8288 * Upon success, we would re-enter this routine after receiving the disassoc
8289 * response and will fall into the reassoc fail sub-state. And, eventually
8290 * call csrRoamComplete which would remove the roam command from SME active
8291 * queue.
8292 */
8293 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8294 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8295 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008296 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008297 __func__, status);
8298 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008299 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008300#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008301
Jeff Johnson295189b2012-06-20 16:38:30 -07008302 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8303 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8304 {
8305 // Disassoc due to Reassoc failure falls into this codepath....
8306 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8307 }
8308 else
8309 {
8310 if ( eSIR_SME_SUCCESS == statusCode )
8311 {
8312 // Successfully disassociated from the 'old' Bss...
8313 //
8314 // We get Disassociate response in three conditions.
8315 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8316 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8317 // Infrastructure network.
8318 // - Third is where we are doing an Infra to Infra roam between networks with different
8319 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8320
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008321 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008322 }
8323 else
8324 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008325 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008326 }
8327 //We are not done yet. Get the data and continue roaming
8328 csrRoamReissueRoamCommand(pMac);
8329 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008330}
8331
Jeff Johnson295189b2012-06-20 16:38:30 -07008332static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8333{
8334 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008335 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008336 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008337 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008338 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008339 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8340 {
8341 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8342 }
8343 else
8344 {
8345 if ( eSIR_SME_SUCCESS == statusCode )
8346 {
8347 // Successfully deauth from the 'old' Bss...
8348 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008349 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008350 }
8351 else
8352 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008353 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008354 }
8355 //We are not done yet. Get the data and continue roaming
8356 csrRoamReissueRoamCommand(pMac);
8357 }
8358}
8359
Jeff Johnson295189b2012-06-20 16:38:30 -07008360static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8361{
8362 eCsrRoamCompleteResult result;
8363
8364 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8365 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008366 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008367 result = eCsrStartBssSuccess;
8368 }
8369 else
8370 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008371 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008372 //Let csrRoamComplete decide what to do
8373 result = eCsrStartBssFailure;
8374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008375 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008376}
8377
Jeff Johnson295189b2012-06-20 16:38:30 -07008378/*
8379 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8380 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8381 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8382 For the messages where sender allocates memory for specific structures, then it can be
8383 cast accordingly.
8384*/
8385void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8386{
8387 tSirSmeRsp *pSmeRsp;
8388 tSmeIbssPeerInd *pIbssPeerInd;
8389 tCsrRoamInfo roamInfo;
8390 // TODO Session Id need to be acquired in this function
8391 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008392 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308393 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8394 pSmeRsp->messageType, pSmeRsp->messageType,
8395 macTraceGetcsrRoamSubState(
8396 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008397 pSmeRsp->messageType = (pSmeRsp->messageType);
8398 pSmeRsp->length = (pSmeRsp->length);
8399 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008400 switch (pSmeRsp->messageType)
8401 {
8402
8403 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8404 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8405 {
8406 //We sent a JOIN_REQ
8407 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8408 }
8409 break;
8410
8411 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8412 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8413 {
8414 //We sent a AUTH_REQ
8415 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8416 }
8417 break;
8418
8419 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8420 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8421 {
8422 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8423 }
8424 break;
8425
8426 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8427 {
8428 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8429 }
8430 break;
8431
8432 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8433 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8434 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8435 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8436 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8437 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8438//HO
8439 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8440 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308441 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8442 macTraceGetcsrRoamSubState(
8443 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008444 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05308445#ifdef DEBUG_ROAM_DELAY
8446 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
8447#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008448 }
8449 break;
8450
8451 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8452 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8453 {
8454 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8455 }
8456 break;
8457
8458 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8459 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8460 {
8461 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8462 }
8463 break;
8464
8465 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8466 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8467 {
8468 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8469 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008470 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008471 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8472 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8473 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008474 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308475 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8476 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008477 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8478 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308479 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8480 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008481 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8482 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8483 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8484 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008485 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308486 smsLog(pMac, LOG1,
8487 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8488 pSmeRsp->messageType, pSmeRsp->messageType,
8489 macTraceGetcsrRoamSubState(
8490 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008491
8492 //If we are connected, check the link status change
8493 if(!csrIsConnStateDisconnected(pMac, sessionId))
8494 {
8495 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8496 }
8497 break;
8498 }
8499}
8500
Jeff Johnson295189b2012-06-20 16:38:30 -07008501void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8502{
8503 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008504 switch (pSirMsg->messageType)
8505 {
8506 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008507 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008508 csrRoamStatsRspProcessor( pMac, pSirMsg );
8509 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008510 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8511 {
8512 tCsrRoamSession *pSession;
8513 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8514 tCsrRoamInfo roamInfo;
8515 tCsrRoamInfo *pRoamInfo = NULL;
8516 tANI_U32 sessionId;
8517 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008518 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308519 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008520 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008521 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8522 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8523 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008524
8525 if(!pSession)
8526 {
8527 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8528 return;
8529 }
8530
Jeff Johnson295189b2012-06-20 16:38:30 -07008531 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8532 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008533 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8534 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8535 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008536 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8537 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308538 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8539 sizeof(tSirMacAddr));
8540 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8541 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008542 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05308543#ifdef WLAN_FEATURE_AP_HT40_24G
8544 pRoamInfo->HT40MHzIntoEnabledSta =
8545 pUpperLayerAssocCnf->HT40MHzIntoEnabledSta;
8546 smsLog( pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
8547 pRoamInfo->HT40MHzIntoEnabledSta);
8548#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008549 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8550 {
8551 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8552 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8553 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8554 }
8555 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8556 {
8557 vos_sleep( 100 );
8558 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8559 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8560 }
8561
Jeff Johnson295189b2012-06-20 16:38:30 -07008562 }
8563 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008564 default:
8565 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8566 break;
8567 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008568}
8569
Jeff Johnson295189b2012-06-20 16:38:30 -07008570eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8571 tSirBssDescription *pBssDescription,
8572 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8573 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8574 tANI_U8 keyId, tANI_U16 keyLength,
8575 tANI_U8 *pKey, tANI_U8 paeRole )
8576{
8577 eHalStatus status = eHAL_STATUS_SUCCESS;
8578 tAniEdType edType;
8579
8580 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8581 {
8582 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8583 }
8584
8585 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8586
8587 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8588 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8589 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8590 addKey )
8591 {
8592 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008593 setKey.encType = EncryptType;
8594 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308595 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008596 setKey.paeRole = paeRole; //0 for supplicant
8597 setKey.keyId = keyId; // Kye index
8598 setKey.keyLength = keyLength;
8599 if( keyLength )
8600 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308601 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008602 }
8603 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8604 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008605 return (status);
8606}
8607
Jeff Johnson295189b2012-06-20 16:38:30 -07008608static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8609 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8610{
8611 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8612 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008613#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008614 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008615#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07008616
8617 do
8618 {
8619 pCommand = csrGetCommandBuffer(pMac);
8620 if(NULL == pCommand)
8621 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008622 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008623 status = eHAL_STATUS_RESOURCES;
8624 break;
8625 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05308626 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07008627 pCommand->command = eSmeCommandSetKey;
8628 pCommand->sessionId = (tANI_U8)sessionId;
8629 // validate the key length, Adjust if too long...
8630 // for static WEP the keys are not set thru' SetContextReq
8631 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8632 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8633 {
8634 //KeyLength maybe 0 for static WEP
8635 if( pSetKey->keyLength )
8636 {
8637 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8638 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008639 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008640 break;
8641 }
8642
8643 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308644 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8645 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008646 }
8647 }
8648 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8649 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8650 {
8651 //KeyLength maybe 0 for static WEP
8652 if( pSetKey->keyLength )
8653 {
8654 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8655 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008656 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008657 break;
8658 }
8659
8660 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308661 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8662 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008663 }
8664 }
8665 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8666 {
8667 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8668 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008669 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008670 break;
8671 }
8672 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308673 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8674 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008675 }
8676 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8677 {
8678 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8679 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008680 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008681 break;
8682 }
8683 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308684 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8685 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008686 }
8687#ifdef FEATURE_WLAN_WAPI
8688 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8689 {
8690 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8691 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008692 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008693 break;
8694 }
8695 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308696 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8697 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008698 }
8699#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008700#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008701 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8702 {
8703 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8704 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008705 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008706 break;
8707 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008708 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05308709 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008710 pSession->eseCckmInfo.reassoc_req_num=1;
8711 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008712 status = eHAL_STATUS_SUCCESS;
8713 break;
8714 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008715#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07008716
Jeff Johnson295189b2012-06-20 16:38:30 -07008717#ifdef WLAN_FEATURE_11W
8718 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008719 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008720 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008721 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008722 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008723 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008724 break;
8725 }
8726 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308727 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008728 }
8729#endif
8730 status = eHAL_STATUS_SUCCESS;
8731 pCommand->u.setKeyCmd.roamId = roamId;
8732 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8733 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308734 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8735 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008736 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8737 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308738 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008739 //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
8740
8741 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8742 if( !HAL_STATUS_SUCCESS( status ) )
8743 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008744 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008745 }
8746 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008747 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008748 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008749 if ( ( NULL != pCommand ) &&
8750 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008751#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008752 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008753#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008754 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008755 {
8756 csrReleaseCommandSetKey( pMac, pCommand );
8757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008758 return( status );
8759}
8760
Jeff Johnson295189b2012-06-20 16:38:30 -07008761eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8762 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8763{
8764 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8765 tSmeCmd *pCommand = NULL;
8766 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008767 do
8768 {
8769 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8770 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008771 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008772 status = eHAL_STATUS_CSR_WRONG_STATE;
8773 break;
8774 }
8775 pCommand = csrGetCommandBuffer(pMac);
8776 if(NULL == pCommand)
8777 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008778 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008779 status = eHAL_STATUS_RESOURCES;
8780 break;
8781 }
8782 pCommand->command = eSmeCommandRemoveKey;
8783 pCommand->sessionId = (tANI_U8)sessionId;
8784 pCommand->u.removeKeyCmd.roamId = roamId;
8785 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308786 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8787 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008788 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8789 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8790 {
8791 //in this case, put it to the end of the Q incase there is a set key pending.
8792 fImediate = eANI_BOOLEAN_FALSE;
8793 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008794 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008795 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008796 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008797 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8798 if( !HAL_STATUS_SUCCESS( status ) )
8799 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008800 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008801 break;
8802 }
8803 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008804 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8805 {
8806 csrReleaseCommandRemoveKey( pMac, pCommand );
8807 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008808 return (status );
8809}
8810
Jeff Johnson295189b2012-06-20 16:38:30 -07008811eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8812{
8813 eHalStatus status;
8814 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8815 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8816 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8817 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008818#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8819 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8820 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05308821 if(!pSession)
8822 {
8823 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8824 return eHAL_STATUS_FAILURE;
8825 }
lukez3c809222013-05-03 10:23:02 -07008826 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008827 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308828 vos_mem_set(&setKeyEvent,
8829 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008830 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8831 {
8832 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8833 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8834 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8835 }
8836 else
8837 {
8838 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8839 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8840 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8841 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308842 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008843 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008844 {
8845 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008846 //It has to be static WEP here
8847 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8848 {
8849 setKeyEvent.keyId = (v_U8_t)defKeyId;
8850 }
8851 }
8852 else
8853 {
8854 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8855 }
8856 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8857 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8858 }
8859#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008860 if( csrIsSetKeyAllowed(pMac, sessionId) )
8861 {
8862 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8863 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8864 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8865 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8866 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8867 pCommand->u.setKeyCmd.keyRsc);
8868 }
8869 else
8870 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008871 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008872 //Set this status so the error handling take care of the case.
8873 status = eHAL_STATUS_CSR_WRONG_STATE;
8874 }
8875 if( !HAL_STATUS_SUCCESS(status) )
8876 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008877 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008878 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008879#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008880 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008881 {
8882 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8883 {
8884 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8885 }
8886 else
8887 {
8888 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8889 }
8890 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8891 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8892 }
8893#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008894 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008895 return ( status );
8896}
8897
Jeff Johnson295189b2012-06-20 16:38:30 -07008898eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8899{
8900 eHalStatus status;
8901 tpSirSmeRemoveKeyReq pMsg = NULL;
8902 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8903 tANI_U8 *p;
8904 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008905#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8906 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8907 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05308908 if(!pSession)
8909 {
8910 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8911 return eHAL_STATUS_FAILURE;
8912 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308913 vos_mem_set(&removeKeyEvent,
8914 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008915 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8916 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8917 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308918 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008919 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8920 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8921 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8922#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008923 if( csrIsSetKeyAllowed(pMac, sessionId) )
8924 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308925 pMsg = vos_mem_malloc(wMsgLen);
8926 if ( NULL == pMsg )
8927 status = eHAL_STATUS_FAILURE;
8928 else
8929 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008930 }
8931 else
8932 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008933 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008934 //Set the error status so error handling kicks in below
8935 status = eHAL_STATUS_CSR_WRONG_STATE;
8936 }
8937 if( HAL_STATUS_SUCCESS( status ) )
8938 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308939 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008940 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8941 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008942 pMsg->sessionId = (tANI_U8)sessionId;
8943 pMsg->transactionId = 0;
8944 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8945 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8946 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308947 vos_mem_copy(p,
8948 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8949 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008950 p += sizeof(tSirMacAddr);
8951 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308952 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008953 p += sizeof(tSirMacAddr);
8954 // edType
8955 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8956 p++;
8957 // weptype
8958 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8959 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8960 {
8961 *p = (tANI_U8)eSIR_WEP_STATIC;
8962 }
8963 else
8964 {
8965 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8966 }
8967 p++;
8968 //keyid
8969 *p = pCommand->u.removeKeyCmd.keyId;
8970 p++;
8971 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008972 status = palSendMBMessage(pMac->hHdd, pMsg);
8973 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008974 if( !HAL_STATUS_SUCCESS( status ) )
8975 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008976 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008977#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8978 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008979 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008980 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8981#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008982 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8983 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008984 return ( status );
8985}
8986
Jeff Johnson295189b2012-06-20 16:38:30 -07008987eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8988{
8989 eHalStatus status;
8990
8991 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8992 {
8993 status = eHAL_STATUS_CSR_WRONG_STATE;
8994 }
8995 else
8996 {
8997 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8998 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008999 return ( status );
9000}
9001
Jeff Johnson295189b2012-06-20 16:38:30 -07009002/*
9003 Prepare a filter base on a profile for parsing the scan results.
9004 Upon successful return, caller MUST call csrFreeScanFilter on
9005 pScanFilter when it is done with the filter.
9006*/
9007eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
9008 tCsrScanResultFilter *pScanFilter)
9009{
9010 eHalStatus status = eHAL_STATUS_SUCCESS;
9011 tANI_U32 size = 0;
9012 tANI_U8 index = 0;
9013
9014 do
9015 {
9016 if(pProfile->BSSIDs.numOfBSSIDs)
9017 {
9018 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309019 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
9020 if ( NULL == pScanFilter->BSSIDs.bssid )
9021 status = eHAL_STATUS_FAILURE;
9022 else
9023 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009024 if(!HAL_STATUS_SUCCESS(status))
9025 {
9026 break;
9027 }
9028 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309029 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009030 }
9031 if(pProfile->SSIDs.numOfSSIDs)
9032 {
9033 if( !CSR_IS_WDS_STA( pProfile ) )
9034 {
9035 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
9036 }
9037 else
9038 {
9039 //For WDS station
9040 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
9041 pScanFilter->SSIDs.numOfSSIDs = 1;
9042 }
9043 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309044 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
9045 if ( NULL == pScanFilter->SSIDs.SSIDList )
9046 status = eHAL_STATUS_FAILURE;
9047 else
9048 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009049 if(!HAL_STATUS_SUCCESS(status))
9050 {
9051 break;
9052 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309053 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
9054 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009055 }
9056 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
9057 {
9058 pScanFilter->ChannelInfo.numOfChannels = 0;
9059 pScanFilter->ChannelInfo.ChannelList = NULL;
9060 }
9061 else if(pProfile->ChannelInfo.numOfChannels)
9062 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309063 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
9064 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
9065 pProfile->ChannelInfo.numOfChannels);
9066 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
9067 status = eHAL_STATUS_FAILURE;
9068 else
9069 status = eHAL_STATUS_SUCCESS;
9070
Jeff Johnson295189b2012-06-20 16:38:30 -07009071 pScanFilter->ChannelInfo.numOfChannels = 0;
9072 if(HAL_STATUS_SUCCESS(status))
9073 {
9074 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
9075 {
9076 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
9077 {
9078 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
9079 = pProfile->ChannelInfo.ChannelList[index];
9080 pScanFilter->ChannelInfo.numOfChannels++;
9081 }
9082 else
9083 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009084 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009085 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009086 }
9087 }
9088 else
9089 {
9090 break;
9091 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009092 }
9093 else
9094 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05309095 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009096 status = eHAL_STATUS_FAILURE;
9097 break;
9098 }
9099 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
9100 pScanFilter->authType = pProfile->AuthType;
9101 pScanFilter->EncryptionType = pProfile->EncryptionType;
9102 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9103 pScanFilter->BSSType = pProfile->BSSType;
9104 pScanFilter->phyMode = pProfile->phyMode;
9105#ifdef FEATURE_WLAN_WAPI
9106 //check if user asked for WAPI with 11n or auto mode, in that case modify
9107 //the phymode to 11g
9108 if(csrIsProfileWapi(pProfile))
9109 {
9110 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9111 {
9112 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9113 }
9114 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9115 {
9116 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9117 }
9118 if(!pScanFilter->phyMode)
9119 {
9120 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9121 }
9122 }
9123#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009124 /*Save the WPS info*/
9125 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009126 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009127 if( pProfile->countryCode[0] )
9128 {
9129 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309130 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9131 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009132 }
9133#ifdef WLAN_FEATURE_VOWIFI_11R
9134 if (pProfile->MDID.mdiePresent)
9135 {
9136 pScanFilter->MDID.mdiePresent = 1;
9137 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9138 }
9139#endif
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309140
9141#ifdef WLAN_FEATURE_11W
9142 // Management Frame Protection
9143 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9144 pScanFilter->MFPRequired = pProfile->MFPRequired;
9145 pScanFilter->MFPCapable = pProfile->MFPCapable;
9146#endif
9147
Jeff Johnson295189b2012-06-20 16:38:30 -07009148 }while(0);
9149
9150 if(!HAL_STATUS_SUCCESS(status))
9151 {
9152 csrFreeScanFilter(pMac, pScanFilter);
9153 }
9154
9155 return(status);
9156}
9157
Jeff Johnson295189b2012-06-20 16:38:30 -07009158tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9159 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9160{
9161 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9162 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009163 do
9164 {
9165 // Validate the type is ok...
9166 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9167 pCommand = csrGetCommandBuffer( pMac );
9168 if ( !pCommand )
9169 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009170 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009171 break;
9172 }
9173 //Change the substate in case it is waiting for key
9174 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9175 {
9176 csrRoamStopWaitForKeyTimer( pMac );
9177 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9178 }
9179 pCommand->command = eSmeCommandWmStatusChange;
9180 pCommand->sessionId = (tANI_U8)sessionId;
9181 pCommand->u.wmStatusChangeCmd.Type = Type;
9182 if ( eCsrDisassociated == Type )
9183 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309184 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9185 pSmeRsp,
9186 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009187 }
9188 else
9189 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309190 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9191 pSmeRsp,
9192 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009193 }
9194 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9195 {
9196 fCommandQueued = eANI_BOOLEAN_TRUE;
9197 }
9198 else
9199 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009200 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009201 csrReleaseCommandWmStatusChange( pMac, pCommand );
9202 }
9203
Jeff Johnson295189b2012-06-20 16:38:30 -07009204 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9205 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009206 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009207 return( fCommandQueued );
9208}
9209
Jeff Johnson295189b2012-06-20 16:38:30 -07009210static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9211{
9212 v_S7_t rssi = 0;
9213 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9214 if(pGetRssiReq)
9215 {
9216 if(NULL != pGetRssiReq->pVosContext)
9217 {
9218 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9219 }
9220 else
9221 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009222 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009223 return;
9224 }
9225
9226 if(NULL != pGetRssiReq->rssiCallback)
9227 {
9228 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9229 }
9230 else
9231 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009232 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009233 return;
9234 }
9235 }
9236 else
9237 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009238 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009239 }
9240 return;
9241}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309242
9243static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9244{
9245 tANI_S8 snr = 0;
9246 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9247
9248 if (pGetSnrReq)
9249 {
9250 if (VOS_STATUS_SUCCESS !=
9251 WDA_GetSnr(pGetSnrReq->staId, &snr))
9252 {
9253 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9254 return;
9255 }
9256
9257 if (pGetSnrReq->snrCallback)
9258 {
9259 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9260 pGetSnrReq->pDevContext);
9261 }
9262 else
9263 {
9264 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9265 return;
9266 }
9267 }
9268 else
9269 {
9270 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9271 }
9272 return;
9273}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009274#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009275void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9276{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009277 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9278
Jeff Johnson36d483b2013-04-08 11:08:53 -07009279 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009280 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009281 /* Get roam Rssi request is backed up and passed back to the response,
9282 Extract the request message to fetch callback */
9283 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9284 v_S7_t rssi = pRoamRssiRsp->rssi;
9285
9286 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009287 {
9288 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9289 reqBkp->rssiCallback = NULL;
9290 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009291 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009292 }
9293 else
9294 {
9295 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9296 if (NULL != reqBkp)
9297 {
9298 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009299 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009300 }
9301 }
9302 }
9303 else
9304 {
9305 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9306 }
9307 return;
9308}
9309#endif
9310
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009311
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009312#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009313void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9314{
9315 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9316
9317 if (NULL != pTsmStatsRsp)
9318 {
9319 /* Get roam Rssi request is backed up and passed back to the response,
9320 Extract the request message to fetch callback */
9321 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9322
9323 if (NULL != reqBkp)
9324 {
9325 if (NULL != reqBkp->tsmStatsCallback)
9326 {
9327 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9328 pTsmStatsRsp->staId, reqBkp->pDevContext);
9329 reqBkp->tsmStatsCallback = NULL;
9330 }
9331 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009332 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009333 }
9334 else
9335 {
9336 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9337 if (NULL != reqBkp)
9338 {
9339 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009340 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009341 }
9342 }
9343 }
9344 else
9345 {
9346 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9347 }
9348 return;
9349}
9350
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009351void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009352{
9353 tANI_U32 roamTS2 = 0;
9354 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009355 tpPESession pSessionEntry = NULL;
9356 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009357
9358 if (NULL == pSession)
9359 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009360 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009361 return;
9362 }
9363
9364 roamTS2 = vos_timer_get_system_time();
9365 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009366 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9367 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009368 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009369
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009370 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9371 if (NULL == pSessionEntry)
9372 {
9373 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9374 return;
9375 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009376 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009377 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009378 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009379}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009380#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009381
Jeff Johnsone7245742012-09-05 17:12:55 -07009382static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9383{
9384 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9385 if(pTlRssiInd)
9386 {
9387 if(NULL != pTlRssiInd->tlCallback)
9388 {
9389 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009390 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009391 }
9392 else
9393 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009394 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009395 }
9396 }
9397 else
9398 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009399 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009400 }
9401 return;
9402}
Jeff Johnson295189b2012-06-20 16:38:30 -07009403
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309404eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9405{
9406 tpSirResetAPCapsChange pMsg;
9407 tANI_U16 len;
9408 eHalStatus status = eHAL_STATUS_SUCCESS;
9409
9410 /* Create the message and send to lim */
9411 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309412 pMsg = vos_mem_malloc(len);
9413 if ( NULL == pMsg )
9414 status = eHAL_STATUS_FAILURE;
9415 else
9416 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309417 if (HAL_STATUS_SUCCESS(status))
9418 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309419 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309420 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9421 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309422 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009423 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9424 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309425 status = palSendMBMessage(pMac->hHdd, pMsg);
9426 }
9427 else
9428 {
9429 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9430 }
9431 return status;
9432}
9433
Jeff Johnson295189b2012-06-20 16:38:30 -07009434void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9435{
9436 tSirSmeAssocInd *pAssocInd;
9437 tSirSmeDisassocInd *pDisassocInd;
9438 tSirSmeDeauthInd *pDeauthInd;
9439 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9440 tSirSmeNewBssInfo *pNewBss;
9441 tSmeIbssPeerInd *pIbssPeerInd;
9442 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9443 tSirSmeApNewCaps *pApNewCaps;
9444 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9445 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9446 tCsrRoamInfo *pRoamInfo = NULL;
9447 tCsrRoamInfo roamInfo;
9448 eHalStatus status;
9449 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9450 tCsrRoamSession *pSession = NULL;
9451 tpSirSmeSwitchChannelInd pSwitchChnInd;
9452 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309453 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009454
9455
9456 if (NULL == pSirMsg)
9457 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9458 return;
9459 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009460 switch( pSirMsg->messageType )
9461 {
9462 case eWNI_SME_ASSOC_IND:
9463 {
9464 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009465 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009466 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9467 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9468 if( HAL_STATUS_SUCCESS( status ) )
9469 {
9470 pSession = CSR_GET_SESSION(pMac, sessionId);
9471
Jeff Johnson32d95a32012-09-10 13:15:23 -07009472 if(!pSession)
9473 {
9474 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9475 return;
9476 }
9477
Jeff Johnson295189b2012-06-20 16:38:30 -07009478 pRoamInfo = &roamInfo;
9479
9480 // Required for indicating the frames to upper layer
9481 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9482 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9483
9484 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9485 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9486 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9487 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9488
9489 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9490 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9491 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9492
9493 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9494 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309495 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9496 sizeof(tSirMacAddr));
9497 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9498 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009499 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +05309500#ifdef WLAN_FEATURE_AP_HT40_24G
9501 pRoamInfo->HT40MHzIntoEnabledSta =
9502 pAssocInd->HT40MHzIntoEnabledSta;
9503 smsLog(pMac, LOGW, FL("HT40MHzIntoEnabledSta: %d \n"),
9504 pRoamInfo->HT40MHzIntoEnabledSta);
9505#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009506 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009507 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009508 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9509 {
9510 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9511 {
9512 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9513 pSession->pConnectBssDesc,
9514 &(pRoamInfo->peerMac),
9515 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9516 pRoamInfo->fAuthRequired = FALSE;
9517 }
9518 else
9519 {
9520 pRoamInfo->fAuthRequired = TRUE;
9521 }
9522 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9523 if (!HAL_STATUS_SUCCESS(status))
9524 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009526 /* Send Association completion message to PE */
9527 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9528
9529 /* send a message to CSR itself just to avoid the EAPOL frames going
9530 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009531 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9532 {
9533 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9534 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009535 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9536 {
9537 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9538 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9539 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9540 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009541 }
9542 }
9543 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009544 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009545 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309546 // Check if AP dis-associated us because of MIC failure. If so,
9547 // then we need to take action immediately and not wait till the
9548 // the WmStatusChange requests is pushed and processed
9549 tSmeCmd *pCommand;
9550
9551 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9552 status = csrRoamGetSessionIdFromBSSID( pMac,
9553 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9554 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009555 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309556 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9557 " for session %d "), sessionId);
9558 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9559 MAC_ADDRESS_STR " "
9560 " reason = %d status = %d "),
9561 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9562 pDisassocInd->reasonCode,
9563 pDisassocInd->statusCode);
9564 // If we are in neighbor preauth done state then on receiving
9565 // disassoc or deauth we dont roam instead we just disassoc
9566 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009567 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309568#ifdef WLAN_FEATURE_VOWIFI_11R
9569 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9570 {
9571 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9572 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009573#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009574#ifdef FEATURE_WLAN_ESE
9575 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309576 {
9577 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9578 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009579#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009580#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309581 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9582 {
9583 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9584 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009585#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309586 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009587
Agarwal Ashish4f616132013-12-30 23:32:50 +05309588 if (!pSession)
9589 {
9590 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9591 return;
9592 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009593
Agarwal Ashish4f616132013-12-30 23:32:50 +05309594 if ( csrIsConnStateInfra( pMac, sessionId ) )
9595 {
9596 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9597 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009598#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309599 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009600#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309601 csrRoamLinkDown(pMac, sessionId);
9602 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9603 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9604 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309605 pRoamInfo = &roamInfo;
9606 pRoamInfo->statusCode = pDisassocInd->statusCode;
9607 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9608 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009609
Agarwal Ashish4f616132013-12-30 23:32:50 +05309610 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9611 sizeof(tSirMacAddr));
9612 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9613 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009614
Agarwal Ashish4f616132013-12-30 23:32:50 +05309615 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9616 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009617
Agarwal Ashish4f616132013-12-30 23:32:50 +05309618 /*
9619 * STA/P2P client got disassociated so remove any pending deauth
9620 * commands in sme pending list
9621 */
Kaushik, Sushant488df382014-03-05 11:43:47 +05309622 pCommand = csrGetCommandBuffer(pMac);
9623 if (NULL == pCommand)
9624 {
9625 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9626 status = eHAL_STATUS_RESOURCES;
9627 return;
9628 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309629 pCommand->command = eSmeCommandRoam;
9630 pCommand->sessionId = (tANI_U8)sessionId;
9631 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9632 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9633 pDisassocInd->peerMacAddr,
9634 sizeof(tSirMacAddr));
9635 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9636 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009637
Agarwal Ashish4f616132013-12-30 23:32:50 +05309638 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009639 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309640 else
9641 {
9642 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9643 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9644 }
Kiet Lam82004c62013-11-11 13:24:28 +05309645 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009646 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009647 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009648 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009649 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9650 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9651 if( HAL_STATUS_SUCCESS( status ) )
9652 {
9653 // If we are in neighbor preauth done state then on receiving
9654 // disassoc or deauth we dont roam instead we just disassoc
9655 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009656 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -07009657#ifdef WLAN_FEATURE_VOWIFI_11R
9658 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9659 {
9660 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9661 }
9662#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009663#ifdef FEATURE_WLAN_ESE
9664 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009665 {
9666 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9667 }
9668#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009669#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309670 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009671 {
9672 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9673 }
9674#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009675 pSession = CSR_GET_SESSION( pMac, sessionId );
9676
Jeff Johnson32d95a32012-09-10 13:15:23 -07009677 if(!pSession)
9678 {
9679 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9680 return;
9681 }
9682
Jeff Johnson295189b2012-06-20 16:38:30 -07009683 if ( csrIsConnStateInfra( pMac, sessionId ) )
9684 {
9685 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009687#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9688 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9689#endif
9690 csrRoamLinkDown(pMac, sessionId);
9691 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009692 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9693 {
9694
9695 pRoamInfo = &roamInfo;
9696
9697 pRoamInfo->statusCode = pDeauthInd->statusCode;
9698 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9699
9700 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9701
Kiet Lam64c1b492013-07-12 13:56:44 +05309702 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9703 sizeof(tSirMacAddr));
9704 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9705 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009706
9707 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9708 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009709 }
9710 break;
9711
9712 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 -08009713 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009714 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9715 //Update with the new channel id.
9716 //The channel id is hidden in the statusCode.
9717 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9718 if( HAL_STATUS_SUCCESS( status ) )
9719 {
9720 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009721 if(!pSession)
9722 {
9723 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9724 return;
9725 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009726 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9727 if(pSession->pConnectBssDesc)
9728 {
9729 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9730 }
9731 }
9732 break;
9733
9734 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009735 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009736 {
9737 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9738 sessionId = pDeauthRsp->sessionId;
9739 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9740 {
9741 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009742 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9743 {
9744 pRoamInfo = &roamInfo;
9745 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309746 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9747 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009748 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9749 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9750 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9751 }
9752 }
9753 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009754 break;
9755
9756 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009757 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009758 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009759 {
9760 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9761 sessionId = pDisassocRsp->sessionId;
9762 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9763 {
9764 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009765 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9766 {
9767 pRoamInfo = &roamInfo;
9768 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309769 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9770 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009771 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9772 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9773 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9774 }
9775 }
9776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009777 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009778 case eWNI_SME_MIC_FAILURE_IND:
9779 {
9780 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9781 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9782 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009783
9784 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9785 if( HAL_STATUS_SUCCESS( status ) )
9786 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309787 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009788 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9789 pRoamInfo = &roamInfo;
9790 if(pMicInd->info.multicast)
9791 {
9792 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9793 }
9794 else
9795 {
9796 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9797 }
9798 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9799 }
9800
Jeff Johnson295189b2012-06-20 16:38:30 -07009801#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9802 {
lukez3c809222013-05-03 10:23:02 -07009803 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009804 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009805 if(!pSession)
9806 {
9807 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9808 return;
9809 }
lukez3c809222013-05-03 10:23:02 -07009810
Kiet Lam64c1b492013-07-12 13:56:44 +05309811 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009812 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9813 secEvent.encryptionModeMulticast =
9814 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9815 secEvent.encryptionModeUnicast =
9816 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9817 secEvent.authMode =
9818 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309819 vos_mem_copy(secEvent.bssid,
9820 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009821 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9822 }
9823#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009824 }
9825 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009826 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9827 {
9828 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9829 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009830 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009831
9832 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9833 if( HAL_STATUS_SUCCESS( status ) )
9834 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309835 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009836 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9837 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9838 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9839 }
9840 }
9841 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009842
Jeff Johnson295189b2012-06-20 16:38:30 -07009843 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9844 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9845 switch( pStatusChangeMsg->statusChangeCode )
9846 {
9847 case eSIR_SME_IBSS_ACTIVE:
9848 sessionId = csrFindIbssSession( pMac );
9849 if( CSR_SESSION_ID_INVALID != sessionId )
9850 {
9851 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009852 if(!pSession)
9853 {
9854 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9855 return;
9856 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009857 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9858 if(pSession->pConnectBssDesc)
9859 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309860 vos_mem_copy(&roamInfo.bssid,
9861 pSession->pConnectBssDesc->bssId,
9862 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009863 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9864 pRoamInfo = &roamInfo;
9865 }
9866 else
9867 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009868 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009869 }
9870 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9871 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9872 }
9873 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009874 case eSIR_SME_IBSS_INACTIVE:
9875 sessionId = csrFindIbssSession( pMac );
9876 if( CSR_SESSION_ID_INVALID != sessionId )
9877 {
9878 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009879 if(!pSession)
9880 {
9881 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9882 return;
9883 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009884 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9885 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9886 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9887 }
9888 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009889 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9890 sessionId = csrFindIbssSession( pMac );
9891 if( CSR_SESSION_ID_INVALID != sessionId )
9892 {
9893 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009894 if(!pSession)
9895 {
9896 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9897 return;
9898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009899 // update the connection state information
9900 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009901#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9902 {
9903 vos_log_ibss_pkt_type *pIbssLog;
9904 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009905 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9906 if(pIbssLog)
9907 {
9908 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9909 if(pNewBss)
9910 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309911 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009912 if(pNewBss->ssId.length)
9913 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309914 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9915 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009916 }
9917 pIbssLog->operatingChannel = pNewBss->channelNumber;
9918 }
9919 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9920 {
9921 //***U8 is not enough for beacon interval
9922 pIbssLog->beaconInterval = (v_U8_t)bi;
9923 }
9924 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9925 }
9926 }
9927#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009928 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009929
9930 if ((eCSR_ENCRYPT_TYPE_NONE ==
9931 pSession->connectedProfile.EncryptionType ))
9932 {
9933 csrRoamIssueSetContextReq( pMac, sessionId,
9934 pSession->connectedProfile.EncryptionType,
9935 pSession->pConnectBssDesc,
9936 &Broadcastaddr,
9937 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009939 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9940 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309941 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9942 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009943 pRoamInfo = &roamInfo;
9944 //This BSSID is th ereal BSSID, let's save it
9945 if(pSession->pConnectBssDesc)
9946 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309947 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9948 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009949 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009950 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009951 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009952 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009953 // detection by LIM that the capabilities of the associated AP have changed.
9954 case eSIR_SME_AP_CAPS_CHANGED:
9955 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009956 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009957 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9958 if( HAL_STATUS_SUCCESS( status ) )
9959 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009960 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9961 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309962 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009963 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9964 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9965 )
9966 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309967 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9968 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009969 }
9970 else
9971 {
9972 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309973 FL("Skipping csrScanForCapabilityChange as "
9974 "CSR is in state %s and sub-state %s"),
9975 macTraceGetcsrRoamState(
9976 pMac->roam.curState[sessionId]),
9977 macTraceGetcsrRoamSubState(
9978 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309979 /* We ignore the caps change event if CSR is not in full connected state.
9980 * Send one event to PE to reset limSentCapsChangeNtf
9981 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9982 * otherwise lim cannot send any CAPS change events to SME */
9983 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009984 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009985 }
9986 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309987
Jeff Johnson295189b2012-06-20 16:38:30 -07009988 default:
9989 roamStatus = eCSR_ROAM_FAILED;
9990 result = eCSR_ROAM_RESULT_NONE;
9991 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009992 } // end switch on statusChangeCode
9993 if(eCSR_ROAM_RESULT_NONE != result)
9994 {
9995 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9996 }
9997 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009998 case eWNI_SME_IBSS_NEW_PEER_IND:
9999 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070010000#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10001 {
10002 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070010003 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10004 if(pIbssLog)
10005 {
10006 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +053010007 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010008 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10009 }
10010 }
10011#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070010012 sessionId = csrFindIbssSession( pMac );
10013 if( CSR_SESSION_ID_INVALID != sessionId )
10014 {
10015 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010016
10017 if(!pSession)
10018 {
10019 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10020 return;
10021 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010022 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
10023 if(pSession->pConnectBssDesc)
10024 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010025 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10026 sizeof(tCsrBssid));
10027 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
10028 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010029 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
10030 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010031 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
10032 - sizeof(tSmeIbssPeerInd)));
10033 if ( NULL == roamInfo.pbFrames )
10034 status = eHAL_STATUS_FAILURE;
10035 else
10036 status = eHAL_STATUS_SUCCESS;
10037 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010038 {
10039 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +053010040 vos_mem_copy(roamInfo.pbFrames,
10041 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
10042 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070010043 }
10044 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10045 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10046 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010047 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
10048 if ( NULL == roamInfo.pBssDesc )
10049 status = eHAL_STATUS_FAILURE;
10050 else
10051 status = eHAL_STATUS_SUCCESS;
10052 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010053 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010054 vos_mem_copy(roamInfo.pBssDesc,
10055 pSession->pConnectBssDesc,
10056 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010057 }
10058 if(HAL_STATUS_SUCCESS(status))
10059 {
10060 pRoamInfo = &roamInfo;
10061 }
10062 else
10063 {
10064 if(roamInfo.pbFrames)
10065 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010066 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010067 }
10068 if(roamInfo.pBssDesc)
10069 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010070 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010071 }
10072 }
10073 }
10074 else
10075 {
10076 pRoamInfo = &roamInfo;
10077 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010078 if ((eCSR_ENCRYPT_TYPE_NONE ==
10079 pSession->connectedProfile.EncryptionType ))
10080 {
10081 csrRoamIssueSetContextReq( pMac, sessionId,
10082 pSession->connectedProfile.EncryptionType,
10083 pSession->pConnectBssDesc,
10084 &(pIbssPeerInd->peerAddr),
10085 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10086 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010087 }
10088 else
10089 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010090 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010091 }
10092 //send up the sec type for the new peer
10093 if (pRoamInfo)
10094 {
10095 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10096 }
10097 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10098 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10099 if(pRoamInfo)
10100 {
10101 if(roamInfo.pbFrames)
10102 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010103 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010104 }
10105 if(roamInfo.pBssDesc)
10106 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010107 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010108 }
10109 }
10110 }
10111 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010112 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10113 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10114 sessionId = csrFindIbssSession( pMac );
10115 if( CSR_SESSION_ID_INVALID != sessionId )
10116 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010117#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10118 {
10119 vos_log_ibss_pkt_type *pIbssLog;
10120
10121 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10122 if(pIbssLog)
10123 {
10124 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10125 if(pIbssPeerInd)
10126 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010127 vos_mem_copy(pIbssLog->peerMacAddr,
10128 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010129 }
10130 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10131 }
10132 }
10133#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010134 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010135 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10136 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10137 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010138 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10139 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010140 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10141 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10142 }
10143 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010144 case eWNI_SME_SETCONTEXT_RSP:
10145 {
10146 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10147 tListElem *pEntry;
10148 tSmeCmd *pCommand;
10149
10150 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10151 if ( pEntry )
10152 {
10153 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10154 if ( eSmeCommandSetKey == pCommand->command )
10155 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010156 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010157 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010158
10159 if(!pSession)
10160 {
10161 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10162 return;
10163 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010164
10165#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10166 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10167 {
10168 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010169 vos_mem_set(&setKeyEvent,
10170 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010171 if( pRsp->peerMacAddr[0] & 0x01 )
10172 {
10173 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
10174 }
10175 else
10176 {
10177 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
10178 }
10179 setKeyEvent.encryptionModeMulticast =
10180 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10181 setKeyEvent.encryptionModeUnicast =
10182 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010183 vos_mem_copy(setKeyEvent.bssid,
10184 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010185 setKeyEvent.authMode =
10186 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010187 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010188 {
10189 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10190 }
10191 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10192 }
10193#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10194 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10195 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010196 csrRoamStopWaitForKeyTimer( pMac );
10197
Jeff Johnson295189b2012-06-20 16:38:30 -070010198 //We are done with authentication, whethere succeed or not
10199 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010200 //We do it here because this linkup function is not called after association
10201 //when a key needs to be set.
10202 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10203 {
10204 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10205 }
10206 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010207 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010208 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010209 vos_mem_copy(&roamInfo.peerMac,
10210 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010211 //Make sure we install the GTK before indicating to HDD as authenticated
10212 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010213 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10214 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010215 {
Yathish9f22e662012-12-10 14:21:35 -080010216#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10217 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10218 {
10219 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010220 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010221 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
10222 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
10223 pMsg->seesionId = sessionId;
10224 status = palSendMBMessage(pMac->hHdd, pMsg );
10225 }
10226#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010227 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010228 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
Hardik Kantilal Pateldb19a092014-11-21 17:01:42 +053010229 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE
10230 && (VOS_P2P_GO_MODE !=
10231 pSession->pCurRoamProfile->csrPersona
10232 && VOS_STA_SAP_MODE !=
10233 pSession->pCurRoamProfile->csrPersona))
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010234 {
10235 tpSirSmeHT40OBSSScanInd pMsg;
10236 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
10237 pMsg->messageType =
10238 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10239 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010240 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10241 vos_mem_copy(pMsg->peerMacAddr,
10242 pSession->connectedProfile.bssid,
10243 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010244 status = palSendMBMessage(pMac->hHdd,
10245 pMsg );
10246 }
10247 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010248 }
10249 else
10250 {
10251 result = eCSR_ROAM_RESULT_NONE;
10252 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010253 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010254 }
10255 else
10256 {
10257 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010258 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10259 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10260 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010261 }
10262 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10263 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010264 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10265 // can go ahead and initiate the TSPEC if any are pending
10266 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010267#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010268 //Send Adjacent AP repot to new AP.
10269 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10270 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010271 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010272 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010273#ifdef FEATURE_WLAN_ESE_UPLOAD
10274 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010275#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010276 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010277#endif
10278 pSession->isPrevApInfoValid = FALSE;
10279 }
10280#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010281 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10282 {
10283 csrReleaseCommandSetKey( pMac, pCommand );
10284 }
10285 }
10286 else
10287 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010288 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010289 }
10290 }
10291 else
10292 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010293 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010294 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010295 smeProcessPendingQueue( pMac );
10296 }
10297 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010298 case eWNI_SME_REMOVEKEY_RSP:
10299 {
10300 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10301 tListElem *pEntry;
10302 tSmeCmd *pCommand;
10303
10304 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10305 if ( pEntry )
10306 {
10307 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10308 if ( eSmeCommandRemoveKey == pCommand->command )
10309 {
10310 sessionId = pCommand->sessionId;
10311 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010312
10313 if(!pSession)
10314 {
10315 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10316 return;
10317 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010318#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10319 {
10320 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010321 vos_mem_set(&removeKeyEvent,
10322 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010323 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10324 removeKeyEvent.encryptionModeMulticast =
10325 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10326 removeKeyEvent.encryptionModeUnicast =
10327 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010328 vos_mem_copy( removeKeyEvent.bssid,
10329 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010330 removeKeyEvent.authMode =
10331 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010332 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010333 {
10334 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10335 }
10336 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10337 }
10338#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010339 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010340 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010341 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10342 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010343 result = eCSR_ROAM_RESULT_NONE;
10344 pRoamInfo = &roamInfo;
10345 }
10346 else
10347 {
10348 result = eCSR_ROAM_RESULT_FAILURE;
10349 }
10350 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10351 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10352 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10353 {
10354 csrReleaseCommandRemoveKey( pMac, pCommand );
10355 }
10356 }
10357 else
10358 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010359 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010360 }
10361 }
10362 else
10363 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010364 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010365 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010366 smeProcessPendingQueue( pMac );
10367 }
10368 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010369 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010370 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010371 csrRoamStatsRspProcessor( pMac, pSirMsg );
10372 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010373#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010374 case eWNI_SME_GET_ROAM_RSSI_RSP:
10375 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10376 csrRoamRssiRspProcessor( pMac, pSirMsg );
10377 break;
10378#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010379#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010380 case eWNI_SME_GET_TSM_STATS_RSP:
10381 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10382 csrTsmStatsRspProcessor( pMac, pSirMsg );
10383 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010384#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010385 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010386 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010387 csrUpdateRssi( pMac, pSirMsg );
10388 break;
10389
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010390 case eWNI_SME_GET_SNR_REQ:
10391 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10392 csrUpdateSnr(pMac, pSirMsg);
10393 break;
10394
Jeff Johnson295189b2012-06-20 16:38:30 -070010395#ifdef WLAN_FEATURE_VOWIFI_11R
10396 case eWNI_SME_FT_PRE_AUTH_RSP:
10397 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10398 break;
10399#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010400 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10401 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010402 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 -070010403 sessionId = pSmeMaxAssocInd->sessionId;
10404 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010405 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10406 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010407 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10408 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10409 break;
10410
10411 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010412 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010413 btampEstablishLogLinkHdlr( pSirMsg );
10414 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010415 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010416 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010417 csrRoamRssiIndHdlr( pMac, pSirMsg );
10418 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010419#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10420 case eWNI_SME_CANDIDATE_FOUND_IND:
10421 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10422 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10423 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010424 case eWNI_SME_HANDOFF_REQ:
10425 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10426 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10427 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010428#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010429
10430 default:
10431 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010432 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010433}
10434
Jeff Johnson295189b2012-06-20 16:38:30 -070010435void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10436 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10437{
10438 if(pSession)
10439 {
10440 if(pSession->bRefAssocStartCnt)
10441 {
10442 pSession->bRefAssocStartCnt--;
10443 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10444 //Need to call association_completion because there is an assoc_start pending.
10445 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10446 eCSR_ROAM_ASSOCIATION_COMPLETION,
10447 eCSR_ROAM_RESULT_FAILURE);
10448 }
10449 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10450 }
10451 else
10452 {
10453 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10454 }
10455}
10456
10457
10458eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10459{
10460 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010461 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10462 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10463 {
10464 status = csrScanRequestLostLink1( pMac, sessionId );
10465 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010466 return(status);
10467}
10468
Jeff Johnson295189b2012-06-20 16:38:30 -070010469//return a boolean to indicate whether roaming completed or continue.
10470tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10471 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10472{
10473 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10474 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10475 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10476 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010477 if(!pSession)
10478 {
10479 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10480 return eANI_BOOLEAN_FALSE;
10481 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010482 //Check whether time is up
10483 if(pSession->fCancelRoaming || fForce ||
10484 ((curTime - pSession->roamingStartTime) > roamTime) ||
10485 eCsrReassocRoaming == pSession->roamingReason ||
10486 eCsrDynamicRoaming == pSession->roamingReason)
10487 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010488 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010489 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10490 {
10491 //roaming is cancelled, tell HDD to indicate disconnect
10492 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10493 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10494 //to be eSIR_BEACON_MISSED
10495 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10496 {
10497 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10498 }
10499 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10500 {
10501 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10502 }
10503 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10504 {
10505 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10506 }
10507 else
10508 {
10509 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10510 }
10511 }
10512 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10513 pSession->roamingReason = eCsrNotRoaming;
10514 }
10515 else
10516 {
10517 pSession->roamResult = roamResult;
10518 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10519 {
10520 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10521 pSession->roamingReason = eCsrNotRoaming;
10522 }
10523 else
10524 {
10525 fCompleted = eANI_BOOLEAN_FALSE;
10526 }
10527 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010528 return(fCompleted);
10529}
10530
Jeff Johnson295189b2012-06-20 16:38:30 -070010531void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10532{
10533 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010534
10535 if(!pSession)
10536 {
10537 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10538 return;
10539 }
10540
Jeff Johnson295189b2012-06-20 16:38:30 -070010541 if(CSR_IS_ROAMING(pSession))
10542 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010543 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010544 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10545 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10546 {
10547 //No need to do anything in here because the handler takes care of it
10548 }
10549 else
10550 {
10551 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10552 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10553 //Roaming is stopped after here
10554 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10555 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010556 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010557 csrRoamStopRoamingTimer(pMac, sessionId);
10558 }
10559 }
10560}
10561
Jeff Johnson295189b2012-06-20 16:38:30 -070010562void csrRoamRoamingTimerHandler(void *pv)
10563{
10564 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10565 tpAniSirGlobal pMac = pInfo->pMac;
10566 tANI_U32 sessionId = pInfo->sessionId;
10567 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010568
10569 if(!pSession)
10570 {
10571 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10572 return;
10573 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010574
10575 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10576 {
10577 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10578 {
10579 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10580 pSession->roamingReason = eCsrNotRoaming;
10581 }
10582 }
10583}
10584
Jeff Johnson295189b2012-06-20 16:38:30 -070010585eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10586{
10587 eHalStatus status;
10588 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010589
10590 if(!pSession)
10591 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010592 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010593 return eHAL_STATUS_FAILURE;
10594 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010595
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010596 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010597 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010598 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010599
10600 return (status);
10601}
10602
Jeff Johnson295189b2012-06-20 16:38:30 -070010603eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10604{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010605 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010606}
10607
Jeff Johnson295189b2012-06-20 16:38:30 -070010608void csrRoamWaitForKeyTimeOutHandler(void *pv)
10609{
10610 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10611 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010612 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010613 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010614
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010615 smsLog(pMac, LOGW, FL("WaitForKey timer expired in state=%s sub-state=%s"),
10616 macTraceGetNeighbourRoamState(
10617 pMac->roam.neighborRoamInfo.neighborRoamState),
10618 macTraceGetcsrRoamSubState(
10619 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010620
Jeff Johnson295189b2012-06-20 16:38:30 -070010621 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10622 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010623#ifdef FEATURE_WLAN_LFR
10624 if (csrNeighborRoamIsHandoffInProgress(pMac))
10625 {
10626 /*
10627 * Enable heartbeat timer when hand-off is in progress
10628 * and Key Wait timer expired.
10629 */
10630 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010631 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010632 pMac->roam.configParam.HeartbeatThresh24);
10633 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10634 pMac->roam.configParam.HeartbeatThresh24,
10635 NULL, eANI_BOOLEAN_FALSE);
10636 }
10637#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010638 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010639
Jeff Johnson295189b2012-06-20 16:38:30 -070010640 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010641 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10642 {
10643 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10644 pInfo->sessionId);
10645 }
10646
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010647 if (pSession)
10648 {
10649 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10650 {
10651 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10652 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010653 if( (pSession->connectedProfile.AuthType ==
10654 eCSR_AUTH_TYPE_SHARED_KEY) &&
10655 ( (pSession->connectedProfile.EncryptionType ==
10656 eCSR_ENCRYPT_TYPE_WEP40) ||
10657 (pSession->connectedProfile.EncryptionType ==
10658 eCSR_ENCRYPT_TYPE_WEP104) ))
10659 {
10660 status = sme_AcquireGlobalLock( &pMac->sme );
10661 if ( HAL_STATUS_SUCCESS( status ) )
10662 {
10663 csrRoamDisconnect( pMac, pInfo->sessionId,
10664 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10665 sme_ReleaseGlobalLock( &pMac->sme );
10666 }
10667 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010668 }
10669 else
10670 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010671 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010672 __func__);
10673 }
10674 }
10675 else
10676 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010677 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010678 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010679 }
10680
10681}
10682
Jeff Johnson295189b2012-06-20 16:38:30 -070010683eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10684{
10685 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010686#ifdef FEATURE_WLAN_LFR
10687 if (csrNeighborRoamIsHandoffInProgress(pMac))
10688 {
10689 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010690 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
10691 macTraceGetNeighbourRoamState(
10692 pMac->roam.neighborRoamInfo.neighborRoamState),
10693 macTraceGetcsrRoamSubState(
10694 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
10695 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010696 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10697 }
10698#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010699 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010700 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010701
10702 return (status);
10703}
10704
Jeff Johnson295189b2012-06-20 16:38:30 -070010705eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10706{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010707 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
10708 macTraceGetNeighbourRoamState(
10709 pMac->roam.neighborRoamInfo.neighborRoamState),
10710 macTraceGetcsrRoamSubState(
10711 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010712#ifdef FEATURE_WLAN_LFR
10713 if (csrNeighborRoamIsHandoffInProgress(pMac))
10714 {
10715 /*
10716 * Enable heartbeat timer when hand-off is in progress
10717 * and Key Wait timer got stopped for some reason
10718 */
10719 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010720 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010721 pMac->roam.configParam.HeartbeatThresh24);
10722 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10723 pMac->roam.configParam.HeartbeatThresh24,
10724 NULL, eANI_BOOLEAN_FALSE);
10725 }
10726#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010727 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010728}
10729
Jeff Johnson295189b2012-06-20 16:38:30 -070010730void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10731 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10732{
10733 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10734 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010735 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10736 /* To silence the KW tool Null chaeck is added */
10737 if(!pSession)
10738 {
10739 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10740 return;
10741 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010742
10743 if(pCommand)
10744 {
10745 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010746 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010747 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010748 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10749 {
10750 //if success, force roaming completion
10751 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10752 }
10753 else
10754 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010755 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010756 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010757 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10758 }
10759}
10760
Jeff Johnson295189b2012-06-20 16:38:30 -070010761eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10762{
10763 eHalStatus status = eHAL_STATUS_SUCCESS;
10764 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10765 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10766 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10767 tCsrRoamInfo *pRoamInfo = NULL;
10768 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010769 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010770 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010771 /* To silence the KW tool Null chaeck is added */
10772 if(!pSession)
10773 {
10774 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10775 return eHAL_STATUS_FAILURE;
10776 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010777 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010778 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010779 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10780 if ( eWNI_SME_DISASSOC_IND == type )
10781 {
10782 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10783 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10784 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010785 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010786 }
10787 else if ( eWNI_SME_DEAUTH_IND == type )
10788 {
10789 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10790 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10791 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010792 /* Convert into proper reason code */
10793 pSession->joinFailStatusCode.reasonCode =
10794 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010795 0 : pDeauthIndMsg->reasonCode;
10796 /* cfg layer expects 0 as reason code if
10797 the driver dosent know the reason code
10798 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010799 }
10800 else
10801 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010802 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010803 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010804 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010805 }
10806
10807 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010808 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010809 {
10810 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10811 }
10812
10813 if ( eWNI_SME_DISASSOC_IND == type )
10814 {
10815 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10816 }
10817 else if ( eWNI_SME_DEAUTH_IND == type )
10818 {
10819 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10820 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010821 if(!HAL_STATUS_SUCCESS(status))
10822 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010823 //If fail to send confirmation to PE, not to trigger roaming
10824 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010825 }
10826
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010827 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010828 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010829 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10830 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010831 if( eWNI_SME_DISASSOC_IND == type)
10832 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010833 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010834 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10835 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010836 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10837 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010838 else if( eWNI_SME_DEAUTH_IND == type )
10839 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010840 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010841 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10842 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010843 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10844 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010845 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010846
10847 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10848 that we are roaming. But if we cannot possibly roam, or if we are unable to
10849 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010850 if(fToRoam)
10851 {
10852 //Only remove the connected BSS in infrastructure mode
10853 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10854 //Not to do anying for lostlink with WDS
10855 if( pMac->roam.configParam.nRoamingTime )
10856 {
10857 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10858 ( eWNI_SME_DEAUTH_IND == type ) ?
10859 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10860 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010861 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010862 //For IBSS, we need to give some more info to HDD
10863 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10864 {
10865 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10866 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10867 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10868 }
10869 else
10870 {
10871 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10872 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010873 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010874 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10875 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10876 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10877 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10878 }
10879 else
10880 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010881 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010882 fToRoam = eANI_BOOLEAN_FALSE;
10883 }
10884 }
10885 else
10886 {
10887 //We are told not to roam, indicate lostlink
10888 fToRoam = eANI_BOOLEAN_FALSE;
10889 }
10890 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010891 if(!fToRoam)
10892 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010893 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010894 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010895 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010896 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10897 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10898 * csrRoamCheckForLinkStatusChange API.
10899 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010900 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10901 }
10902
10903 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010904 Still enable idle scan for polling in case concurrent sessions are running */
10905 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10906 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010907 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010908 }
10909 }
10910
10911 return (status);
10912}
10913
Jeff Johnson295189b2012-06-20 16:38:30 -070010914eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10915{
10916 eHalStatus status = eHAL_STATUS_SUCCESS;
10917 tListElem *pEntry = NULL;
10918 tSmeCmd *pCommand = NULL;
10919 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010920
10921 if(!pSession)
10922 {
10923 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10924 return eHAL_STATUS_FAILURE;
10925 }
10926
Jeff Johnson295189b2012-06-20 16:38:30 -070010927 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010928 //Only remove the connected BSS in infrastructure mode
10929 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10930 if(pMac->roam.configParam.nRoamingTime)
10931 {
10932 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10933 {
10934 //before starting the lost link logic release the roam command for handoff
10935 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10936 if(pEntry)
10937 {
10938 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10939 }
10940 if(pCommand)
10941 {
10942 if (( eSmeCommandRoam == pCommand->command ) &&
10943 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10944 {
10945 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10946 {
10947 csrReleaseCommandRoam( pMac, pCommand );
10948 }
10949 }
10950 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010951 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010952 }
10953 }
10954 else
10955 {
10956 //We are told not to roam, indicate lostlink
10957 status = eHAL_STATUS_FAILURE;
10958 }
10959
10960 return (status);
10961}
Jeff Johnson295189b2012-06-20 16:38:30 -070010962void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10963{
10964 tListElem *pEntry;
10965 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010966 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10967 if ( pEntry )
10968 {
10969 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10970 if ( eSmeCommandWmStatusChange == pCommand->command )
10971 {
10972 // Nothing to process in a Lost Link completion.... It just kicks off a
10973 // roaming sequence.
10974 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10975 {
10976 csrReleaseCommandWmStatusChange( pMac, pCommand );
10977 }
10978 else
10979 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010980 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010981 }
10982
10983 }
10984 else
10985 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010986 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010987 }
10988 }
10989 else
10990 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010991 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010992 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010993 smeProcessPendingQueue( pMac );
10994}
10995
Jeff Johnson295189b2012-06-20 16:38:30 -070010996void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10997{
10998 eHalStatus status = eHAL_STATUS_FAILURE;
10999 tSirSmeRsp *pSirSmeMsg;
11000 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011001
11002 if(!pSession)
11003 {
11004 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
11005 return;
11006 }
11007
Jeff Johnson295189b2012-06-20 16:38:30 -070011008 switch ( pCommand->u.wmStatusChangeCmd.Type )
11009 {
11010 case eCsrDisassociated:
11011 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
11012 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
11013 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011014 case eCsrDeauthenticated:
11015 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
11016 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
11017 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011018 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011019 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070011020 break;
11021 }
11022 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
11023 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
11024 {
11025 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
11026 {
11027 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011028 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070011029 }
11030 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011031 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
11032 // command here since there is nothing else to do.
11033 csrRoamWmStatusChangeComplete( pMac );
11034}
11035
Jeff Johnson295189b2012-06-20 16:38:30 -070011036//This function returns band and mode information.
11037//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
11038//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070011039static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11040 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070011041{
Jeff Johnson295189b2012-06-20 16:38:30 -070011042 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
11043 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
11044 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070011045 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070011046
Jeff Johnson295189b2012-06-20 16:38:30 -070011047 //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 -070011048 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
11049 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
11050 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
11051 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011052 {
11053 switch( pMac->roam.configParam.uCfgDot11Mode )
11054 {
11055 case eCSR_CFG_DOT11_MODE_11A:
11056 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11057 eBand = eCSR_BAND_5G;
11058 break;
11059 case eCSR_CFG_DOT11_MODE_11B:
11060 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11061 eBand = eCSR_BAND_24;
11062 break;
11063 case eCSR_CFG_DOT11_MODE_11G:
11064 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11065 eBand = eCSR_BAND_24;
11066 break;
11067 case eCSR_CFG_DOT11_MODE_11N:
11068 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011069 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11070 break;
11071#ifdef WLAN_FEATURE_11AC
11072 case eCSR_CFG_DOT11_MODE_11AC:
11073 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11074 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011075 /* If the operating channel is in 2.4 GHz band, check for
11076 * INI item to disable VHT operation in 2.4 GHz band
11077 */
11078 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11079 !pMac->roam.configParam.enableVhtFor24GHz)
11080 {
11081 /* Disable 11AC operation */
11082 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11083 }
11084 else
11085 {
11086 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11087 }
11088 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011089 }
11090 else
11091 {
11092 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11093 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11094 }
11095 break;
11096 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11097 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11098 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011099 /* If the operating channel is in 2.4 GHz band, check for
11100 * INI item to disable VHT operation in 2.4 GHz band
11101 */
11102 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11103 !pMac->roam.configParam.enableVhtFor24GHz)
11104 {
11105 /* Disable 11AC operation */
11106 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11107 }
11108 else
11109 {
11110 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11111 }
11112 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011113 }
11114 else
11115 {
11116 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11117 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11118 }
11119 break;
11120#endif
11121 case eCSR_CFG_DOT11_MODE_AUTO:
Ravi Joshia96ceb42013-05-20 18:52:39 -070011122#ifdef WLAN_FEATURE_11AC
Abhishek Singh03c39422014-09-24 10:52:30 +053011123 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11124 {
11125 /* If the operating channel is in 2.4 GHz band, check for
11126 * INI item to disable VHT operation in 2.4 GHz band
11127 */
11128 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11129 !pMac->roam.configParam.enableVhtFor24GHz)
Ravi Joshia96ceb42013-05-20 18:52:39 -070011130 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011131 /* Disable 11AC operation */
11132 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011133 }
11134 else
11135 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011136 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11137 }
11138 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11139 }
11140 else
11141 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011142 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11143 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011144 }
Abhishek Singh03c39422014-09-24 10:52:30 +053011145#else
11146 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11147 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11148#endif
Ravi Joshia96ceb42013-05-20 18:52:39 -070011149 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011150 default:
11151 // Global dot11 Mode setting is 11a/b/g.
11152 // use the channel number to determine the Mode setting.
11153 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11154 {
11155 eBand = pMac->roam.configParam.eBand;
11156 if(eCSR_BAND_24 == eBand)
11157 {
11158 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11159 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11160 }
11161 else
11162 {
11163 //prefer 5GHz
11164 eBand = eCSR_BAND_5G;
11165 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11166 }
11167 }
11168 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11169 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011170 // WiFi tests require IBSS networks to start in 11b mode
11171 // without any change to the default parameter settings
11172 // on the adapter. We use ACU to start an IBSS through
11173 // creation of a startIBSS profile. This startIBSS profile
11174 // has Auto MACProtocol and the adapter property setting
11175 // for dot11Mode is also AUTO. So in this case, let's
11176 // start the IBSS network in 11b mode instead of 11g mode.
11177 // So this is for Auto=profile->MacProtocol && Auto=Global.
11178 // dot11Mode && profile->channel is < 14, then start the IBSS
11179 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011180 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011181 // Note: we used to have this start as an 11g IBSS for best
11182 // performance... now to specify that the user will have to
11183 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011184 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11185 eBand = eCSR_BAND_24;
11186 }
11187 else
11188 {
11189 // else, it's a 5.0GHz channel. Set mode to 11a.
11190 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11191 eBand = eCSR_BAND_5G;
11192 }
11193 break;
11194 }//switch
11195 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11196 else
11197 {
11198 //dot11 mode is set, lets pick the band
11199 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11200 {
11201 // channel is Auto also.
11202 eBand = pMac->roam.configParam.eBand;
11203 if(eCSR_BAND_ALL == eBand)
11204 {
11205 //prefer 5GHz
11206 eBand = eCSR_BAND_5G;
11207 }
11208 }
11209 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11210 {
11211 eBand = eCSR_BAND_24;
11212 }
11213 else
11214 {
11215 eBand = eCSR_BAND_5G;
11216 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011217 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011218 if(pBand)
11219 {
11220 *pBand = eBand;
11221 }
11222
11223 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011224 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011225 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11226 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011227
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011228 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
11229 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 -070011230 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011231#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011232 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011233#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011234 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11235 {
11236 //We cannot do 11n here
11237 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11238 {
11239 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11240 }
11241 else
11242 {
11243 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11244 }
11245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011246 return( cfgDot11Mode );
11247}
11248
Jeff Johnson295189b2012-06-20 16:38:30 -070011249eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11250{
11251 eHalStatus status;
11252 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011253
11254 if(!pSession)
11255 {
11256 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11257 return eHAL_STATUS_FAILURE;
11258 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011259
11260#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11261 {
11262 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011263 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11264 if(pIbssLog)
11265 {
11266 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11267 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11268 }
11269 }
11270#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011271 // Set the roaming substate to 'stop Bss request'...
11272 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11273
11274 // attempt to stop the Bss (reason code is ignored...)
11275 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011276 if(!HAL_STATUS_SUCCESS(status))
11277 {
11278 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11279 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011280 return (status);
11281}
11282
Jeff Johnson295189b2012-06-20 16:38:30 -070011283//pNumChan is a caller allocated space with the sizeof pChannels
11284eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11285{
11286
11287 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11288 (tANI_U8 *)pChannels,
11289 pNumChan));
11290}
11291
Kiran4a17ebe2013-01-31 10:43:43 -080011292tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11293{
11294 tANI_U32 cfgLength = 0;
11295 tANI_U16 cfgId = 0;
11296 tPowerdBm maxTxPwr = 0;
11297 tANI_U8 *pCountryInfo = NULL;
11298 eHalStatus status;
11299 tANI_U8 count = 0;
11300 tANI_U8 firstChannel;
11301 tANI_U8 maxChannels;
11302
11303 if (CSR_IS_CHANNEL_5GHZ(channel))
11304 {
11305 cfgId = WNI_CFG_MAX_TX_POWER_5;
11306 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11307 }
11308 else if (CSR_IS_CHANNEL_24GHZ(channel))
11309 {
11310 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11311 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11312 }
11313 else
11314 return maxTxPwr;
11315
Kiet Lam64c1b492013-07-12 13:56:44 +053011316 pCountryInfo = vos_mem_malloc(cfgLength);
11317 if ( NULL == pCountryInfo )
11318 status = eHAL_STATUS_FAILURE;
11319 else
11320 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011321 if (status != eHAL_STATUS_SUCCESS)
11322 {
11323 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011324 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011325 __FUNCTION__, status);
11326 goto error;
11327 }
11328 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11329 if (status != eHAL_STATUS_SUCCESS)
11330 {
11331 goto error;
11332 }
11333 /* Identify the channel and maxtxpower */
11334 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11335 {
11336 firstChannel = pCountryInfo[count++];
11337 maxChannels = pCountryInfo[count++];
11338 maxTxPwr = pCountryInfo[count++];
11339
11340 if ((channel >= firstChannel) &&
11341 (channel < (firstChannel + maxChannels)))
11342 {
11343 break;
11344 }
11345 }
11346
11347error:
11348 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011349 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011350
11351 return maxTxPwr;
11352}
11353
11354
Jeff Johnson295189b2012-06-20 16:38:30 -070011355tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11356{
11357 tANI_BOOLEAN fValid = FALSE;
11358 tANI_U32 idxValidChannels;
11359 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11360
11361 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11362 {
11363 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11364 {
11365 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11366 {
11367 fValid = TRUE;
11368 break;
11369 }
11370 }
11371 }
11372 pMac->roam.numValidChannels = len;
11373 return fValid;
11374}
11375
Jeff Johnson295189b2012-06-20 16:38:30 -070011376tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11377{
11378 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11379 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011380 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11381 {
11382 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11383 {
11384 fValid = eANI_BOOLEAN_TRUE;
11385 break;
11386 }
11387 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011388 return (fValid);
11389}
11390
Jeff Johnson295189b2012-06-20 16:38:30 -070011391//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011392 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011393{
Jeff Johnsone7245742012-09-05 17:12:55 -070011394 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011395 tANI_U8 centerChn;
11396 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011397
Jeff Johnson295189b2012-06-20 16:38:30 -070011398 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11399 {
11400 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11401 }
11402 else
11403 {
11404 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11405 }
11406 //Figure what the other side's CB mode
11407 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11408 {
11409 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11410 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011411 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11412 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11413 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11414 "\x00\x0f\xac\x02",4))
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011415 //In Case only WPA1 is supported and TKIP is the only one cipher suite in Unicast.
11416 ||( !pIes->RSN.present && (pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
Agrawal Ashishf187d512014-04-03 17:01:52 +053011417 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011418 "\x00\x50\xf2\x02",4))))
Agrawal Ashishf187d512014-04-03 17:01:52 +053011419
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011420 {
11421 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11422 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11423 }
11424
11425 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011426 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011427 /* This is called during INFRA STA/CLIENT and should use the merged value of
11428 * supported channel width and recommended tx width as per standard
11429 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011430 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011431 pIes->HTCaps.supportedChannelWidthSet,
11432 pIes->HTInfo.recommendedTxWidthSet,
11433 pIes->HTInfo.secondaryChannelOffset);
11434
11435 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11436 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011437 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011438 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11439 switch (eRet) {
11440 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11441 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11442 break;
11443 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11444 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11445 break;
11446 case PHY_SINGLE_CHANNEL_CENTERED:
11447 default:
11448 centerChn = primaryChn;
11449 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011450 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011451 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011452 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011453 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053011454 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011455 }
11456 }
11457 }
11458 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011459 return eRet;
11460}
Jeff Johnson295189b2012-06-20 16:38:30 -070011461tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11462{
11463 tANI_BOOLEAN fFound = FALSE;
11464 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011465 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11466 {
11467 if( pCipherList->encryptionType[idx] == encryptionType )
11468 {
11469 fFound = TRUE;
11470 break;
11471 }
11472 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011473 return fFound;
11474}
Jeff Johnson295189b2012-06-20 16:38:30 -070011475tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11476{
11477 tANI_BOOLEAN fFound = FALSE;
11478 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011479 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11480 {
11481 if( pAuthList->authType[idx] == authType )
11482 {
11483 fFound = TRUE;
11484 break;
11485 }
11486 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011487 return fFound;
11488}
Jeff Johnson295189b2012-06-20 16:38:30 -070011489tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11490{
11491 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11492 tCsrScanResultFilter *pScanFilter = NULL;
11493 eHalStatus status = eHAL_STATUS_SUCCESS;
11494
11495 if(pProfile1 && pProfile2)
11496 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011497 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11498 if ( NULL == pScanFilter )
11499 status = eHAL_STATUS_FAILURE;
11500 else
11501 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011502 if(HAL_STATUS_SUCCESS(status))
11503 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011504 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011505 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11506 if(HAL_STATUS_SUCCESS(status))
11507 {
11508 fCheck = eANI_BOOLEAN_FALSE;
11509 do
11510 {
11511 tANI_U32 i;
11512 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11513 {
11514 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11515 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11516 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11517 if ( fCheck ) break;
11518 }
11519 if(!fCheck)
11520 {
11521 break;
11522 }
11523 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11524 || pProfile2->BSSType != pProfile1->BSSType
11525 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11526 )
11527 {
11528 fCheck = eANI_BOOLEAN_FALSE;
11529 break;
11530 }
11531#ifdef WLAN_FEATURE_VOWIFI_11R
11532 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11533 {
11534 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11535 {
11536 fCheck = eANI_BOOLEAN_FALSE;
11537 break;
11538 }
11539 }
11540#endif
11541 //Match found
11542 fCheck = eANI_BOOLEAN_TRUE;
11543 }while(0);
11544 csrFreeScanFilter(pMac, pScanFilter);
11545 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011546 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011547 }
11548 }
11549
11550 return (fCheck);
11551}
11552
Jeff Johnson295189b2012-06-20 16:38:30 -070011553tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11554{
11555 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11556 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011557 do
11558 {
11559 //Only check for static WEP
11560 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11561 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11562 {
11563 fCheck = eANI_BOOLEAN_TRUE;
11564 break;
11565 }
11566 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11567 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11568 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11569 {
11570 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011571 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11572 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011573 {
11574 break;
11575 }
11576 }
11577 if( i == CSR_MAX_NUM_KEY)
11578 {
11579 fCheck = eANI_BOOLEAN_TRUE;
11580 }
11581 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011582 return (fCheck);
11583}
11584
Jeff Johnson295189b2012-06-20 16:38:30 -070011585//IBSS
11586
Jeff Johnson295189b2012-06-20 16:38:30 -070011587tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11588{
11589 tANI_U8 channel = 0;
11590 tANI_U32 idx;
11591 tANI_U32 idxValidChannels;
11592 tANI_BOOLEAN fFound = FALSE;
11593 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11594
11595 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11596 {
11597 channel = pMac->roam.configParam.AdHocChannel5G;
11598 if(!csrRoamIsChannelValid(pMac, channel))
11599 {
11600 channel = 0;
11601 }
11602 }
11603 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11604 {
11605 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11606 {
11607 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11608 {
11609 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11610 {
11611 fFound = TRUE;
11612 channel = csrStartIbssChannels50[ idx ];
11613 }
11614 }
11615 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011616 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11617 if (!fFound)
11618 {
11619 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11620 {
Girish Gowli386e76c2014-10-20 22:00:29 +053011621 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idxValidChannels ]) ) // the max channel# in 11g is 14
Jeff Johnson295189b2012-06-20 16:38:30 -070011622 {
Girish Gowli386e76c2014-10-20 22:00:29 +053011623 channel = pMac->roam.validChannelList[ idxValidChannels ];
Jeff Johnson295189b2012-06-20 16:38:30 -070011624 break;
11625 }
11626 }
11627 }
11628 }//if
11629
11630 return( channel );
11631}
11632
Jeff Johnson295189b2012-06-20 16:38:30 -070011633tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11634{
11635 tANI_U8 channel = 1;
11636 tANI_U32 idx;
11637 tANI_U32 idxValidChannels;
11638 tANI_BOOLEAN fFound = FALSE;
11639 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11640
11641 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11642 {
11643 channel = pMac->roam.configParam.AdHocChannel24;
11644 if(!csrRoamIsChannelValid(pMac, channel))
11645 {
11646 channel = 0;
11647 }
11648 }
11649
11650 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11651 {
11652 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11653 {
11654 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11655 {
11656 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11657 {
11658 fFound = TRUE;
11659 channel = csrStartIbssChannels24[ idx ];
11660 }
11661 }
11662 }
11663 }
11664
11665 return( channel );
11666}
11667
Jeff Johnson295189b2012-06-20 16:38:30 -070011668static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11669 tCsrRoamStartBssParams *pParam )
11670{
11671 eCsrCfgDot11Mode cfgDot11Mode;
11672 eCsrBand eBand;
11673 tANI_U8 channel = 0;
11674 tSirNwType nwType;
11675 tANI_U8 operationChannel = 0;
11676
11677 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11678 {
11679 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11680 }
11681
Jeff Johnson295189b2012-06-20 16:38:30 -070011682 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011683
Jeff Johnson295189b2012-06-20 16:38:30 -070011684 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11685 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11686 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11687 )
11688 {
11689 /* This should never happen */
11690 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011691 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011692 pProfile->csrPersona);
11693 VOS_ASSERT(0);
11694 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011695 switch( cfgDot11Mode )
11696 {
11697 case eCSR_CFG_DOT11_MODE_11G:
11698 nwType = eSIR_11G_NW_TYPE;
11699 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011700 case eCSR_CFG_DOT11_MODE_11B:
11701 nwType = eSIR_11B_NW_TYPE;
11702 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011703 case eCSR_CFG_DOT11_MODE_11A:
11704 nwType = eSIR_11A_NW_TYPE;
11705 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011706 default:
11707 case eCSR_CFG_DOT11_MODE_11N:
11708 case eCSR_CFG_DOT11_MODE_TAURUS:
11709 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11710 if(eCSR_BAND_24 == eBand)
11711 {
11712 nwType = eSIR_11G_NW_TYPE;
11713 }
11714 else
11715 {
11716 nwType = eSIR_11A_NW_TYPE;
11717 }
11718 break;
11719 }
11720
11721 pParam->extendedRateSet.numRates = 0;
11722
11723 switch ( nwType )
11724 {
11725 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011726 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011727 case eSIR_11A_NW_TYPE:
11728
11729 pParam->operationalRateSet.numRates = 8;
11730
11731 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11732 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11733 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11734 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11735 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11736 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11737 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11738 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11739
11740 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11741 {
11742 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11743 if( 0 == channel &&
11744 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11745 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11746 )
11747 {
11748 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11749 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11750 nwType = eSIR_11B_NW_TYPE;
11751 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11752 pParam->operationalRateSet.numRates = 4;
11753 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11754 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11755 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11756 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11757 }
11758 }
11759 else
11760 {
11761 channel = operationChannel;
11762 }
11763 break;
11764
11765 case eSIR_11B_NW_TYPE:
11766 pParam->operationalRateSet.numRates = 4;
11767 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11768 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11769 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11770 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011771 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11772 {
11773 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11774 }
11775 else
11776 {
11777 channel = operationChannel;
11778 }
11779
11780 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011781 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011782 /* For P2P Client and P2P GO, disable 11b rates */
11783 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11784 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11785 )
11786 {
11787 pParam->operationalRateSet.numRates = 8;
11788
11789 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11790 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11791 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11792 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11793 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11794 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11795 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11796 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11797 }
11798 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011799 {
11800 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011801 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11802 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11803 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11804 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11805
11806 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011807 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11808 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11809 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11810 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11811 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11812 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11813 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11814 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11815 }
11816
11817 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11818 {
11819 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11820 }
11821 else
11822 {
11823 channel = operationChannel;
11824 }
11825
11826 break;
11827 }
11828 pParam->operationChn = channel;
11829 pParam->sirNwType = nwType;
11830}
11831
Jeff Johnson295189b2012-06-20 16:38:30 -070011832static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11833 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11834{
11835
11836 if( pParam )
11837 {
11838 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011839 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011840 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011841 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011842
11843 if( pIes )
11844 {
11845 if(pIes->SuppRates.present)
11846 {
11847 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11848 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11849 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011850 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 -070011851 pIes->SuppRates.num_rates);
11852 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11853 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011854 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11855 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011856 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011857 if (pIes->ExtSuppRates.present)
11858 {
11859 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011860 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011861 {
11862 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11863 SIR_MAC_RATESET_EID_MAX, resetting to \
11864 SIR_MAC_RATESET_EID_MAX"),
11865 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011866 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011867 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011868 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011869 pIes->ExtSuppRates.rates,
11870 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11871 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011872 if( pIes->SSID.present )
11873 {
11874 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011875 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11876 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011877 }
11878 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011879 }
11880 else
11881 {
11882 pParam->ssId.length = 0;
11883 pParam->operationalRateSet.numRates = 0;
11884 }
11885 }
11886}
11887
Jeff Johnson295189b2012-06-20 16:38:30 -070011888static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11889{
11890 tANI_U8 MaxRate = 0;
11891 tANI_U32 i;
11892 tANI_U8 *pRate;
11893
11894 pRate = pSirRateSet->rate;
11895 for ( i = 0; i < pSirRateSet->numRates; i++ )
11896 {
11897 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11898 }
11899
11900 // Save the max rate in the connected state information...
11901
11902 // modify LastRates variable as well
11903
11904 return;
11905}
11906
Jeff Johnson295189b2012-06-20 16:38:30 -070011907eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11908 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11909{
11910 eHalStatus status = eHAL_STATUS_SUCCESS;
11911 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011912 // Set the roaming substate to 'Start BSS attempt'...
11913 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011914#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11915 //Need to figure out whether we need to log WDS???
11916 if( CSR_IS_IBSS( pProfile ) )
11917 {
11918 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011919 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11920 if(pIbssLog)
11921 {
11922 if(pBssDesc)
11923 {
11924 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011925 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011926 }
11927 else
11928 {
11929 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11930 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011931 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011932 if(pProfile->ChannelInfo.numOfChannels == 0)
11933 {
11934 pIbssLog->channelSetting = AUTO_PICK;
11935 }
11936 else
11937 {
11938 pIbssLog->channelSetting = SPECIFIED;
11939 }
11940 pIbssLog->operatingChannel = pParam->operationChn;
11941 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11942 }
11943 }
11944#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11945 //Put RSN information in for Starting BSS
Abhishek Singh00e46532014-11-13 05:34:55 -080011946 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11947 pParam->pRSNIE = pProfile->pRSNReqIE;
Jeff Johnson295189b2012-06-20 16:38:30 -070011948
Jeff Johnson295189b2012-06-20 16:38:30 -070011949 pParam->privacy = pProfile->privacy;
11950 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11951 pParam->authType = pProfile->csr80211AuthType;
11952 pParam->beaconInterval = pProfile->beaconInterval;
11953 pParam->dtimPeriod = pProfile->dtimPeriod;
11954 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11955 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11956 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11957 {
11958 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11959 {
11960 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11961 }
11962 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011963 pParam->protEnabled = pProfile->protEnabled;
11964 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11965 pParam->ht_protection = pProfile->cfg_protection;
11966 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011967
Jeff Johnson295189b2012-06-20 16:38:30 -070011968 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11969 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011970 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080011971
11972#ifdef WLAN_FEATURE_11W
11973 pParam->mfpCapable = (0 != pProfile->MFPCapable);
11974 pParam->mfpRequired = (0 != pProfile->MFPRequired);
11975#endif
11976
Jeff Johnson295189b2012-06-20 16:38:30 -070011977 // When starting an IBSS, start on the channel from the Profile.
11978 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011979 return (status);
11980}
11981
Jeff Johnson295189b2012-06-20 16:38:30 -070011982static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011983 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011984{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011985 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011986 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011987 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011988
11989 if(!pSession)
11990 {
11991 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11992 return;
11993 }
11994
Jeff Johnson295189b2012-06-20 16:38:30 -070011995 if( pBssDesc )
11996 {
11997 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11998 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11999 //The following code has to be do after that.
12000 //For WDS station, use selfMac as the self BSSID
12001 if( CSR_IS_WDS_STA( pProfile ) )
12002 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012003 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12004 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012005 }
12006 }
12007 else
12008 {
12009 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070012010 //Use the first SSID
12011 if(pProfile->SSIDs.numOfSSIDs)
12012 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012013 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
12014 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012015 }
12016 //For WDS station, use selfMac as the self BSSID
12017 if( CSR_IS_WDS_STA( pProfile ) )
12018 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012019 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
12020 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012021 }
12022 //Use the first BSSID
12023 else if( pProfile->BSSIDs.numOfBSSIDs )
12024 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012025 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
12026 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012027 }
12028 else
12029 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012030 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012031 }
12032 }
12033 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070012034 //Set operating channel in pProfile which will be used
12035 //in csrRoamSetBssConfigCfg() to determine channel bonding
12036 //mode and will be configured in CFG later
12037 pProfile->operationChannel = Channel;
12038
12039 if(Channel == 0)
12040 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053012041 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070012042 }
12043 else
12044 {
12045
12046 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012047 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012048 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012049 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012050 {
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012051#ifdef WLAN_FEATURE_AP_HT40_24G
12052 if (CSR_IS_INFRA_AP(pProfile))
12053 cbMode = pMac->roam.configParam.channelBondingAPMode24GHz;
12054 else
12055 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
12056#else
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053012057 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053012058#endif
Jeff Johnsone7245742012-09-05 17:12:55 -070012059 }
12060 else
12061 {
12062 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
12063 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012064 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070012065 pBssConfig->cbMode = cbMode;
12066 pSession->bssParams.cbMode = cbMode;
12067 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012068 }
12069}
12070
Jeff Johnson295189b2012-06-20 16:38:30 -070012071static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
12072 tANI_BOOLEAN *pfSameIbss )
12073{
12074 eHalStatus status = eHAL_STATUS_SUCCESS;
12075 tANI_BOOLEAN fSameIbss = FALSE;
12076
12077 if ( csrIsConnStateIbss( pMac, sessionId ) )
12078 {
12079 // Check if any profile parameter has changed ? If any profile parameter
12080 // has changed then stop old BSS and start a new one with new parameters
12081 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
12082 {
12083 fSameIbss = TRUE;
12084 }
12085 else
12086 {
12087 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12088 }
12089 }
12090 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12091 {
12092 // Disassociate from the connected Infrastructure network...
12093 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12094 }
12095 else
12096 {
12097 tBssConfigParam *pBssConfig;
12098
Kiet Lam64c1b492013-07-12 13:56:44 +053012099 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12100 if ( NULL == pBssConfig )
12101 status = eHAL_STATUS_FAILURE;
12102 else
12103 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012104 if(HAL_STATUS_SUCCESS(status))
12105 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012106 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012107 // there is no Bss description before we start an IBSS so we need to adopt
12108 // all Bss configuration parameters from the Profile.
12109 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12110 if(HAL_STATUS_SUCCESS(status))
12111 {
12112 //save dotMode
12113 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12114 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012115 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012116 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12117 NULL, pBssConfig,
12118 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012119 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012120
12121 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012122 }//Allocate memory
12123 }
12124
12125 if(pfSameIbss)
12126 {
12127 *pfSameIbss = fSameIbss;
12128 }
12129 return( status );
12130}
12131
Jeff Johnson295189b2012-06-20 16:38:30 -070012132static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12133 tSirSmeNewBssInfo *pNewBss )
12134{
12135 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012136
12137 if(!pSession)
12138 {
12139 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12140 return;
12141 }
12142
Jeff Johnson295189b2012-06-20 16:38:30 -070012143 if( pNewBss )
12144 {
12145 // Set the operating channel.
12146 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12147 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012148 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12149 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012150 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012151 return;
12152}
12153
Jeff Johnson295189b2012-06-20 16:38:30 -070012154#ifdef FEATURE_WLAN_WAPI
12155eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12156 tANI_U32 numItems )
12157{
12158 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12159 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012160 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12161 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012162 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012163 return status;
12164 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012165 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012166 pSession = CSR_GET_SESSION( pMac, sessionId );
12167 if(numItems <= CSR_MAX_BKID_ALLOWED)
12168 {
12169 status = eHAL_STATUS_SUCCESS;
12170 //numItems may be 0 to clear the cache
12171 pSession->NumBkidCache = (tANI_U16)numItems;
12172 if(numItems && pBKIDCache)
12173 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012174 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12175 sizeof(tBkidCacheInfo) * numItems);
12176 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012177 }
12178 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012179 return (status);
12180}
Jeff Johnson295189b2012-06-20 16:38:30 -070012181eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12182 tBkidCacheInfo *pBkidCache)
12183{
12184 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12185 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012186 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12187 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012188 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012189 return status;
12190 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012191 pSession = CSR_GET_SESSION( pMac, sessionId );
12192 if(pNum && pBkidCache)
12193 {
12194 if(pSession->NumBkidCache == 0)
12195 {
12196 *pNum = 0;
12197 status = eHAL_STATUS_SUCCESS;
12198 }
12199 else if(*pNum >= pSession->NumBkidCache)
12200 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012201 if(pSession->NumBkidCache > CSR_MAX_BKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012202 {
Girish Gowli2c26e902014-10-20 22:18:17 +053012203 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 -070012204 pSession->NumBkidCache);
Girish Gowli2c26e902014-10-20 22:18:17 +053012205 pSession->NumBkidCache = CSR_MAX_BKID_ALLOWED;
Jeff Johnson295189b2012-06-20 16:38:30 -070012206 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012207 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12208 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012209 *pNum = pSession->NumBkidCache;
12210 status = eHAL_STATUS_SUCCESS;
12211 }
12212 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012213 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012214}
Jeff Johnson295189b2012-06-20 16:38:30 -070012215tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12216{
12217 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012218}
12219#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012220eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012221 tPmkidCacheInfo *pPMKIDCache,
12222 tANI_U32 numItems,
12223 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -070012224{
12225 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12226 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012227
12228 if (!pSession)
Jeff Johnson32d95a32012-09-10 13:15:23 -070012229 {
12230 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12231 return eHAL_STATUS_FAILURE;
12232 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012233
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012234 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012235
12236 if (numItems <= CSR_MAX_PMKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012237 {
12238#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12239 {
12240 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012241 vos_mem_set(&secEvent,
12242 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012243 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12244 secEvent.encryptionModeMulticast =
12245 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12246 secEvent.encryptionModeUnicast =
12247 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012248 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012249 secEvent.authMode =
12250 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12251 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12252 }
12253#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012254 status = eHAL_STATUS_SUCCESS;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012255 if (update_entire_cache) {
12256 pSession->NumPmkidCache = (tANI_U16)numItems;
12257 if (numItems && pPMKIDCache)
12258 {
12259 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12260 sizeof(tPmkidCacheInfo) * numItems);
12261 }
12262 } else {
12263 tANI_U32 i = 0, j = 0;
12264 tANI_U8 BSSIDMatched = 0;
12265 tPmkidCacheInfo *pmksa;
12266
12267 for (i = 0; i < numItems; i++) {
12268 pmksa = &pPMKIDCache[i];
12269 for (j = 0; j < CSR_MAX_PMKID_ALLOWED; j++) {
12270 if (vos_mem_compare(pSession->PmkidCacheInfo[j].BSSID,
12271 pmksa->BSSID, VOS_MAC_ADDR_SIZE)) {
12272 /* If a matching BSSID found, update it */
12273 BSSIDMatched = 1;
12274 vos_mem_copy(pSession->PmkidCacheInfo[j].PMKID,
12275 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12276 break;
12277 }
12278 }
12279
12280 if (!BSSIDMatched) {
12281 vos_mem_copy(
12282 pSession->PmkidCacheInfo[pSession->NumPmkidCache].BSSID,
12283 pmksa->BSSID, VOS_MAC_ADDR_SIZE);
12284 vos_mem_copy(
12285 pSession->PmkidCacheInfo[pSession->NumPmkidCache].PMKID,
12286 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12287 /* Increment the CSR local cache index */
12288 if (pSession->NumPmkidCache < (CSR_MAX_PMKID_ALLOWED - 1))
12289 pSession->NumPmkidCache++;
12290 else
12291 pSession->NumPmkidCache = 0;
12292 }
12293 BSSIDMatched = 0;
12294 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012295 }
12296 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012297 return (status);
12298}
12299
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012300eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012301 tANI_U8 *pBSSId,
12302 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012303{
12304 eHalStatus status = eHAL_STATUS_FAILURE;
12305 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12306 tANI_BOOLEAN fMatchFound = FALSE;
12307 tANI_U32 Index;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012308
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012309 if(!pSession)
12310 {
12311 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12312 return eHAL_STATUS_FAILURE;
12313 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012314
12315 /* Check if there are no entries to delete */
12316 if (0 == pSession->NumPmkidCache) {
12317 smsLog(pMac, LOG1, FL("No entries to delete/Flush"));
12318 return eHAL_STATUS_SUCCESS;
12319 }
12320
12321 if (!flush_cache) {
12322 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
12323 if (vos_mem_compare(pSession->PmkidCacheInfo[Index].BSSID,
12324 pBSSId, VOS_MAC_ADDR_SIZE)) {
12325 fMatchFound = 1;
12326
12327 /* Clear this - the matched entry */
12328 vos_mem_zero(&pSession->PmkidCacheInfo[Index],
12329 sizeof(tPmkidCacheInfo));
12330 status = eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012331 break;
12332 }
12333 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012334
12335 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
12336 smsLog(pMac, LOG1, FL("No such PMKSA entry exists "MAC_ADDRESS_STR),
12337 MAC_ADDR_ARRAY(pBSSId));
12338 return status;
12339 }
12340
12341 return status;
12342 } else {
12343 /* Flush the entire cache */
12344 vos_mem_zero(pSession->PmkidCacheInfo,
12345 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
12346 pSession->NumPmkidCache = 0;
12347 return eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012348 }
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012349}
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012350
Jeff Johnson295189b2012-06-20 16:38:30 -070012351tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12352{
12353 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12354}
12355
Jeff Johnson295189b2012-06-20 16:38:30 -070012356eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12357{
12358 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12359 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012360
12361 if(!pSession)
12362 {
12363 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12364 return eHAL_STATUS_FAILURE;
12365 }
12366
Jeff Johnson295189b2012-06-20 16:38:30 -070012367 if(pNum && pPmkidCache)
12368 {
12369 if(pSession->NumPmkidCache == 0)
12370 {
12371 *pNum = 0;
12372 status = eHAL_STATUS_SUCCESS;
12373 }
12374 else if(*pNum >= pSession->NumPmkidCache)
12375 {
12376 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12377 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012378 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 -070012379 pSession->NumPmkidCache);
12380 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12381 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012382 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
12383 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012384 *pNum = pSession->NumPmkidCache;
12385 status = eHAL_STATUS_SUCCESS;
12386 }
12387 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012388 return (status);
12389}
12390
Jeff Johnson295189b2012-06-20 16:38:30 -070012391eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12392{
12393 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12394 tANI_U32 len;
12395 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012396
12397 if(!pSession)
12398 {
12399 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12400 return eHAL_STATUS_FAILURE;
12401 }
12402
Jeff Johnson295189b2012-06-20 16:38:30 -070012403 if(pLen)
12404 {
12405 len = *pLen;
12406 *pLen = pSession->nWpaRsnReqIeLength;
12407 if(pBuf)
12408 {
12409 if(len >= pSession->nWpaRsnReqIeLength)
12410 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012411 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12412 pSession->nWpaRsnReqIeLength);
12413 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012414 }
12415 }
12416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012417 return (status);
12418}
12419
Jeff Johnson295189b2012-06-20 16:38:30 -070012420eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12421{
12422 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12423 tANI_U32 len;
12424 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012425
12426 if(!pSession)
12427 {
12428 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12429 return eHAL_STATUS_FAILURE;
12430 }
12431
Jeff Johnson295189b2012-06-20 16:38:30 -070012432 if(pLen)
12433 {
12434 len = *pLen;
12435 *pLen = pSession->nWpaRsnRspIeLength;
12436 if(pBuf)
12437 {
12438 if(len >= pSession->nWpaRsnRspIeLength)
12439 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012440 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12441 pSession->nWpaRsnRspIeLength);
12442 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012443 }
12444 }
12445 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012446 return (status);
12447}
Jeff Johnson295189b2012-06-20 16:38:30 -070012448#ifdef FEATURE_WLAN_WAPI
12449eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12450{
12451 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12452 tANI_U32 len;
12453 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012454
12455 if(!pSession)
12456 {
12457 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12458 return eHAL_STATUS_FAILURE;
12459 }
12460
Jeff Johnson295189b2012-06-20 16:38:30 -070012461 if(pLen)
12462 {
12463 len = *pLen;
12464 *pLen = pSession->nWapiReqIeLength;
12465 if(pBuf)
12466 {
12467 if(len >= pSession->nWapiReqIeLength)
12468 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012469 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12470 pSession->nWapiReqIeLength);
12471 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012472 }
12473 }
12474 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012475 return (status);
12476}
Jeff Johnson295189b2012-06-20 16:38:30 -070012477eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12478{
12479 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12480 tANI_U32 len;
12481 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012482
12483 if(!pSession)
12484 {
12485 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12486 return eHAL_STATUS_FAILURE;
12487 }
12488
Jeff Johnson295189b2012-06-20 16:38:30 -070012489 if(pLen)
12490 {
12491 len = *pLen;
12492 *pLen = pSession->nWapiRspIeLength;
12493 if(pBuf)
12494 {
12495 if(len >= pSession->nWapiRspIeLength)
12496 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012497 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12498 pSession->nWapiRspIeLength);
12499 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012500 }
12501 }
12502 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012503 return (status);
12504}
12505#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012506eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12507{
12508 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12509 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012510
12511 if(!pSession)
12512 {
12513 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12514 return (retStatus);
12515 }
12516
Jeff Johnson295189b2012-06-20 16:38:30 -070012517 if(CSR_IS_ROAMING(pSession))
12518 {
12519 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12520 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12521 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012522 return (retStatus);
12523}
12524
Jeff Johnson295189b2012-06-20 16:38:30 -070012525//This function remove the connected BSS from te cached scan result
12526eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12527 tCsrRoamConnectedProfile *pConnProfile)
12528{
12529 eHalStatus status = eHAL_STATUS_FAILURE;
12530 tCsrScanResultFilter *pScanFilter = NULL;
12531 tListElem *pEntry;
12532 tCsrScanResult *pResult;
12533 tDot11fBeaconIEs *pIes;
12534 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012535 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12536 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12537 {
12538 do
12539 {
12540 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012541 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12542 if ( NULL == pScanFilter )
12543 status = eHAL_STATUS_FAILURE;
12544 else
12545 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012546 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012547 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12548 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12549 if ( NULL == pScanFilter->BSSIDs.bssid )
12550 status = eHAL_STATUS_FAILURE;
12551 else
12552 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012553 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012554 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12555 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012556 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12557 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12558 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012559 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12560 if ( NULL == pScanFilter->SSIDs.SSIDList )
12561 status = eHAL_STATUS_FAILURE;
12562 else
12563 status = eHAL_STATUS_SUCCESS;
12564 if (!HAL_STATUS_SUCCESS(status)) break;
12565 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12566 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012567 }
12568 pScanFilter->authType.numEntries = 1;
12569 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12570 pScanFilter->BSSType = pConnProfile->BSSType;
12571 pScanFilter->EncryptionType.numEntries = 1;
12572 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12573 pScanFilter->mcEncryptionType.numEntries = 1;
12574 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12575 //We ignore the channel for now, BSSID should be enough
12576 pScanFilter->ChannelInfo.numOfChannels = 0;
12577 //Also ignore the following fields
12578 pScanFilter->uapsd_mask = 0;
12579 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012580 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012581 pScanFilter->countryCode[0] = 0;
12582 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012583 csrLLLock(&pMac->scan.scanResultList);
12584 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12585 while( pEntry )
12586 {
12587 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12588 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12589 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12590 pScanFilter, NULL, NULL, NULL, &pIes);
12591 //Release the IEs allocated by csrMatchBSS is needed
12592 if( !pResult->Result.pvIes )
12593 {
12594 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012595 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012596 }
12597 if(fMatch)
12598 {
12599 //We found the one
12600 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12601 {
12602 //Free the memory
12603 csrFreeScanResultEntry( pMac, pResult );
12604 }
12605 break;
12606 }
12607 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12608 }//while
12609 csrLLUnlock(&pMac->scan.scanResultList);
12610 }while(0);
12611 if(pScanFilter)
12612 {
12613 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012614 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012615 }
12616 }
12617 return (status);
12618}
12619
Jeff Johnson295189b2012-06-20 16:38:30 -070012620//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012621eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12622{
12623 eHalStatus status = eHAL_STATUS_SUCCESS;
12624 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012625 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12626 {
12627 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12628 {
12629 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12630 {
12631 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012632 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012633 status = eHAL_STATUS_CSR_WRONG_STATE;
12634 break;
12635 }
12636 if( csrIsConnStateInfra( pMac, sessionId ) )
12637 {
12638 if( chnId &&
12639 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12640 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012641 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012642 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12643 status = eHAL_STATUS_CSR_WRONG_STATE;
12644 break;
12645 }
12646 }
12647 }
12648 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012649 return ( status );
12650}
12651
Jeff Johnson295189b2012-06-20 16:38:30 -070012652static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12653{
12654 eHalStatus status = eHAL_STATUS_SUCCESS;
12655 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12656 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012657
12658 if(!pSession)
12659 {
12660 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12661 return eHAL_STATUS_FAILURE;
12662 }
12663
Jeff Johnson295189b2012-06-20 16:38:30 -070012664 if ( csrIsConnStateIbss( pMac, sessionId ) )
12665 {
12666 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12667 }
12668 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12669 {
12670 // Disassociate from the connected Infrastructure network...
12671 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12672 }
12673 else
12674 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012675 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12676 //Otherwise we need to add code to handle the
12677 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12678 //send stop_bss to PE, before we can continue.
12679 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012680 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012681 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012682 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12683 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012684 // there is no Bss description before we start an WDS so we need
12685 // to adopt all Bss configuration parameters from the Profile.
12686 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12687 if(HAL_STATUS_SUCCESS(status))
12688 {
12689 //Save profile for late use
12690 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012691 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12692 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012693 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012694 vos_mem_set(pSession->pCurRoamProfile,
12695 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012696 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12697 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012698 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012699 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012700 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12701 NULL, &bssConfig,
12702 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012703 }
12704 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012705
Jeff Johnson295189b2012-06-20 16:38:30 -070012706 return( status );
12707}
12708
Jeff Johnson295189b2012-06-20 16:38:30 -070012709////////////////////Mail box
12710
Jeff Johnson295189b2012-06-20 16:38:30 -070012711//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12712//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012713static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12714 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012715 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12716{
12717 tCsrChannelSet channelGroup;
12718 tSirMacCapabilityInfo *pAP_capabilityInfo;
12719 tAniBool fTmp;
12720 tANI_BOOLEAN found = FALSE;
12721 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012722 tANI_S8 pwrLimit = 0;
12723 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012724 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12725 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12726 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12727 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012728 // 802.11h
12729 //We can do this because it is in HOST CPU order for now.
12730 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012731 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12732 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12733 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012734 fTmp = (tAniBool)pal_cpu_to_be32(1);
12735 }
12736 else
12737 fTmp = (tAniBool)0;
12738
12739 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012740 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012741 pBuf += sizeof(tAniBool);
12742 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012743 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012744 // This is required for 11k test VoWiFi Ent: Test 2.
12745 // We need the power capabilities for Assoc Req.
12746 // This macro is provided by the halPhyCfg.h. We pick our
12747 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012748 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12749 if (0 != pwrLimit)
12750 {
12751 *pBuf++ = pwrLimit;
12752 }
12753 else
12754 {
12755 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12756 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012757 size = sizeof(pMac->roam.validChannelList);
12758 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12759 {
12760 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12761 for ( i = 0; i < size; i++)
12762 {
12763 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12764
12765 }
12766 }
12767 else
12768 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012769 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012770 *pBuf++ = 0; //tSirSupChnl->numChnl
12771 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012772 //Check whether it is ok to enter UAPSD
12773#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12774 if( btcIsReadyForUapsd(pMac) )
12775#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12776 {
12777 *pBuf++ = uapsdMask;
12778 }
12779#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12780 else
12781 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012782 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012783 *pBuf++ = 0;
12784 }
12785#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12786
Jeff Johnson295189b2012-06-20 16:38:30 -070012787 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012788 vos_mem_copy(pBuf, pBssDescription,
12789 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012790 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12791}
12792
Jeff Johnson295189b2012-06-20 16:38:30 -070012793/*
12794 * The communication between HDD and LIM is thru mailbox (MB).
12795 * Both sides will access the data structure "tSirSmeJoinReq".
12796 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12797 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12798 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12799 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12800 */
12801eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012802 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012803{
12804 eHalStatus status = eHAL_STATUS_SUCCESS;
12805 tSirSmeJoinReq *pMsg;
12806 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012807 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012808 tANI_U16 msgLen, wTmp, ieLen;
12809 tSirMacRateSet OpRateSet;
12810 tSirMacRateSet ExRateSet;
12811 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12812 tANI_U32 dwTmp;
12813 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012814 tANI_U32 ucDot11Mode = 0;
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053012815 tANI_U8 txBFCsnValue = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012816
12817 if(!pSession)
12818 {
12819 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12820 return eHAL_STATUS_FAILURE;
12821 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012822 /* To satisfy klockworks */
12823 if (NULL == pBssDescription)
12824 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012825 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012826 return eHAL_STATUS_FAILURE;
12827 }
12828
Jeff Johnson295189b2012-06-20 16:38:30 -070012829 do {
12830 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12831 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053012832 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012833 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12834 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12835 // IE fields, but the length field in the bssDescription needs to be interpreted to
12836 // determine length of the IE fields.
12837 //
12838 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12839 // add in the length from the bssDescription (then add the size of the 'length' field
12840 // itself because that is NOT included in the length field).
12841 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12842 pBssDescription->length + sizeof( pBssDescription->length ) +
12843 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 +053012844 pMsg = vos_mem_malloc(msgLen);
12845 if (NULL == pMsg)
12846 status = eHAL_STATUS_FAILURE;
12847 else
12848 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012849 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012850 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012851 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012852 pMsg->length = pal_cpu_to_be16(msgLen);
12853 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012854 // sessionId
12855 *pBuf = (tANI_U8)sessionId;
12856 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012857 // transactionId
12858 *pBuf = 0;
12859 *( pBuf + 1 ) = 0;
12860 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012861 // ssId
12862 if( pIes->SSID.present && pIes->SSID.num_ssid )
12863 {
12864 // ssId len
12865 *pBuf = pIes->SSID.num_ssid;
12866 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012867 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012868 pBuf += pIes->SSID.num_ssid;
12869 }
12870 else
12871 {
12872 *pBuf = 0;
12873 pBuf++;
12874 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012875 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012876 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12877 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012878 pBuf += sizeof(tSirMacAddr);
12879 // bsstype
12880 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12881 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012882 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012883 pBuf += sizeof(tSirBssType);
12884 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012885 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12886 if (pBssDescription->channelId <= 14 &&
12887 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12888 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12889 {
12890 //Need to disable VHT operation in 2.4 GHz band
12891 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12892 }
12893 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012894 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012895 //Persona
12896 *pBuf = (tANI_U8)pProfile->csrPersona;
12897 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012898 //CBMode
12899 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12900 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012901
12902 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012903 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12904
Jeff Johnson295189b2012-06-20 16:38:30 -070012905 // uapsdPerAcBitmask
12906 *pBuf = pProfile->uapsd_mask;
12907 pBuf++;
12908
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012909
12910
Jeff Johnson295189b2012-06-20 16:38:30 -070012911 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012912 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012913 {
12914 // OperationalRateSet
12915 if (OpRateSet.numRates) {
12916 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012917 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012918 pBuf += OpRateSet.numRates;
12919 } else *pBuf++ = 0;
12920 // ExtendedRateSet
12921 if (ExRateSet.numRates) {
12922 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012923 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012924 pBuf += ExRateSet.numRates;
12925 } else *pBuf++ = 0;
12926 }
12927 else
12928 {
12929 *pBuf++ = 0;
12930 *pBuf++ = 0;
12931 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012932 // rsnIE
12933 if ( csrIsProfileWpa( pProfile ) )
12934 {
12935 // Insert the Wpa IE into the join request
12936 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12937 (tCsrWpaIe *)( wpaRsnIE ) );
12938 }
12939 else if( csrIsProfileRSN( pProfile ) )
12940 {
12941 // Insert the RSN IE into the join request
12942 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12943 (tCsrRSNIe *)( wpaRsnIE ) );
12944 }
12945#ifdef FEATURE_WLAN_WAPI
12946 else if( csrIsProfileWapi( pProfile ) )
12947 {
12948 // Insert the WAPI IE into the join request
12949 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12950 (tCsrWapiIe *)( wpaRsnIE ) );
12951 }
12952#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012953 else
12954 {
12955 ieLen = 0;
12956 }
12957 //remember the IE for future use
12958 if( ieLen )
12959 {
12960 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12961 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012962 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 -070012963 ieLen = DOT11F_IE_RSN_MAX_LEN;
12964 }
12965#ifdef FEATURE_WLAN_WAPI
12966 if( csrIsProfileWapi( pProfile ) )
12967 {
12968 //Check whether we need to allocate more memory
12969 if(ieLen > pSession->nWapiReqIeLength)
12970 {
12971 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12972 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012973 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012974 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012975 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12976 if (NULL == pSession->pWapiReqIE)
12977 status = eHAL_STATUS_FAILURE;
12978 else
12979 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012980 if(!HAL_STATUS_SUCCESS(status)) break;
12981 }
12982 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012983 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012984 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012985 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012986 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012987 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012988 pBuf += ieLen;
12989 }
12990 else//should be WPA/WPA2 otherwise
12991#endif /* FEATURE_WLAN_WAPI */
12992 {
12993 //Check whether we need to allocate more memory
12994 if(ieLen > pSession->nWpaRsnReqIeLength)
12995 {
12996 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12997 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012998 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012999 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013000 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
13001 if (NULL == pSession->pWpaRsnReqIE)
13002 status = eHAL_STATUS_FAILURE;
13003 else
13004 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013005 if(!HAL_STATUS_SUCCESS(status)) break;
13006 }
13007 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013008 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013009 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013010 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013011 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013012 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013013 pBuf += ieLen;
13014 }
13015 }
13016 else
13017 {
13018 //free whatever old info
13019 pSession->nWpaRsnReqIeLength = 0;
13020 if(pSession->pWpaRsnReqIE)
13021 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013022 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013023 pSession->pWpaRsnReqIE = NULL;
13024 }
13025#ifdef FEATURE_WLAN_WAPI
13026 pSession->nWapiReqIeLength = 0;
13027 if(pSession->pWapiReqIE)
13028 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013029 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070013030 pSession->pWapiReqIE = NULL;
13031 }
13032#endif /* FEATURE_WLAN_WAPI */
13033 //length is two bytes
13034 *pBuf = 0;
13035 *(pBuf + 1) = 0;
13036 pBuf += 2;
13037 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013038#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013039 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013040 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013041 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070013042 //length is two bytes
13043 *pBuf = 0;
13044 *(pBuf + 1) = 0;
13045 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013046 }
13047 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013048 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013049 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013050 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013051 {
13052 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013053#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013054 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080013055 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013056 pSession->suppCckmIeInfo.cckmIe, ieLen);
13057#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013058 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013059 pSession,
13060 pProfile,
13061 pBssDescription,
13062 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070013063 pSession->nWpaRsnReqIeLength,
13064 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013065#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013066 }
13067 else
13068 {
13069 ieLen = 0;
13070 }
13071 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
13072 if( ieLen )
13073 {
13074 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
13075 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013076 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013077 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013078 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013079 pBuf += ieLen;
13080 }
13081 else
13082 {
13083 //Indicate you have no CCKM IE
13084 //length is two bytes
13085 *pBuf = 0;
13086 *(pBuf + 1) = 0;
13087 pBuf += 2;
13088 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013089 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013090#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070013091 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053013092 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070013093 {
13094 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013095 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013096 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013097 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013098 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013099 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013100 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053013101 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013102 pBuf += ieLen;
13103 }
13104 else
13105 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053013106 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013107 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013108 *pBuf = 0;
13109 *(pBuf + 1) = 0;
13110 pBuf += 2;
13111 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013112 // addIEAssoc
13113 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
13114 {
13115 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070013116 if(ieLen > pSession->nAddIEAssocLength)
13117 {
13118 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053013119 {
13120 vos_mem_free(pSession->pAddIEAssoc);
13121 }
13122 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
13123 if (NULL == pSession->pAddIEAssoc)
13124 status = eHAL_STATUS_FAILURE;
13125 else
13126 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013127 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013128 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013129 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013130 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013131 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013132 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013133 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013134 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013135 pBuf += ieLen;
13136 }
13137 else
13138 {
13139 pSession->nAddIEAssocLength = 0;
13140 if(pSession->pAddIEAssoc)
13141 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013142 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013143 pSession->pAddIEAssoc = NULL;
13144 }
13145 *pBuf = 0;
13146 *(pBuf + 1) = 0;
13147 pBuf += 2;
13148 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013149
13150 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013151 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013152 //Unmask any AC in reassoc that is ACM-set
13153 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13154 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013155 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013156 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13157 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013158#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013159 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013160#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013161 }
13162 else
13163 {
13164 uapsd_mask = 0;
13165 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013166 }
13167 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013168
Jeff Johnson295189b2012-06-20 16:38:30 -070013169 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013170 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013171 pBuf += sizeof(tANI_U32);
13172
Jeff Johnson295189b2012-06-20 16:38:30 -070013173 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013174 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013175 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013176#ifdef WLAN_FEATURE_11W
13177 //MgmtEncryption
13178 if (pProfile->MFPEnabled)
13179 {
13180 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13181 }
13182 else
13183 {
13184 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13185 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013186 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013187 pBuf += sizeof(tANI_U32);
13188#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013189#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013190 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013191 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013192#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013193 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013194 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013195#endif
13196 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013197 {
13198 // is11Rconnection;
13199 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013200 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013201 pBuf += sizeof(tAniBool);
13202 }
13203 else
13204 {
13205 // is11Rconnection;
13206 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013207 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013208 pBuf += sizeof(tAniBool);
13209 }
13210#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013211#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013212
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013213 // isESEFeatureIniEnabled
13214 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013215 {
13216 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013217 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013218 pBuf += sizeof(tAniBool);
13219 }
13220 else
13221 {
13222 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013223 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013224 pBuf += sizeof(tAniBool);
13225 }
13226
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013227 /* A profile can not be both ESE and 11R. But an 802.11R AP
13228 * may be advertising support for ESE as well. So if we are
13229 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013230 * If we are associating explictly 11R only then we will get
13231 * 11R.
13232 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013233 if ((csrIsProfileESE(pProfile) ||
13234 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013235 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13236 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13237 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13238 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13239#ifdef WLAN_FEATURE_11W
13240 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013241 || (pProfile->negotiatedAuthType ==
13242 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013243#endif
13244 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013245 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013246 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013247 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013248 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013249 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013250 pBuf += sizeof(tAniBool);
13251 }
13252 else
13253 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013254 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013255 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013256 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013257 pBuf += sizeof(tAniBool);
13258 }
13259
13260 if (eWNI_SME_JOIN_REQ == messageType)
13261 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013262 tESETspecInfo eseTspec;
13263 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013264 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013265 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13266 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13267 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013268 }
13269 else if (eWNI_SME_REASSOC_REQ == messageType)
13270 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013271 if ((csrIsProfileESE(pProfile) ||
13272 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013273 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13274 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13275 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13276 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13277#ifdef WLAN_FEATURE_11W
13278 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
Abhishek Singh83080e02014-11-07 12:04:16 +053013279 || (pProfile->negotiatedAuthType ==
13280 eCSR_AUTH_TYPE_RSN_8021X_SHA256)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013281#endif
13282 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013283 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013284 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013285 tESETspecInfo eseTspec;
13286 // ESE Tspec information
13287 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13288 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13289 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013290 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013291 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013292 if (eseTspec.numTspecs) {
13293 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13294 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013295 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013296 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013297 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013298 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013299 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013300 tESETspecInfo eseTspec;
13301 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013302 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013303 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13304 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13305 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013306 }
13307 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013308#endif // FEATURE_WLAN_ESE
13309#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013310 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013311 if (pMac->roam.configParam.isFastTransitionEnabled
13312#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013313 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013314#endif
13315 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013316 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013317 dwTmp = pal_cpu_to_be32(TRUE);
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 else
13322 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013323 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013324 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013325 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013326 }
13327#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013328#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013329 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013330 {
13331 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013332 dwTmp = pal_cpu_to_be32(TRUE);
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 else
13337 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013338 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013339 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013340 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013341 }
13342#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013343
13344 // txLdpcIniFeatureEnabled
13345 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13346 pBuf++;
13347
Kiran4a17ebe2013-01-31 10:43:43 -080013348 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13349 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13350 {
13351 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13352 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13353 csrApplyPower2Current(pMac);
13354 }
13355
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013356#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013357 // txBFIniFeatureEnabled
13358 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13359 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013360
13361 // txBFCsnValue
Abhishek Singhcb4d15c2014-11-04 16:09:49 +053013362 txBFCsnValue = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13363 if (pIes->VHTCaps.present)
13364 {
13365 txBFCsnValue = CSR_ROAM_MIN(txBFCsnValue, pIes->VHTCaps.numSoundingDim);
13366 }
13367 *pBuf = txBFCsnValue;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013368 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053013369
13370 /* Only enable MuBf if no other MuBF session exist
13371 * and FW and HOST is MuBF capable.
13372 */
13373 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
13374 {
13375 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
13376 pBuf++;
13377 }
13378 else
13379 {
13380 *pBuf = 0;
13381 pBuf++;
13382 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013383#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013384 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13385 pBuf++;
13386
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013387 // WME
13388 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13389 {
13390 //WME enabled
13391 dwTmp = pal_cpu_to_be32(TRUE);
13392 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13393 pBuf += sizeof(tAniBool);
13394 }
13395 else
13396 {
13397 dwTmp = pal_cpu_to_be32(FALSE);
13398 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13399 pBuf += sizeof(tAniBool);
13400 }
13401
13402 // QOS
13403 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13404 {
13405 //QOS enabled
13406 dwTmp = pal_cpu_to_be32(TRUE);
13407 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13408 pBuf += sizeof(tAniBool);
13409 }
13410 else
13411 {
13412 dwTmp = pal_cpu_to_be32(FALSE);
13413 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13414 pBuf += sizeof(tAniBool);
13415 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013416 //BssDesc
13417 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13418 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013419
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013420 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053013421 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
13422 pMsg = NULL;
13423
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013424 if(!HAL_STATUS_SUCCESS(status))
13425 {
13426 break;
13427 }
13428 else
13429 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013430#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013431 if (eWNI_SME_JOIN_REQ == messageType)
13432 {
13433 //Tush-QoS: notify QoS module that join happening
13434 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13435 }
13436 else if (eWNI_SME_REASSOC_REQ == messageType)
13437 {
13438 //Tush-QoS: notify QoS module that reassoc happening
13439 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13440 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013441#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013442 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013443 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053013444
13445 if (pMsg != NULL)
13446 {
13447 vos_mem_free( pMsg );
13448 }
13449
Jeff Johnson295189b2012-06-20 16:38:30 -070013450 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013451}
13452
Jeff Johnson295189b2012-06-20 16:38:30 -070013453//
13454eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13455{
13456 eHalStatus status = eHAL_STATUS_SUCCESS;
13457 tSirSmeDisassocReq *pMsg;
13458 tANI_U8 *pBuf;
13459 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013460 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13461 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13462 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013463 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013464 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13465 if (NULL == pMsg)
13466 status = eHAL_STATUS_FAILURE;
13467 else
13468 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013469 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013470 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013471 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13472 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013473 pBuf = &pMsg->sessionId;
13474 // sessionId
13475 *pBuf++ = (tANI_U8)sessionId;
13476 // transactionId
13477 *pBuf = 0;
13478 *( pBuf + 1 ) = 0;
13479 pBuf += sizeof(tANI_U16);
13480
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013481 if ( (pSession->pCurRoamProfile != NULL) &&
13482 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13483 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013484 {
13485 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013486 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13487 sizeof( tSirMacAddr ));
13488 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013489 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013490 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013491 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13492 //perMacAddr is passed as bssId for softAP
13493 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013494 pBuf = pBuf + sizeof ( tSirMacAddr );
13495 }
13496 else
13497 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013498 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013499 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13500 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013501 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013502 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13503 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013504 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013505 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013506 if(!HAL_STATUS_SUCCESS(status))
13507 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013508 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013509 break;
13510 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013511 // reasonCode
13512 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013513 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13514 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013515 if(!HAL_STATUS_SUCCESS(status))
13516 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013517 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013518 break;
13519 }
13520 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013521 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13522 Here we should not send the disassoc over the air to the AP */
13523 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13524#ifdef WLAN_FEATURE_VOWIFI_11R
13525 && csrRoamIs11rAssoc(pMac)
13526#endif
13527 )
13528 {
13529 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13530 }
13531 pBuf += sizeof(tANI_U8);
13532 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013533 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013534 return( status );
13535}
Jeff Johnson295189b2012-06-20 16:38:30 -070013536eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13537{
13538 eHalStatus status = eHAL_STATUS_SUCCESS;
13539 tSirSmeTkipCntrMeasReq *pMsg;
13540 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013541 do
13542 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013543 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13544 if ( NULL == pMsg )
13545 status = eHAL_STATUS_FAILURE;
13546 else
13547 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013548 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013549 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013550 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13551 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013552 pBuf = &pMsg->sessionId;
13553 // sessionId
13554 *pBuf++ = (tANI_U8)sessionId;
13555 // transactionId
13556 *pBuf = 0;
13557 *( pBuf + 1 ) = 0;
13558 pBuf += sizeof(tANI_U16);
13559 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013560 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13561 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013562 pBuf = pBuf + sizeof ( tSirMacAddr );
13563 // bEnable
13564 *pBuf = (tANI_BOOLEAN)bEnable;
13565 if(!HAL_STATUS_SUCCESS(status))
13566 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013567 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013568 break;
13569 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013570 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013571 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013572 return( status );
13573}
Jeff Johnson295189b2012-06-20 16:38:30 -070013574eHalStatus
13575csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13576 VOS_MODULE_ID modId, tSirMacAddr bssId,
13577 void *pUsrContext, void *pfnSapEventCallback,
13578 tANI_U8 *pAssocStasBuf )
13579{
13580 eHalStatus status = eHAL_STATUS_SUCCESS;
13581 tSirSmeGetAssocSTAsReq *pMsg;
13582 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13583 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013584 do
13585 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013586 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13587 if ( NULL == pMsg )
13588 status = eHAL_STATUS_FAILURE;
13589 else
13590 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013591 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013592 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013593 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013594 pBuf = (tANI_U8 *)&pMsg->bssId;
13595 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013596 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013597 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013598 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013599 // modId
13600 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013601 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013602 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013603 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013604 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
13605 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013606 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013607 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
13608 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013609 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080013610 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
13611 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013612 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013613 status = palSendMBMessage( pMac->hHdd, pMsg );
13614 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013615 return( status );
13616 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013617eHalStatus
13618csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13619 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13620 {
13621 eHalStatus status = eHAL_STATUS_SUCCESS;
13622 tSirSmeGetWPSPBCSessionsReq *pMsg;
13623 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080013624
Jeff Johnson295189b2012-06-20 16:38:30 -070013625 do
13626 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013627 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13628 if ( NULL == pMsg )
13629 status = eHAL_STATUS_FAILURE;
13630 else
13631 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013632 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013633 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013634 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013635 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013636 VOS_ASSERT(pBuf);
13637
Jeff Johnson295189b2012-06-20 16:38:30 -070013638 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013639 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013640 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
13641 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013642 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013643 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
13644 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013645 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013646 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013647 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013648 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013649 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013650 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013651 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013652 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013653 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013654 return( status );
13655}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013656
13657eHalStatus
13658csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13659{
13660 tpSirChangeBIParams pMsg;
13661 tANI_U16 len = 0;
13662 eHalStatus status = eHAL_STATUS_SUCCESS;
13663 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13664
13665 if(!pSession)
13666 {
13667 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13668 return eHAL_STATUS_FAILURE;
13669 }
13670
13671 //NO need to update the Beacon Params if update beacon parameter flag is not set
13672 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13673 return eHAL_STATUS_SUCCESS;
13674
13675 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13676
13677 /* Create the message and send to lim */
13678 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013679 pMsg = vos_mem_malloc(len);
13680 if ( NULL == pMsg )
13681 status = eHAL_STATUS_FAILURE;
13682 else
13683 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013684 if(HAL_STATUS_SUCCESS(status))
13685 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013686 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013687 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13688 pMsg->length = len;
13689
13690 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013691 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13692 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013693 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13694 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013695 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013696 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013697 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13698 status = palSendMBMessage(pMac->hHdd, pMsg);
13699 }
13700 return status;
13701}
13702
Hardik Kantilal Patel62a3a762014-11-21 12:55:57 +053013703#ifdef WLAN_FEATURE_AP_HT40_24G
13704eHalStatus csrSetHT2040Mode(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U8 cbMode)
13705{
13706 tpSirSetHT2040Mode pMsg;
13707 tANI_U16 len = 0;
13708 eHalStatus status = eHAL_STATUS_SUCCESS;
13709 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13710
13711 if(!pSession)
13712 {
13713 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13714 return eHAL_STATUS_FAILURE;
13715 }
13716
13717 /* Create the message and send to lim */
13718 len = sizeof(tSirSetHT2040Mode);
13719 pMsg = vos_mem_malloc(len);
13720
13721 if ( NULL == pMsg )
13722 {
13723 smsLog( pMac, LOGE, FL("Memory Allocation Fail !!!"));
13724 status = eHAL_STATUS_FAILURE;
13725 }
13726 else
13727 status = eHAL_STATUS_SUCCESS;
13728
13729 if(HAL_STATUS_SUCCESS(status))
13730 {
13731 vos_mem_set(pMsg, sizeof(tSirSetHT2040Mode), 0);
13732 pMsg->messageType = eWNI_SME_SET_HT_2040_MODE;
13733 pMsg->length = len;
13734
13735 // bssId
13736 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13737 sizeof(tSirMacAddr));
13738
13739 smsLog( pMac, LOGW, FL("CSR Attempting to set "
13740 "HT20/40 mode for Bssid= "MAC_ADDRESS_STR),
13741 MAC_ADDR_ARRAY(pMsg->bssId));
13742
13743 pMsg->sessionId = sessionId;
13744 pMsg->cbMode = cbMode;
13745
13746 smsLog(pMac, LOGW, FL("session %d Channel Bonding: %d"),
13747 sessionId, cbMode);
13748
13749 status = palSendMBMessage(pMac->hHdd, pMsg);
13750 }
13751 return status;
13752}
13753#endif
13754
Jeff Johnson295189b2012-06-20 16:38:30 -070013755eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13756{
13757 eHalStatus status = eHAL_STATUS_SUCCESS;
13758 tSirSmeDeauthReq *pMsg;
13759 tANI_U8 *pBuf;
13760 tANI_U16 wTmp;
13761 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13762 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13763 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013764 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013765 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13766 if ( NULL == pMsg )
13767 status = eHAL_STATUS_FAILURE;
13768 else
13769 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013770 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013771 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013772 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13773 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13774 //sessionId
13775 pBuf = &pMsg->sessionId;
13776 *pBuf++ = (tANI_U8)sessionId;
13777
13778 //tansactionId
13779 *pBuf = 0;
13780 *(pBuf + 1 ) = 0;
13781 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013782 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013784 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13785 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013786 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13787 sizeof( pMsg->peerMacAddr ) );
13788 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013789 pBuf = pBuf + sizeof(tSirMacAddr);
13790 }
13791 else
13792 {
13793 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013794 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13795 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013796 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013797 }
13798 if(!HAL_STATUS_SUCCESS(status))
13799 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013800 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013801 break;
13802 }
13803 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013804 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13805 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013806 pBuf = pBuf + sizeof(tSirMacAddr);
13807 if(!HAL_STATUS_SUCCESS(status))
13808 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013809 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013810 break;
13811 }
13812 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013813 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13814 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013815 if(!HAL_STATUS_SUCCESS(status))
13816 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013817 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013818 break;
13819 }
13820 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013821 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013822 return( status );
13823}
13824
Jeff Johnson295189b2012-06-20 16:38:30 -070013825eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13826{
13827 eHalStatus status = eHAL_STATUS_SUCCESS;
13828 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013829 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013830 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13831 if ( NULL == pMsg )
13832 status = eHAL_STATUS_FAILURE;
13833 else
13834 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013835 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013836 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013837 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13838 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13839 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013840 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13841 sizeof(pMsg->peerMacAddr));
13842 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013843 if(!HAL_STATUS_SUCCESS(status))
13844 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013845 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013846 break;
13847 }
13848//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013849 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13850 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013851 if(!HAL_STATUS_SUCCESS(status))
13852 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013853 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013854 break;
13855 }
13856//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013857 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013858 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013859 return( status );
13860}
13861
Jeff Johnson295189b2012-06-20 16:38:30 -070013862eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13863{
13864 eHalStatus status = eHAL_STATUS_SUCCESS;
13865 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013866 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013867 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13868 if ( NULL == pMsg )
13869 status = eHAL_STATUS_FAILURE;
13870 else
13871 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013872 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013873 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013874 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13875 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13876 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013877 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13878 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013879 if(!HAL_STATUS_SUCCESS(status))
13880 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013881 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013882 break;
13883 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013884 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13885 sizeof(pMsg->peerMacAddr));
13886 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013887 if(!HAL_STATUS_SUCCESS(status))
13888 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013889 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013890 break;
13891 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013892 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013893 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013894 return( status );
13895}
Jeff Johnson295189b2012-06-20 16:38:30 -070013896eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13897{
13898 eHalStatus status = eHAL_STATUS_SUCCESS;
13899 tSirSmeAssocCnf *pMsg;
13900 tANI_U8 *pBuf;
13901 tSirResultCodes statusCode;
13902 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013903 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013904 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13905 if ( NULL == pMsg )
13906 status = eHAL_STATUS_FAILURE;
13907 else
13908 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013909 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013910 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013911 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13912 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013913 pBuf = (tANI_U8 *)&pMsg->statusCode;
13914 if(HAL_STATUS_SUCCESS(Halstatus))
13915 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13916 else
13917 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013918 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013919 pBuf += sizeof(tSirResultCodes);
13920 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013921 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13922 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013923 pBuf += sizeof (tSirMacAddr);
13924 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013925 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13926 sizeof(tSirMacAddr));
13927 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013928 pBuf += sizeof (tSirMacAddr);
13929 // aid
13930 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013931 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013932 pBuf += sizeof (tANI_U16);
13933 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013934 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13935 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013936 pBuf += sizeof (tSirMacAddr);
13937 // alternateChannelId
13938 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013939 status = palSendMBMessage( pMac->hHdd, pMsg );
13940 if(!HAL_STATUS_SUCCESS(status))
13941 {
13942 //pMsg is freed by palSendMBMessage
13943 break;
13944 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013945 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013946 return( status );
13947}
Jeff Johnson295189b2012-06-20 16:38:30 -070013948eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13949 tpSirSmeAssocInd pAssocInd,
13950 eHalStatus Halstatus,
13951 tANI_U8 sessionId)
13952{
13953 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013954 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13955 tANI_U8 *pBuf;
13956 tSirResultCodes statusCode;
13957 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013958 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013959 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13960 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13961 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013962
Jeff Johnson295189b2012-06-20 16:38:30 -070013963 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13964 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13965
13966 pMsg->sessionId = sessionId;
13967
13968 pBuf = (tANI_U8 *)&pMsg->statusCode;
13969 if(HAL_STATUS_SUCCESS(Halstatus))
13970 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13971 else
13972 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013973 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013974 pBuf += sizeof(tSirResultCodes);
13975 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013976 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013977 pBuf += sizeof (tSirMacAddr);
13978 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013979 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13980 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013981 pBuf += sizeof (tSirMacAddr);
13982 // StaId
13983 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013984 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013985 pBuf += sizeof (tANI_U16);
13986 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013987 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013988 pBuf += sizeof (tSirMacAddr);
13989 // alternateChannelId
13990 *pBuf = 11;
13991 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013992 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013993 //Wmm
13994 *pBuf = pAssocInd->wmmEnabledSta;
13995 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013996 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013997 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013998 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013999 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053014000 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070014001 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070014002 //reassocReq
14003 *pBuf = pAssocInd->reassocReq;
14004 pBuf += sizeof (tANI_U8);
Hardik Kantilal Patel1ba630f2014-11-21 04:32:05 +053014005#ifdef WLAN_FEATURE_AP_HT40_24G
14006 // 40 MHz Intolerant
14007 *pBuf = pAssocInd->HT40MHzIntoEnabledSta;
14008 pBuf += sizeof (tANI_U8);
14009#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014010 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
14011 msgQ.bodyptr = pMsg;
14012 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014013 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014014 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053014015 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070014016}
Jeff Johnson295189b2012-06-20 16:38:30 -070014017
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014018eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
14020 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
14021 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
14022 tANI_U8 *pKeyRsc )
14023{
14024 tSirSmeSetContextReq *pMsg;
14025 tANI_U16 msgLen;
14026 eHalStatus status = eHAL_STATUS_FAILURE;
14027 tAniEdType tmpEdType;
14028 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053014029 tANI_U8 *pBuf = NULL;
14030 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014031 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Sushant Kaushike7de85f2014-06-16 17:13:30 +053014032 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
14033 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014034 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014035 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070014036 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
14037 // key set. Since we only support upto one key, we always allocate memory for 1 key
14038 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
14039 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
14040 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
14041 ( sizeof( pMsg->keyMaterial.key ) );
14042
Kiet Lam64c1b492013-07-12 13:56:44 +053014043 pMsg = vos_mem_malloc(msgLen);
14044 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14045 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014046 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
14047 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014048 //sessionId
14049 pBuf = &pMsg->sessionId;
14050 *pBuf = (tANI_U8)sessionId;
14051 pBuf++;
14052 // transactionId
14053 *pBuf = 0;
14054 *(pBuf + 1) = 0;
14055 pBuf += sizeof(tANI_U16);
14056 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014057 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014058
14059 pBuf += sizeof(tSirMacAddr);
14060
14061 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053014062 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14063 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014064
14065 pBuf += sizeof(tSirMacAddr);
14066
14067 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014068 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
14069 // in the tSirKeyMaterial keyMaterial; field).
14070 //
14071 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
14072 // shorter than this max size. Is LIM interpreting this ok ?
14073 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 -070014074 // set pMsg->keyMaterial.edType
14075 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014076 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014077 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070014078 // set the pMsg->keyMaterial.numKeys field
14079 *p = numKeys;
14080 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070014081 // set pSirKey->keyId = keyId;
14082 *p = keyId;
14083 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014084 // set pSirKey->unicast = (tANI_U8)fUnicast;
14085 *p = (tANI_U8)fUnicast;
14086 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070014087 // set pSirKey->keyDirection = aniKeyDirection;
14088 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053014089 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070014090 p += sizeof(tAniKeyDirection);
14091 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053014092 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070014093 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070014094 // set pSirKey->paeRole
14095 *p = paeRole; // 0 is Supplicant
14096 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014097 // set pSirKey->keyLength = keyLength;
14098 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070014099 if ( keyLength && pKey )
14100 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014101 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070014102 if(keyLength == 16)
14103 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014104 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 -070014105 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
14106 pKey[5], pKey[6], pKey[7], pKey[8],
14107 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
14108 }
14109 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014110 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014111 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014112 return( status );
14113}
14114
Jeff Johnson295189b2012-06-20 16:38:30 -070014115eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
14116 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
14117{
14118 eHalStatus status;
14119 tSirSmeStartBssReq *pMsg;
14120 tANI_U8 *pBuf = NULL;
14121 tANI_U8 *wTmpBuf = NULL;
14122 tANI_U16 msgLen, wTmp;
14123 tANI_U32 dwTmp;
14124 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070014125 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014126 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070014127 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014128
14129 if(!pSession)
14130 {
14131 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14132 return eHAL_STATUS_FAILURE;
14133 }
14134
Jeff Johnson295189b2012-06-20 16:38:30 -070014135 do {
14136 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
14137 pSession->joinFailStatusCode.reasonCode = 0;
14138 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014139 pMsg = vos_mem_malloc(msgLen);
14140 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14141 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014142 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014143 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014144 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014145 //sessionId
14146 *pBuf = (tANI_U8)sessionId;
14147 pBuf++;
14148 // transactionId
14149 *pBuf = 0;
14150 *(pBuf + 1) = 0;
14151 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014152 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053014153 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014154 pBuf += sizeof(tSirMacAddr);
14155 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014156 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014157 pBuf += sizeof(tSirMacAddr);
14158 // beaconInterval
14159 if( pBssDesc && pBssDesc->beaconInterval )
14160 {
14161 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
14162 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014163 else if(pParam->beaconInterval)
14164 {
14165 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
14166 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014167 else
14168 {
14169 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
14170 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070014171 if(csrIsconcurrentsessionValid (pMac, sessionId,
14172 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070014173 == eHAL_STATUS_SUCCESS )
14174 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080014175 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070014176 pParam->bssPersona);
14177 //Update the beacon Interval
14178 pParam->beaconInterval = wTmp;
14179 }
14180 else
14181 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014182 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014183 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053014184 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070014185 return status;
14186 }
14187
Kiet Lam64c1b492013-07-12 13:56:44 +053014188 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014189 pBuf += sizeof(tANI_U16);
14190 // dot11mode
14191 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
14192 pBuf += 1;
14193 // bssType
14194 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053014195 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014196 pBuf += sizeof(tSirBssType);
14197 // ssId
14198 if( pParam->ssId.length )
14199 {
14200 // ssId len
14201 *pBuf = pParam->ssId.length;
14202 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014203 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070014204 pBuf += pParam->ssId.length;
14205 }
14206 else
14207 {
14208 *pBuf = 0;
14209 pBuf++;
14210 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014211 // set the channel Id
14212 *pBuf = pParam->operationChn;
14213 pBuf++;
14214 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070014215 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014216 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070014217 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014218
Jeff Johnson295189b2012-06-20 16:38:30 -070014219 // Set privacy
14220 *pBuf = pParam->privacy;
14221 pBuf++;
14222
14223 //Set Uapsd
14224 *pBuf = pParam->ApUapsdEnable;
14225 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014226 //Set SSID hidden
14227 *pBuf = pParam->ssidHidden;
14228 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014229 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
14230 pBuf++;
14231
14232 //Ht protection Enable/Disable
14233 *pBuf = (tANI_U8)pParam->protEnabled;
14234 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014235 //Enable Beacons to Receive for OBSS protection Enable/Disable
14236 *pBuf = (tANI_U8)pParam->obssProtEnabled;
14237 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014238 //set cfg related to protection
14239 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053014240 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014241 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014242 // Set Auth type
14243 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014244 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014245 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014246 // Set DTIM
14247 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053014248 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014249 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014250 // Set wps_state
14251 *pBuf = pParam->wps_state;
14252 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080014253 // set isCoalesingInIBSSAllowed
14254 *pBuf = pMac->isCoalesingInIBSSAllowed;
14255 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014256 //Persona
14257 *pBuf = (tANI_U8)pParam->bssPersona;
14258 pBuf++;
14259
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080014260 //txLdpcIniFeatureEnabled
14261 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
14262 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070014263
Chet Lanctot8cecea22014-02-11 19:09:36 -080014264#ifdef WLAN_FEATURE_11W
14265 // Set MFP capable/required
14266 *pBuf = (tANI_U8)pParam->mfpCapable;
14267 pBuf++;
14268 *pBuf = (tANI_U8)pParam->mfpRequired;
14269 pBuf++;
14270#endif
14271
krunal soni4f087d22013-07-29 16:32:26 -070014272 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070014273 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
14274 {
14275 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053014276 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014277 break;
14278 }
14279 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053014280 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014281 pBuf += sizeof(tANI_U16);
14282 if( wTmp )
14283 {
14284 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053014285 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014286 pBuf += wTmp;
14287 }
14288 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014289 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014290 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014291 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
14292 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014293 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
14294 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070014295 pBuf += pParam->operationalRateSet.numRates ;
14296 *pBuf++ = pParam->extendedRateSet.numRates;
14297 if(0 != pParam->extendedRateSet.numRates)
14298 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014299 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
14300 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070014301 pBuf += pParam->extendedRateSet.numRates;
14302 }
Hardik Kantilal Pateldd107952014-11-20 15:24:52 +053014303#ifdef WLAN_FEATURE_AP_HT40_24G
14304 *pBuf++ = (tANI_U8)pMac->roam.configParam.apHT40_24GEnabled;
14305#endif
krunal sonie9002db2013-11-25 14:24:17 -080014306
Jeff Johnson295189b2012-06-20 16:38:30 -070014307 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
14308 pMsg->length = pal_cpu_to_be16(msgLen);
14309
14310 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014311 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014312 return( status );
14313}
14314
Jeff Johnson295189b2012-06-20 16:38:30 -070014315eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
14316{
14317 eHalStatus status = eHAL_STATUS_FAILURE;
14318 tSirSmeStopBssReq *pMsg;
14319 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14320 tANI_U8 *pBuf;
14321 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070014322
14323 if(!pSession)
14324 {
14325 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14326 return eHAL_STATUS_FAILURE;
14327 }
14328
Jeff Johnson295189b2012-06-20 16:38:30 -070014329 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014330 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14331 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14332 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014333 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14334 pBuf = &pMsg->sessionId;
14335 //sessionId
14336 *pBuf = (tANI_U8)sessionId;
14337 pBuf++;
14338 // transactionId
14339 *pBuf = 0;
14340 pBuf += sizeof(tANI_U16);
14341 //reason code
14342 *pBuf = 0;
14343 pBuf += sizeof(tSirResultCodes);
14344 // bssid
14345 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14346 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14347 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014348 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
14349 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014350 }
14351 else
14352 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014353 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14354 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014355 }
14356 pBuf += sizeof(tSirMacAddr);
14357 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
14358 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014359 status = palSendMBMessage( pMac->hHdd, pMsg );
14360#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053014361 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14362 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14363 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014364 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14365 pMsg->reasonCode = 0;
14366 // bssid
14367 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14368 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14369 {
14370 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
14371 }
14372 else
14373 {
14374 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
14375 }
Kiet Lam64c1b492013-07-12 13:56:44 +053014376 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014377 pMsg->transactionId = 0;
14378 pMsg->sessionId = (tANI_U8)sessionId;
14379 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
14380 status = palSendMBMessage( pMac->hHdd, pMsg );
14381#endif
14382 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014383 return( status );
14384}
14385
Jeff Johnson295189b2012-06-20 16:38:30 -070014386eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
14387 tCsrRoamModifyProfileFields *pModProfileFields,
14388 tANI_U32 *pRoamId, v_BOOL_t fForce)
14389{
Jeff Johnson295189b2012-06-20 16:38:30 -070014390 eHalStatus status = eHAL_STATUS_FAILURE;
14391 tANI_U32 roamId = 0;
14392 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014393 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053014394 (fForce || (!vos_mem_compare( &pModProfileFields,
14395 &pSession->connectedProfile.modifyProfileFields,
14396 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014397 {
14398 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14399 if(pRoamId)
14400 {
14401 *pRoamId = roamId;
14402 }
14403
Jeff Johnson295189b2012-06-20 16:38:30 -070014404 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
14405 eCsrSmeIssuedReassocToSameAP, roamId,
14406 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014407 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014408 return status;
14409}
Jeff Johnson295189b2012-06-20 16:38:30 -070014410static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
14411{
14412 eHalStatus status = eHAL_STATUS_SUCCESS;
14413 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053014414 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014415 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
14416 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
14417 return (status);
14418}
Jeff Johnson295189b2012-06-20 16:38:30 -070014419eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14420{
14421 eHalStatus status = eHAL_STATUS_SUCCESS;
14422 tListElem *pEntry = NULL;
14423 tSmeCmd *pCommand = NULL;
14424 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014425 do
14426 {
14427 if(pMsg == NULL)
14428 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014429 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014430 status = eHAL_STATUS_FAILURE;
14431 break;
14432 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014433 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14434 if(pEntry)
14435 {
14436 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14437 if(eSmeCommandAddStaSession == pCommand->command)
14438 {
14439 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014440 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053014441 if (pRsp->status == eSIR_FAILURE) {
14442 VOS_ASSERT( 0 );
14443 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014444 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014445 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014446 //Remove this command out of the active list
14447 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14448 {
14449 //Now put this command back on the avilable command list
14450 csrReleaseCommand(pMac, pCommand);
14451 }
14452 smeProcessPendingQueue( pMac );
14453 }
14454 else
14455 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014456 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 -070014457 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014458 status = eHAL_STATUS_FAILURE;
14459 break;
14460 }
14461 }
14462 else
14463 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014464 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 -070014465 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014466 status = eHAL_STATUS_FAILURE;
14467 break;
14468 }
14469 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014470 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014471}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014472eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14473 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014474{
14475 tSirSmeAddStaSelfReq *pMsg;
14476 tANI_U16 msgLen;
14477 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014478 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014479 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014480 pMsg = vos_mem_malloc(msgLen);
14481 if ( NULL == pMsg ) break;
14482 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014483 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14484 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014485 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014486 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014487 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14488
14489 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14490
Arif Hussain24bafea2013-11-15 15:10:03 -080014491 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14492 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014493 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014494 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014495 return( status );
14496}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014497eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14498 tANI_U32 sessionId,
14499 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014500{
14501 eHalStatus status = eHAL_STATUS_SUCCESS;
14502 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014503 pCommand = csrGetCommandBuffer(pMac);
14504 if(NULL == pCommand)
14505 {
14506 status = eHAL_STATUS_RESOURCES;
14507 }
14508 else
14509 {
14510 pCommand->command = eSmeCommandAddStaSession;
14511 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014512 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14513 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014514 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014515 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14516 if( !HAL_STATUS_SUCCESS( status ) )
14517 {
14518 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014519 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014520 }
14521 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014522 return (status);
14523}
Jeff Johnson295189b2012-06-20 16:38:30 -070014524eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14525{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014526 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014527}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014528eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14529 csrRoamCompleteCallback callback,
14530 void *pContext, tANI_U8 *pSelfMacAddr,
14531 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014532{
14533 eHalStatus status = eHAL_STATUS_SUCCESS;
14534 tANI_U32 i;
14535 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014536 *pbSessionId = CSR_SESSION_ID_INVALID;
14537 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14538 {
14539 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14540 {
14541 pSession = CSR_GET_SESSION( pMac, i );
14542 status = eHAL_STATUS_SUCCESS;
14543 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14544 pSession->sessionId = (tANI_U8)i;
14545 pSession->callback = callback;
14546 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014547 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014548 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014549 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14550 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014551 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014552 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014553 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014554 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014555 break;
14556 }
14557#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014558 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14559 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014560 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014561 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014562 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014563 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014564 break;
14565 }
14566#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014567 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014568 break;
14569 }
14570 }
14571 if( CSR_ROAM_SESSION_MAX == i )
14572 {
14573 //No session is available
14574 status = eHAL_STATUS_RESOURCES;
14575 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014576 return ( status );
14577}
Jeff Johnson295189b2012-06-20 16:38:30 -070014578eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14579{
14580 eHalStatus status = eHAL_STATUS_SUCCESS;
14581 tListElem *pEntry = NULL;
14582 tSmeCmd *pCommand = NULL;
14583 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014584 do
14585 {
14586 if(pMsg == NULL)
14587 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014588 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014589 status = eHAL_STATUS_FAILURE;
14590 break;
14591 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014592 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14593 if(pEntry)
14594 {
14595 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14596 if(eSmeCommandDelStaSession == pCommand->command)
14597 {
14598 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014599 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014600 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014601 //This session is done.
14602 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014603 if(pCommand->u.delStaSessionCmd.callback)
14604 {
14605
14606 status = sme_ReleaseGlobalLock( &pMac->sme );
14607 if ( HAL_STATUS_SUCCESS( status ) )
14608 {
14609 pCommand->u.delStaSessionCmd.callback(
14610 pCommand->u.delStaSessionCmd.pContext);
14611 status = sme_AcquireGlobalLock( &pMac->sme );
14612 if (! HAL_STATUS_SUCCESS( status ) )
14613 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014614 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014615 return status;
14616 }
14617 }
14618 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014619 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014620 }
14621 }
14622
14623 //Remove this command out of the active list
14624 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14625 {
14626 //Now put this command back on the avilable command list
14627 csrReleaseCommand(pMac, pCommand);
14628 }
14629 smeProcessPendingQueue( pMac );
14630 }
14631 else
14632 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014633 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 -070014634 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014635 status = eHAL_STATUS_FAILURE;
14636 break;
14637 }
14638 }
14639 else
14640 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014641 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 -070014642 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014643 status = eHAL_STATUS_FAILURE;
14644 break;
14645 }
14646 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014647 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014648}
Jeff Johnson295189b2012-06-20 16:38:30 -070014649eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14650{
14651 tSirSmeDelStaSelfReq *pMsg;
14652 tANI_U16 msgLen;
14653 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014654 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014655 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14656 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014657 pMsg = vos_mem_malloc(msgLen);
14658 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14659 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014660 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14661 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014662 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014663 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14664 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014665 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014666 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014667 return( status );
14668}
Jeff Johnson295189b2012-06-20 16:38:30 -070014669eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14670 tSirMacAddr sessionMacAddr,
14671 csrRoamSessionCloseCallback callback,
14672 void *pContext)
14673{
14674 eHalStatus status = eHAL_STATUS_SUCCESS;
14675 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014676 pCommand = csrGetCommandBuffer(pMac);
14677 if(NULL == pCommand)
14678 {
14679 status = eHAL_STATUS_RESOURCES;
14680 }
14681 else
14682 {
14683 pCommand->command = eSmeCommandDelStaSession;
14684 pCommand->sessionId = (tANI_U8)sessionId;
14685 pCommand->u.delStaSessionCmd.callback = callback;
14686 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014687 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14688 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014689 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14690 if( !HAL_STATUS_SUCCESS( status ) )
14691 {
14692 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014693 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014694 }
14695 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014696 return (status);
14697}
Jeff Johnson295189b2012-06-20 16:38:30 -070014698eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14699{
14700 return csrSendMBDelSelfStaReqMsg( pMac,
14701 pCommand->u.delStaSessionCmd.selfMacAddr );
14702}
Jeff Johnson295189b2012-06-20 16:38:30 -070014703static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14704{
14705 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14706 tListElem *pEntry, *pNext;
14707 tSmeCmd *pCommand;
14708 tDblLinkList localList;
14709
14710 vos_mem_zero(&localList, sizeof(tDblLinkList));
14711 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14712 {
14713 smsLog(pMac, LOGE, FL(" failed to open list"));
14714 return;
14715 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014716 csrLLLock(pList);
14717 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14718 while(pEntry != NULL)
14719 {
14720 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14721 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14722 if(pCommand->sessionId == sessionId)
14723 {
14724 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14725 {
14726 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14727 }
14728 }
14729 pEntry = pNext;
14730 }
14731 csrLLUnlock(pList);
14732
14733 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14734 {
14735 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14736 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14737 }
14738 csrLLClose(&localList);
14739}
14740
Jeff Johnson295189b2012-06-20 16:38:30 -070014741void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14742{
14743 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14744 {
14745 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014746 csrRoamStop(pMac, sessionId);
14747 csrFreeConnectBssDesc(pMac, sessionId);
14748 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14749 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014750 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014751#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014752 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014753#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014754 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14755 if (pMac->fScanOffload)
14756 {
14757 purgeSmeSessionCmdList(pMac, sessionId,
14758 &pMac->sme.smeScanCmdPendingList);
14759 }
14760
Jeff Johnson295189b2012-06-20 16:38:30 -070014761 purgeCsrSessionCmdList(pMac, sessionId);
14762 csrInitSession(pMac, sessionId);
14763 }
14764}
14765
Jeff Johnson295189b2012-06-20 16:38:30 -070014766eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14767 tANI_BOOLEAN fSync,
14768 csrRoamSessionCloseCallback callback,
14769 void *pContext )
14770{
14771 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014772 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14773 {
14774 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14775 if(fSync)
14776 {
14777 csrCleanupSession(pMac, sessionId);
14778 }
14779 else
14780 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014781 purgeSmeSessionCmdList(pMac, sessionId,
14782 &pMac->sme.smeCmdPendingList);
14783 if (pMac->fScanOffload)
14784 {
14785 purgeSmeSessionCmdList(pMac, sessionId,
14786 &pMac->sme.smeScanCmdPendingList);
14787 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014788 purgeCsrSessionCmdList(pMac, sessionId);
14789 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14790 pSession->selfMacAddr, callback, pContext);
14791 }
14792 }
14793 else
14794 {
14795 status = eHAL_STATUS_INVALID_PARAMETER;
14796 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014797 return ( status );
14798}
14799
Jeff Johnson295189b2012-06-20 16:38:30 -070014800static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14801{
14802 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014803
14804 if(!pSession)
14805 {
14806 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14807 return;
14808 }
14809
Jeff Johnson295189b2012-06-20 16:38:30 -070014810 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14811 pSession->sessionId = CSR_SESSION_ID_INVALID;
14812 pSession->callback = NULL;
14813 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014814 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14815 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14816 csrFreeRoamProfile( pMac, sessionId );
14817 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14818 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14819 csrFreeConnectBssDesc(pMac, sessionId);
14820 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014821 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14822 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014823 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014824 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014825 pSession->pWpaRsnReqIE = NULL;
14826 }
14827 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014828 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014829 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014830 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014831 pSession->pWpaRsnRspIE = NULL;
14832 }
14833 pSession->nWpaRsnRspIeLength = 0;
14834#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014835 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014836 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014837 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014838 pSession->pWapiReqIE = NULL;
14839 }
14840 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014841 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014842 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014843 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014844 pSession->pWapiRspIE = NULL;
14845 }
14846 pSession->nWapiRspIeLength = 0;
14847#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014848 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014849 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014850 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014851 }
14852 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014853
Kiet Lam64c1b492013-07-12 13:56:44 +053014854 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014855 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014856 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014857 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014858 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014859 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014860}
14861
Jeff Johnson295189b2012-06-20 16:38:30 -070014862eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14863{
14864 eHalStatus status = eHAL_STATUS_FAILURE;
14865 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014866 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14867 {
14868 if( CSR_IS_SESSION_VALID( pMac, i ) )
14869 {
14870 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14871 {
14872 //Found it
14873 status = eHAL_STATUS_SUCCESS;
14874 *pSessionId = i;
14875 break;
14876 }
14877 }
14878 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014879 return( status );
14880}
14881
Jeff Johnson295189b2012-06-20 16:38:30 -070014882//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14883//session because for IBSS, the bssid changes.
14884static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14885{
14886 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14887 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014888 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14889 {
14890 if( CSR_IS_SESSION_VALID( pMac, i ) )
14891 {
14892 pSession = CSR_GET_SESSION( pMac, i );
14893 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14894 {
14895 //Found it
14896 nRet = i;
14897 break;
14898 }
14899 }
14900 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014901 return (nRet);
14902}
Jeff Johnson295189b2012-06-20 16:38:30 -070014903static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14904{
Mukul Sharma20aa6582014-08-07 21:36:12 +053014905 VOS_STATUS status = VOS_STATUS_SUCCESS;
14906
14907 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070014908 profile info from pmac global structure */
14909
Arif Hussain24bafea2013-11-15 15:10:03 -080014910 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14911 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014912 /* Check for user misconfig of RSSI trigger threshold */
14913 pMac->roam.configParam.vccRssiThreshold =
14914 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14915 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14916 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014917 /* Check for user misconfig of UL MAC Loss trigger threshold */
14918 pMac->roam.configParam.vccUlMacLossThreshold =
14919 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14920 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014921#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14922 {
14923 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014924 /* Indicate the neighbor roal algorithm about the connect indication */
14925 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14926 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053014927
14928 // Making sure we are roaming force fully to 5GHz AP only once and
14929 // only when we connected to 2.4GH AP only during initial association.
14930 if(pMac->roam.neighborRoamInfo.cfgParams.neighborInitialForcedRoamTo5GhEnable &&
14931 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel) == SIR_BAND_2_4_GHZ)
14932 {
14933 //Making ini value to false here only so we just roam to
14934 //only once for whole driver load to unload tenure
14935 pMac->roam.neighborRoamInfo.cfgParams.neighborInitialForcedRoamTo5GhEnable = VOS_FALSE;
14936
14937 status = vos_timer_start(&pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer,
14938 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
14939 //MUKUL TODO: change the neighborResultsRefreshPeriod to some ini value reuqired ??
14940 if ( status != VOS_STATUS_SUCCESS )
14941 {
14942 smsLog(pMac, LOGE, FL("%s Neighbor forcedInitialRoamTo5GHTimer start failed with status %d"), __func__, status);
14943 }
14944 smsLog(pMac, LOGE, FL("%s: Forced roam to 5G started Timer"), __func__);
14945 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014946 }
14947#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014948}
14949
Jeff Johnson295189b2012-06-20 16:38:30 -070014950static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14951{
14952 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014953
14954 if(!pSession)
14955 {
14956 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14957 return;
14958 }
14959
Jeff Johnson295189b2012-06-20 16:38:30 -070014960 //Only to handle the case for Handover on infra link
14961 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14962 {
14963 return;
14964 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014965 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14966 csrRoamDeregStatisticsReq(pMac);
14967 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14968#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14969 /* Indicate the neighbor roal algorithm about the disconnect indication */
14970 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14971#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014972
14973 //Remove this code once SLM_Sessionization is supported
14974 //BMPS_WORKAROUND_NOT_NEEDED
14975 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014976 csrIsInfraApStarted( pMac ) &&
14977 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014978 {
14979 pMac->roam.configParam.doBMPSWorkaround = 0;
14980 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014981}
14982
Jeff Johnson295189b2012-06-20 16:38:30 -070014983void csrRoamTlStatsTimerHandler(void *pv)
14984{
14985 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14986 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014987 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14988
Jeff Johnsone7245742012-09-05 17:12:55 -070014989 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14990
Jeff Johnson295189b2012-06-20 16:38:30 -070014991#if 0
14992 // TODO Persession .???
14993 //req TL for stats
14994 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14995 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014996 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014997 }
14998 else
14999 {
15000 //save in SME
15001 csrRoamSaveStatsFromTl(pMac, tlStats);
15002 }
15003#endif
15004 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15005 {
15006 if(pMac->roam.tlStatsReqInfo.periodicity)
15007 {
15008 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015009 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15010 pMac->roam.tlStatsReqInfo.periodicity);
15011 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015012 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015013 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015014 return;
15015 }
15016 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15017 }
15018 }
15019}
Jeff Johnson295189b2012-06-20 16:38:30 -070015020void csrRoamPeStatsTimerHandler(void *pv)
15021{
15022 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
15023 eHalStatus status;
15024 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
15025 VOS_STATUS vosStatus;
15026 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070015027 pPeStatsReqListEntry->timerRunning = FALSE;
15028 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
15029 {
15030 // If we entered here, meaning the timer could not be successfully
15031 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
15032
15033 /* Destroy the timer */
15034 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
15035 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15036 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015037 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015038 }
15039
15040 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015041 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070015042 pPeStatsReqListEntry = NULL;
15043 }
15044 else
15045 {
15046 if(!pPeStatsReqListEntry->rspPending)
15047 {
15048 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
15049 pPeStatsReqListEntry->staId);
15050 if(!HAL_STATUS_SUCCESS(status))
15051 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015052 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015053 }
15054 else
15055 {
15056 pPeStatsReqListEntry->rspPending = TRUE;
15057 }
15058 }
15059
15060 //send down a req
15061 if(pPeStatsReqListEntry->periodicity &&
15062 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
15063 {
15064 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
15065 if(ePMC_FULL_POWER == powerState)
15066 {
15067 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
15068 {
15069 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
15070 }
15071 }
15072 else
15073 {
15074 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
15075 {
15076 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
15077 }
15078 }
15079 //start timer
15080 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
15081 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15082 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015083 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015084 return;
15085 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015086 pPeStatsReqListEntry->timerRunning = TRUE;
15087
15088 }
15089
15090 }
15091}
Jeff Johnson295189b2012-06-20 16:38:30 -070015092void csrRoamStatsClientTimerHandler(void *pv)
15093{
15094 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070015095 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
15096 {
15097#if 0
15098 // TODO Stats fix for multisession
15099 //start the timer
15100 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
15101
15102 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15103 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015104 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015105 }
15106#endif
15107 }
15108#if 0
15109 //send up the stats report
15110 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
15111 pStaEntry->staId, pStaEntry->pContext);
15112#endif
15113}
15114
15115
15116
Jeff Johnson295189b2012-06-20 16:38:30 -070015117eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
15118{
15119 tAniGetPEStatsReq *pMsg;
15120 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053015121 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
15122 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015123 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015124 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053015125 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015126 }
15127 // need to initiate a stats request to PE
15128 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
15129 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
15130 pMsg->staId = staId;
15131 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015132 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015133 if(!HAL_STATUS_SUCCESS(status))
15134 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015135 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070015136 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015137 return status;
15138}
Jeff Johnson295189b2012-06-20 16:38:30 -070015139void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
15140{
15141 tAniGetPEStatsRsp *pSmeStatsRsp;
15142 eHalStatus status = eHAL_STATUS_FAILURE;
15143 tListElem *pEntry = NULL;
15144 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15145 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15146 tANI_U32 tempMask = 0;
15147 tANI_U8 counter = 0;
15148 tANI_U8 *pStats = NULL;
15149 tANI_U32 length = 0;
15150 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015151 v_S7_t rssi = 0, snr = 0;
15152 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015153 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015154 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
15155 if(pSmeStatsRsp->rc)
15156 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015157 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015158 goto post_update;
15159 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015160 tempMask = pSmeStatsRsp->statsMask;
15161 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070015162 /* subtract all statistics from this length, and after processing the entire
15163 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
15164 * in this 'stats' message.
15165 */
15166 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070015167 //new stats info from PE, fill up the stats strucutres in PMAC
15168 while(tempMask)
15169 {
15170 if(tempMask & 1)
15171 {
15172 switch(counter)
15173 {
15174 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015175 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015176 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
15177 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015178 pStats += sizeof(tCsrSummaryStatsInfo);
15179 length -= sizeof(tCsrSummaryStatsInfo);
15180 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015181 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015182 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015183 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
15184 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015185 pStats += sizeof(tCsrGlobalClassAStatsInfo);
15186 length -= sizeof(tCsrGlobalClassAStatsInfo);
15187 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015188 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015189 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015190 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
15191 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015192 pStats += sizeof(tCsrGlobalClassBStatsInfo);
15193 length -= sizeof(tCsrGlobalClassBStatsInfo);
15194 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015195 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015196 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015197 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
15198 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015199 pStats += sizeof(tCsrGlobalClassCStatsInfo);
15200 length -= sizeof(tCsrGlobalClassCStatsInfo);
15201 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015202 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015203 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015204 if( CSR_MAX_STA > pSmeStatsRsp->staId )
15205 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015206 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
15207 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015208 }
15209 else
15210 {
15211 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015212 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015213 VOS_ASSERT( 0 );
15214 }
15215 if(!HAL_STATUS_SUCCESS(status))
15216 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015217 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015218 }
15219 pStats += sizeof(tCsrPerStaStatsInfo);
15220 length -= sizeof(tCsrPerStaStatsInfo);
15221 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015222 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015223 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015224 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015225 }
15226 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015227 tempMask >>=1;
15228 counter++;
15229 }
15230 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
15231 if (length != 0)
15232 {
15233 pRssi = (tANI_U32*)pStats;
15234 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015235 pStats += sizeof(tANI_U32);
15236 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015237 }
15238 else
15239 {
15240 /* If riva is not sending rssi, continue to use the hack */
15241 rssi = RSSI_HACK_BMPS;
15242 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015243
Jeff Johnson295189b2012-06-20 16:38:30 -070015244 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015245
15246 if (length != 0)
15247 {
15248 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015249 pStats += sizeof(tANI_U32);
15250 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015251 }
15252 else
15253 {
15254 linkCapacity = 0;
15255 }
15256
15257 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015258
15259 if (length != 0)
15260 {
15261 pSnr = (tANI_U32*)pStats;
15262 snr = (v_S7_t)*pSnr;
15263 }
15264 else
15265 {
15266 snr = SNR_HACK_BMPS;
15267 }
15268
15269 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015270post_update:
15271 //make sure to update the pe stats req list
15272 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
15273 if(pEntry)
15274 {
15275 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
15276 pPeStaEntry->rspPending = FALSE;
15277
15278 }
15279 //check the one timer cases
15280 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
15281 if(pEntry)
15282 {
Jeff Johnson295189b2012-06-20 16:38:30 -070015283 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015284 if(pTempStaEntry->timerExpired)
15285 {
15286 //send up the stats report
15287 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15288 pTempStaEntry->staId, pTempStaEntry->pContext);
15289 //also remove from the client list
15290 csrRoamRemoveStatListEntry(pMac, pEntry);
15291 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015292 }
15293 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015294}
Jeff Johnson295189b2012-06-20 16:38:30 -070015295tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15296{
15297 tListElem *pEntry = NULL;
15298 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015299 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015300 if(!pEntry)
15301 {
15302 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015303 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015304 return NULL;
15305 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015306 while( pEntry )
15307 {
15308 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015309 if(pTempStaEntry->statsMask == statsMask)
15310 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015311 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015312 break;
15313 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015314 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15315 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015316 return pEntry;
15317}
15318
Jeff Johnson295189b2012-06-20 16:38:30 -070015319tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
15320 tANI_BOOLEAN update)
15321{
15322 tListElem *pEntry;
15323 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015324 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015325 if(!pEntry)
15326 {
15327 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015328 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015329 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015330 return NULL;
15331 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015332 while( pEntry )
15333 {
15334 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015335 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
15336 (pTempStaEntry->statsMask == pStaEntry->statsMask))
15337 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015338 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015339 if(update)
15340 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015341 pTempStaEntry->periodicity = pStaEntry->periodicity;
15342 pTempStaEntry->callback = pStaEntry->callback;
15343 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015344 }
15345 break;
15346 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015347 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15348 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015349 return pEntry;
15350}
Jeff Johnson295189b2012-06-20 16:38:30 -070015351tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15352{
15353 tListElem *pEntry;
15354 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015355 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015356 if(!pEntry)
15357 {
15358 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015359 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015360 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015361 return NULL;
15362 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015363 while( pEntry )
15364 {
15365 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015366 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
15367 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015368 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015369 break;
15370 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015371 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15372 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015373 return pEntry;
15374}
Jeff Johnson295189b2012-06-20 16:38:30 -070015375eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
15376 csrRoamLinkQualityIndCallback callback,
15377 void *pContext)
15378{
15379 pMac->roam.linkQualityIndInfo.callback = callback;
15380 pMac->roam.linkQualityIndInfo.context = pContext;
15381 if( NULL == callback )
15382 {
15383 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
15384 }
15385 else
15386 {
15387 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070015388 /* do we need to invoke the callback to notify client of initial value ?? */
15389 }
15390 return eHAL_STATUS_SUCCESS;
15391}
Jeff Johnson295189b2012-06-20 16:38:30 -070015392void csrRoamVccTrigger(tpAniSirGlobal pMac)
15393{
15394 eCsrRoamLinkQualityInd newVccLinkQuality;
15395 tANI_U32 ul_mac_loss = 0;
15396 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015397 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15398 /*-------------------------------------------------------------------------
15399 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015400 Check for a change in link quality and notify client if necessary
15401 -------------------------------------------------------------------------*/
15402 ul_mac_loss_trigger_threshold =
15403 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015404 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015405 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015406 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070015407 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
15408 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015409 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015410 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15411 }
15412 else
15413 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015414 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070015415 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15416 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015417 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
15418 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070015419 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15420 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015421 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015422 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15423 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015424 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015425 newVccLinkQuality );
15426
15427 /* we now invoke the callback once to notify client of initial value */
15428 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15429 pMac->roam.linkQualityIndInfo.context );
15430 //event: EVENT_WLAN_VCC
15431 }
15432 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015433 pMac->roam.vccLinkQuality = newVccLinkQuality;
15434
Jeff Johnson295189b2012-06-20 16:38:30 -070015435}
Jeff Johnson295189b2012-06-20 16:38:30 -070015436VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
15437 v_U8_t rssiNotification,
15438 void * context)
15439{
15440 tpAniSirGlobal pMac = PMAC_STRUCT( context );
15441 eCsrRoamLinkQualityInd newVccLinkQuality;
15442 // TODO : Session info unavailable
15443 tANI_U32 sessionId = 0;
15444 VOS_STATUS status = VOS_STATUS_SUCCESS;
15445 /*-------------------------------------------------------------------------
15446 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015447 Check for a change in link quality and notify client if necessary
15448 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015449 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015450 pMac->roam.configParam.vccRssiThreshold);
15451 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15452 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015453 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015454 return VOS_STATUS_SUCCESS;
15455 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015456 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15457 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015458 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015459 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15460 }
15461 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15462 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015463 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015464 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15465 }
15466 else
15467 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015468 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015469 //Set to this so the code below won't do anything
15470 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015471 VOS_ASSERT(0);
15472 }
15473
Jeff Johnson295189b2012-06-20 16:38:30 -070015474 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15475 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015476 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015477 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15478 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015479 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015480 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070015481 /* we now invoke the callback once to notify client of initial value */
15482 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15483 pMac->roam.linkQualityIndInfo.context );
15484 //event: EVENT_WLAN_VCC
15485 }
15486 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015487 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015488 return status;
15489}
Jeff Johnson295189b2012-06-20 16:38:30 -070015490tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
15491 tDblLinkList *pStaList,
15492 tCsrStatsClientReqInfo *pStaEntry)
15493{
15494 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015495 //if same entity requested for same set of stats with different periodicity &
15496 // callback update it
15497 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
15498 {
15499
Kiet Lam64c1b492013-07-12 13:56:44 +053015500 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15501 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015502 {
15503 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015504 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015505 return NULL;
15506 }
15507
Jeff Johnson295189b2012-06-20 16:38:30 -070015508 pNewStaEntry->callback = pStaEntry->callback;
15509 pNewStaEntry->pContext = pStaEntry->pContext;
15510 pNewStaEntry->periodicity = pStaEntry->periodicity;
15511 pNewStaEntry->requesterId = pStaEntry->requesterId;
15512 pNewStaEntry->statsMask = pStaEntry->statsMask;
15513 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15514 pNewStaEntry->pMac = pStaEntry->pMac;
15515 pNewStaEntry->staId = pStaEntry->staId;
15516 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15517
15518 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15519 }
15520 return pNewStaEntry;
15521}
15522
Jeff Johnson295189b2012-06-20 16:38:30 -070015523tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15524 tDblLinkList *pStaList,
15525 tCsrPeStatsReqInfo *pStaEntry)
15526{
15527 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015528 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15529 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015530 {
15531 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015532 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015533 return NULL;
15534 }
15535
Jeff Johnson295189b2012-06-20 16:38:30 -070015536 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15537 pNewStaEntry->numClient = pStaEntry->numClient;
15538 pNewStaEntry->periodicity = pStaEntry->periodicity;
15539 pNewStaEntry->statsMask = pStaEntry->statsMask;
15540 pNewStaEntry->pMac = pStaEntry->pMac;
15541 pNewStaEntry->staId = pStaEntry->staId;
15542 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15543 pNewStaEntry->rspPending = pStaEntry->rspPending;
15544
15545 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015546 return pNewStaEntry;
15547}
Jeff Johnson295189b2012-06-20 16:38:30 -070015548eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15549 tCsrRssiCallback callback,
15550 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15551{
15552 eHalStatus status = eHAL_STATUS_SUCCESS;
15553 vos_msg_t msg;
15554 tANI_U32 sessionId;
15555
15556 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015557 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015558 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15559 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015560 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015561 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015562 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015563 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015564 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15565
15566 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15567 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15568 pMsg->sessionId = sessionId;
15569 pMsg->staId = staId;
15570 pMsg->rssiCallback = callback;
15571 pMsg->pDevContext = pContext;
15572 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015573 msg.type = eWNI_SME_GET_RSSI_REQ;
15574 msg.bodyptr = pMsg;
15575 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015576 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15577 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015578 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015579 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015580 status = eHAL_STATUS_FAILURE;
15581 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015582 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015583 return status;
15584}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015585
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015586eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15587 tCsrSnrCallback callback,
15588 tANI_U8 staId, tCsrBssid bssId,
15589 void *pContext)
15590{
15591 eHalStatus status = eHAL_STATUS_SUCCESS;
15592 vos_msg_t msg;
15593 tANI_U32 sessionId;
15594
15595 tAniGetSnrReq *pMsg;
15596
15597 smsLog(pMac, LOG2, FL("called"));
15598
15599 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15600 if (NULL == pMsg )
15601 {
15602 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15603 return status;
15604 }
15605
15606 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15607
15608 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15609 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15610 pMsg->sessionId = sessionId;
15611 pMsg->staId = staId;
15612 pMsg->snrCallback = callback;
15613 pMsg->pDevContext = pContext;
15614 msg.type = eWNI_SME_GET_SNR_REQ;
15615 msg.bodyptr = pMsg;
15616 msg.reserved = 0;
15617
15618 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15619 {
15620 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15621 vos_mem_free((v_VOID_t *)pMsg);
15622 status = eHAL_STATUS_FAILURE;
15623 }
15624
15625 smsLog(pMac, LOG2, FL("returned"));
15626 return status;
15627}
15628
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015629#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015630eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15631 tCsrRssiCallback callback,
15632 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15633{
15634 eHalStatus status = eHAL_STATUS_SUCCESS;
15635 tAniGetRssiReq *pMsg;
15636
Kiet Lam64c1b492013-07-12 13:56:44 +053015637 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15638 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015639 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015640 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015641 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015642 }
15643 // need to initiate a stats request to PE
15644 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15645 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15646 pMsg->staId = staId;
15647 pMsg->rssiCallback = callback;
15648 pMsg->pDevContext = pContext;
15649 pMsg->pVosContext = pVosContext;
15650 status = palSendMBMessage(pMac->hHdd, pMsg );
15651 if(!HAL_STATUS_SUCCESS(status))
15652 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015653 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015654 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015655 status = eHAL_STATUS_FAILURE;
15656 }
15657 return status;
15658}
15659#endif
15660
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015661
15662
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015663#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015664eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15665 tCsrTsmStatsCallback callback,
15666 tANI_U8 staId,
15667 tCsrBssid bssId,
15668 void *pContext,
15669 void* pVosContext,
15670 tANI_U8 tid)
15671{
15672 eHalStatus status = eHAL_STATUS_SUCCESS;
15673 tAniGetTsmStatsReq *pMsg = NULL;
15674
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015675 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15676 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015677 {
15678 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015679 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015680 }
15681 // need to initiate a stats request to PE
15682 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15683 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15684 pMsg->staId = staId;
15685 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015686 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015687 pMsg->tsmStatsCallback = callback;
15688 pMsg->pDevContext = pContext;
15689 pMsg->pVosContext = pVosContext;
15690 status = palSendMBMessage(pMac->hHdd, pMsg );
15691 if(!HAL_STATUS_SUCCESS(status))
15692 {
15693 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15694 //pMsg is freed by palSendMBMessage
15695 status = eHAL_STATUS_FAILURE;
15696 }
15697 return status;
15698}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015699#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015700
15701
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015702/* ---------------------------------------------------------------------------
15703 \fn csrGetTLSTAState
15704 \helper function to get teh TL STA State whenever the function is called.
15705
15706 \param staId - The staID to be passed to the TL
15707 to get the relevant TL STA State
15708 \return the state as tANI_U16
15709 ---------------------------------------------------------------------------*/
15710tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15711{
15712 WLANTL_STAStateType tlSTAState;
15713 tlSTAState = WLANTL_STA_INIT;
15714
15715 //request TL for STA State
15716 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15717 {
15718 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15719 }
15720
15721 return tlSTAState;
15722}
15723
Jeff Johnson295189b2012-06-20 16:38:30 -070015724eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15725 tANI_U32 statsMask,
15726 tCsrStatsCallback callback,
15727 tANI_U32 periodicity, tANI_BOOLEAN cache,
15728 tANI_U8 staId, void *pContext)
15729{
15730 tCsrStatsClientReqInfo staEntry;
15731 tCsrStatsClientReqInfo *pStaEntry = NULL;
15732 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15733 tListElem *pEntry = NULL;
15734 tANI_BOOLEAN found = FALSE;
15735 eHalStatus status = eHAL_STATUS_SUCCESS;
15736 tANI_BOOLEAN insertInClientList = FALSE;
15737 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015738 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015739
15740 if( csrIsAllSessionDisconnected(pMac) )
15741 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015742 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015743 return eHAL_STATUS_FAILURE;
15744 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015745
15746 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15747 {
15748 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15749 return eHAL_STATUS_FAILURE;
15750 }
15751
Jeff Johnson295189b2012-06-20 16:38:30 -070015752 if((!statsMask) && (!callback))
15753 {
15754 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015755 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015756 return eHAL_STATUS_FAILURE;
15757 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015758 //for the search list method for deregister
15759 staEntry.requesterId = requesterId;
15760 staEntry.statsMask = statsMask;
15761 //requester wants to deregister or just an error
15762 if((statsMask) && (!callback))
15763 {
15764 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15765 if(!pEntry)
15766 {
15767 //msg
15768 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015769 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015770 return eHAL_STATUS_FAILURE;
15771 }
15772 else
15773 {
15774 //clean up & return
15775 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015776 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015777 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015778 pStaEntry->pPeStaEntry->numClient--;
15779 //check if we need to delete the entry from peStatsReqList too
15780 if(!pStaEntry->pPeStaEntry->numClient)
15781 {
15782 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15783 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015784 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015785
Jeff Johnson295189b2012-06-20 16:38:30 -070015786 //check if we need to stop the tl stats timer too
15787 pMac->roam.tlStatsReqInfo.numClient--;
15788 if(!pMac->roam.tlStatsReqInfo.numClient)
15789 {
15790 if(pMac->roam.tlStatsReqInfo.timerRunning)
15791 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015792 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15793 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015794 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015795 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015796 return eHAL_STATUS_FAILURE;
15797 }
15798 }
15799 pMac->roam.tlStatsReqInfo.periodicity = 0;
15800 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15801 }
15802 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015803 // Destroy the vos timer...
15804 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15805 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15806 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015807 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015808 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015809 csrRoamRemoveStatListEntry(pMac, pEntry);
15810 pStaEntry = NULL;
15811 return eHAL_STATUS_SUCCESS;
15812 }
15813 }
15814
15815 if(cache && !periodicity)
15816 {
15817 //return the cached stats
15818 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15819 }
15820 else
15821 {
15822 //add the request in the client req list
15823 staEntry.callback = callback;
15824 staEntry.pContext = pContext;
15825 staEntry.periodicity = periodicity;
15826 staEntry.pPeStaEntry = NULL;
15827 staEntry.staId = staId;
15828 staEntry.pMac = pMac;
15829 staEntry.timerExpired = FALSE;
15830
15831
Jeff Johnson295189b2012-06-20 16:38:30 -070015832 //if periodic report requested with non cached result from PE/TL
15833 if(periodicity)
15834 {
15835
15836 //if looking for stats from PE
15837 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15838 {
15839
15840 //check if same request made already & waiting for rsp
15841 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15842 periodicity, &found, staId);
15843 if(!pPeStaEntry)
15844 {
15845 //bail out, maxed out on number of req for PE
15846 return eHAL_STATUS_FAILURE;
15847 }
15848 else
15849 {
15850 staEntry.pPeStaEntry = pPeStaEntry;
15851 }
15852
15853 }
15854 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15855 if(statsMask & (1 << eCsrGlobalClassDStats))
15856 {
15857 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15858 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015859 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015860 }
15861 else
15862 {
15863
15864 //update periodicity
15865 if(pMac->roam.tlStatsReqInfo.periodicity)
15866 {
15867 pMac->roam.tlStatsReqInfo.periodicity =
15868 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15869 }
15870 else
15871 {
15872 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15873 }
15874 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15875 {
15876 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15877 }
15878
15879 if(!pMac->roam.tlStatsReqInfo.timerRunning)
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(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 Johnsone7245742012-09-05 17:12:55 -070015901
Jeff Johnson295189b2012-06-20 16:38:30 -070015902 if(pMac->roam.tlStatsReqInfo.periodicity)
15903 {
15904 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015905 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15906 pMac->roam.tlStatsReqInfo.periodicity);
15907 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015908 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015909 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015910 return eHAL_STATUS_FAILURE;
15911 }
15912 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15913 }
15914 }
15915 }
15916 pMac->roam.tlStatsReqInfo.numClient++;
15917 }
15918
15919 insertInClientList = TRUE;
15920 }
15921 //if one time report requested with non cached result from PE/TL
15922 else if(!cache && !periodicity)
15923 {
15924 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15925 {
15926 //send down a req
15927 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15928 if(!HAL_STATUS_SUCCESS(status))
15929 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015930 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015931 }
15932 //so that when the stats rsp comes back from PE we respond to upper layer
15933 //right away
15934 staEntry.timerExpired = TRUE;
15935 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015936 }
15937 if(statsMask & (1 << eCsrGlobalClassDStats))
15938 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015939 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015940 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015941 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015942 //req TL for class D stats
15943 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15944 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015945 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015946 }
15947 else
15948 {
15949 //save in SME
15950 csrRoamSaveStatsFromTl(pMac, pTlStats);
15951 }
15952 vos_mem_free(pTlStats);
15953 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015954 }
15955 else
15956 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015957 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015958 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015959
15960 }
15961 //if looking for stats from TL only
15962 if(!insertInClientList)
15963 {
15964 //return the stats
15965 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15966 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015967 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015968 if(insertInClientList)
15969 {
15970 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15971 if(!pStaEntry)
15972 {
15973 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015974 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015975 return eHAL_STATUS_FAILURE;
15976 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015977 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015978 //Init & start timer if needed
15979 if(periodicity)
15980 {
15981 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15982 csrRoamStatsClientTimerHandler, pStaEntry );
15983 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15984 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015985 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015986 return eHAL_STATUS_FAILURE;
15987 }
15988 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15989 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15990 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015991 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015992 return eHAL_STATUS_FAILURE;
15993 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015994 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015995 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015996 }
15997 return eHAL_STATUS_SUCCESS;
15998}
15999
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016000#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16001
16002static tSirRetStatus
16003csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
16004 tANI_U8* pBD,
16005 tANI_U8 type,
16006 tANI_U8 subType,
16007 tSirMacAddr peerAddr,
16008 tSirMacAddr selfMacAddr)
16009{
16010 tSirRetStatus statusCode = eSIR_SUCCESS;
16011 tpSirMacMgmtHdr pMacHdr;
16012
16013 /* Prepare MAC management header */
16014 pMacHdr = (tpSirMacMgmtHdr) (pBD);
16015
16016 /* Prepare FC */
16017 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
16018 pMacHdr->fc.type = type;
16019 pMacHdr->fc.subType = subType;
16020
16021 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053016022 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
16023 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016024
16025 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
16026
16027 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053016028 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
16029 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016030 return statusCode;
16031} /*** csrRoamScanOffloadPopulateMacHeader() ***/
16032
16033static tSirRetStatus
16034csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
16035 tANI_U8 nChannelNum,
16036 tANI_U32 dot11mode,
16037 tSirMacAddr selfMacAddr,
16038 tANI_U8 *pFrame,
16039 tANI_U16 *pusLen)
16040{
16041 tDot11fProbeRequest pr;
16042 tANI_U32 nStatus, nBytes, nPayload;
16043 tSirRetStatus nSirStatus;
16044 /*Bcast tx*/
16045 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
16046 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
16047
16048
Kiet Lam64c1b492013-07-12 13:56:44 +053016049 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016050
16051 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
16052
16053 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
16054 {
16055 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
16056 }
16057
16058
16059 if (IS_DOT11_MODE_HT(dot11mode))
16060 {
16061 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
16062 }
16063
16064
16065 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
16066 if ( DOT11F_FAILED( nStatus ) )
16067 {
16068 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16069 "Failed to calculate the packed size f"
16070 "or a Probe Request (0x%08x).\n", nStatus );
16071
16072
16073 nPayload = sizeof( tDot11fProbeRequest );
16074 }
16075 else if ( DOT11F_WARNED( nStatus ) )
16076 {
16077 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16078 "There were warnings while calculating"
16079 "the packed size for a Probe Request ("
16080 "0x%08x).\n", nStatus );
16081 }
16082
16083 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
16084
16085 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053016086 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016087
16088
16089 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016090 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016091
16092 if ( eSIR_SUCCESS != nSirStatus )
16093 {
16094 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16095 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
16096 nSirStatus );
16097 return nSirStatus;
16098 }
16099
16100
16101 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
16102 sizeof( tSirMacMgmtHdr ),
16103 nPayload, &nPayload );
16104 if ( DOT11F_FAILED( nStatus ) )
16105 {
16106 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16107 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
16108 return eSIR_FAILURE;
16109 }
16110 else if ( DOT11F_WARNED( nStatus ) )
16111 {
16112 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070016113 "There were warnings while packing a Probe Request (0x%08x).\n",
16114 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016115 }
16116
16117 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
16118 return eSIR_SUCCESS;
16119}
16120
16121eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
16122{
16123 vos_msg_t msg;
16124 tSirRoamOffloadScanReq *pRequestBuf;
16125 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
16126 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016127 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016128 tANI_U8 *ChannelList = NULL;
16129 tANI_U32 sessionId;
16130 eHalStatus status = eHAL_STATUS_SUCCESS;
16131 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070016132 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016133 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016134 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016135 tSirBssDescription *pBssDesc = NULL;
16136 tDot11fBeaconIEs *pIes = NULL;
16137 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080016138 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016139
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016140 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
16141
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070016142 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016143 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016144 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016145 return eHAL_STATUS_FAILURE;
16146 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016147
16148 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
16149 {
16150 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
16151 return eHAL_STATUS_FAILURE;
16152 }
Abhishek Singh3e915632014-11-01 17:14:50 +053016153
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016154 /*The Dynamic Config Items Update may happen even if the state is in INIT.
16155 * It is important to ensure that the command is passed down to the FW only
16156 * if the Infra Station is in a connected state.A connected station could also be
16157 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
16158 * We also have to ensure that if there is a STOP command we always have to inform Riva,
16159 * irrespective of whichever state we are in.*/
16160 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
16161 (command != ROAM_SCAN_OFFLOAD_STOP))
16162 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053016163 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
16164 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
16165 macTraceGetNeighbourRoamState(
16166 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016167 return eHAL_STATUS_FAILURE;
16168 }
16169
Abhishek Singh3e915632014-11-01 17:14:50 +053016170 /* We dont need psession during ROAM_SCAN_OFFLOAD_STOP
16171 * Also there are cases where pNeighborRoamInfo->currAPbssid
16172 * is set to 0 during disconnect and so we might return without stopping
16173 * the roam scan. So no need to find the session if command is
16174 * ROAM_SCAN_OFFLOAD_STOP.
16175 */
16176 if( ROAM_SCAN_OFFLOAD_STOP != command )
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016177 {
Abhishek Singh3e915632014-11-01 17:14:50 +053016178 status = csrRoamGetSessionIdFromBSSID(pMac,
16179 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
16180 &sessionId);
16181
16182 if ( !HAL_STATUS_SUCCESS( status ) )
16183 {
16184 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16185 "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
16186 return eHAL_STATUS_FAILURE;
16187 }
16188 pSession = CSR_GET_SESSION( pMac, sessionId );
16189 if (NULL == pSession)
16190 {
16191 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
krunal soni587bf012014-02-04 12:35:11 -080016192 "%s:pSession is null", __func__);
Abhishek Singh3e915632014-11-01 17:14:50 +053016193 return eHAL_STATUS_FAILURE;
16194 }
16195 pBssDesc = pSession->pConnectBssDesc;
16196 if (pBssDesc == NULL)
16197 {
16198 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16199 "%s: pBssDesc not found for current session", __func__);
16200 return eHAL_STATUS_FAILURE;
16201 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016202 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016203 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
16204 if (NULL == pRequestBuf)
16205 {
Abhishek Singh3e915632014-11-01 17:14:50 +053016206 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16207 "%s: Not able to allocate memory for Roam Offload scan request", __func__);
16208 return eHAL_STATUS_FAILED_ALLOC;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016209 }
16210
Abhishek Singh3e915632014-11-01 17:14:50 +053016211 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
16212 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
16213 * host driver reloads, but Riva still up and running*/
16214 pRequestBuf->Command = command;
16215 if(command == ROAM_SCAN_OFFLOAD_STOP)
16216 {
16217 pRequestBuf->RoamScanOffloadEnabled = 0;
16218 /*For a STOP Command, there is no need to
16219 * go through filling up all the below parameters
16220 * since they are not required for the STOP command*/
16221 goto send_roam_scan_offload_cmd;
16222 }
16223 else
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016224 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053016225 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
16226 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016227 sizeof(tCsrBssid));
16228 pRequestBuf->ConnectedNetwork.ssId.length =
16229 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
16230 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
16231 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
16232 pRequestBuf->ConnectedNetwork.ssId.length);
16233 pRequestBuf->ConnectedNetwork.authentication =
16234 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
16235 pRequestBuf->ConnectedNetwork.encryption =
16236 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
16237 pRequestBuf->ConnectedNetwork.mcencryption =
16238 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016239 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
16240 {
16241 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016242 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016243 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16244 }
16245 else
16246 {
16247 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
16248 operationChannel = pSession->connectedProfile.operationChannel;
16249
16250 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
16251 {
16252 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16253 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
16254 vos_mem_free(pRequestBuf);
16255 return eHAL_STATUS_FAILURE;
16256 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016257 if(NULL == pIes)
16258 {
16259 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16260 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053016261 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016262 return eHAL_STATUS_FAILURE;
16263 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016264 if (pIes->SuppRates.present)
16265 {
16266 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
16267 /*Check for both basic rates and extended rates.*/
16268 for (i = 0; i < pIes->SuppRates.num_rates; i++)
16269 {
16270 /*Check if the Rate is Mandatory or Not*/
16271 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
16272 && (pIes->SuppRates.rates[i] & 0x80))
16273 {
16274 /*Retrieve the actual data rate*/
16275 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
16276 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16277 if (minRate == 0)
16278 minRate = dataRate;
16279 else
16280 minRate = (minRate < dataRate) ? minRate:dataRate;
16281 }
16282 }
16283
16284 if (pIes->ExtSuppRates.present)
16285 {
16286 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
16287 {
16288 /*Check if the Rate is Mandatory or Not*/
16289 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
16290 && (pIes->ExtSuppRates.rates[i] & 0x80))
16291 {
16292 /*Retrieve the actual data rate*/
16293 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
16294 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16295 if (minRate == 0)
16296 minRate = dataRate;
16297 else
16298 minRate = (minRate < dataRate) ? minRate:dataRate;
16299 }
16300 }
16301 }
16302 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
16303 }
16304 else
16305 {
16306 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16307 "%s: Supp Rates not present in pIes", __func__);
16308 vos_mem_free(pRequestBuf);
16309 return eHAL_STATUS_FAILURE;
16310 }
16311 if (NULL != pIes)
16312 {
16313 vos_mem_free(pIes);
16314 pIes = NULL;
16315 }
16316 switch (minRate)
16317 {
16318 case 1:
16319 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
16320 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
16321 break;
16322 case 2:
16323 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
16324 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
16325 break;
16326 case 5:
16327 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
16328 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
16329 break;
16330 case 6:
16331 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16332 {
16333 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
16334 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
16335 }
16336 else
16337 {
16338 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
16339 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
16340 }
16341 break;
16342 case 11:
16343 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
16344 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
16345 break;
16346 case 12:
16347 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16348 {
16349 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
16350 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
16351 }
16352 else
16353 {
16354 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
16355 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
16356 }
16357 break;
16358 case 24:
16359 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16360 {
16361 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
16362 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
16363 }
16364 else
16365 {
16366 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
16367 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
16368 }
16369 break;
16370 default:
16371 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
16372 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16373 break;
16374 }
16375 }
16376 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16377 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
16378 operationChannel, minRate,
16379 pRequestBuf->RxSensitivityThreshold,
16380 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016381 pRequestBuf->RoamRssiDiff =
16382 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016383 pRequestBuf->StartScanReason = reason;
16384 pRequestBuf->NeighborScanTimerPeriod =
16385 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
16386 pRequestBuf->NeighborRoamScanRefreshPeriod =
16387 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
16388 pRequestBuf->NeighborScanChannelMinTime =
16389 pNeighborRoamInfo->cfgParams.minChannelScanTime;
16390 pRequestBuf->NeighborScanChannelMaxTime =
16391 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
16392 pRequestBuf->EmptyRefreshScanPeriod =
16393 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080016394 /* MAWC feature */
16395 pRequestBuf->MAWCEnabled =
16396 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016397#ifdef FEATURE_WLAN_ESE
16398 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016399#endif
16400 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016401#ifdef FEATURE_WLAN_ESE
16402 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016403 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
16404 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016405 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
16406#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016407 currChannelListInfo->numOfChannels == 0)
16408 {
16409
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016410 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
16411 * Give Preference to INI Channels.*/
16412 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
16413 {
16414 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
16415 /*The INI channels need to be filtered with respect to the current
16416 * band that is supported.*/
16417 eBand = pMac->roam.configParam.bandCapability;
16418 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016419 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016420 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16421 "Invalid band, No operation carried out (Band %d)", eBand);
16422 vos_mem_free(pRequestBuf);
16423 return eHAL_STATUS_FAILURE;
16424 }
16425 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
16426 {
16427 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
16428 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
16429 (eCSR_BAND_ALL == eBand))
16430 {
16431 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
16432 csrRoamIsChannelValid(pMac, *ChannelList) &&
16433 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16434 {
16435 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16436 }
16437 }
16438 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016439 }
16440 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16441 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016442 }
16443 else
16444 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016445 ChannelList = pMac->scan.occupiedChannels.channelList;
16446 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
16447 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016448 /*Allow DFS channels only if the DFS channel roam flag is enabled */
16449 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16450 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016451 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16452 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016453 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016454 }
16455 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016456 }
16457 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16458 /* If the profile changes as to what it was earlier, inform the FW through
16459 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
16460 * for the earlier profile and try to learn them afresh.*/
16461 if (reason == REASON_FLUSH_CHANNEL_LIST)
16462 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16463 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016464 if (csrNeighborRoamIsNewConnectedProfile(pMac))
16465 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16466 else
16467 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016468 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016469 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016470 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016471#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016472 else
16473 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016474 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016475 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016476 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016477 if (currChannelListInfo->numOfChannels != 0)
16478 {
16479 ChannelList = currChannelListInfo->ChannelList;
16480 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016481 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016482 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16483 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016484 {
16485 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16486 }
16487 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016488 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016489 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16490 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16491 }
16492 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016493#endif
Kaushik, Sushant5ed8ab62014-03-05 11:21:11 +053016494 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0])) && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016495 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016496 if (j < sizeof(ChannelCacheStr))
16497 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016498 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
16499 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016500 }
16501 else
16502 {
16503 break;
16504 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016505 }
16506 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16507 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
16508 pRequestBuf->ChannelCacheType,
16509 pRequestBuf->ConnectedNetwork.ChannelCount,
16510 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016511 num_channels = 0;
16512 ChannelList = NULL;
16513
16514 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070016515 host_channels = sizeof(pMac->roam.validChannelList);
16516 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016517 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070016518 ChannelList = pMac->roam.validChannelList;
16519 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016520 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070016521 else
16522 {
16523 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16524 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070016525 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070016526 return eHAL_STATUS_FAILURE;
16527 }
16528 for(i=0; i<pMac->roam.numValidChannels; i++)
16529 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016530 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16531 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Srinivas Girigowda56076852013-08-20 14:00:50 -070016532 {
16533 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
16534 }
16535 ChannelList++;
16536 }
16537 pRequestBuf->ValidChannelCount = num_channels;
16538
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016539 pRequestBuf->MDID.mdiePresent =
16540 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16541 pRequestBuf->MDID.mobilityDomain =
16542 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016543 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16544
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016545 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016546 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16547 * where RFS is the RF Switching time. It is twice RFS to consider the
16548 * time to go off channel and return to the home channel. */
16549 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16550 {
16551 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16552 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16553 " Hence enforcing home away time to disable (0)",
16554 __func__, pRequestBuf->HomeAwayTime,
16555 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16556 pRequestBuf->HomeAwayTime = 0;
16557 }
16558 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016559
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016560 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16561 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16562 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16563 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16564 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16565
16566 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16567 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016568send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016569 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016570 msg.reserved = 0;
16571 msg.bodyptr = pRequestBuf;
16572 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16573 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016574 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16575 vos_mem_free(pRequestBuf);
16576 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016577 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016578 else
16579 {
16580 if (ROAM_SCAN_OFFLOAD_START == command)
16581 bRoamScanOffloadStarted = VOS_TRUE;
16582 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16583 bRoamScanOffloadStarted = VOS_FALSE;
16584 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016585
16586 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16587 return status;
16588}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016589
16590eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16591{
16592 switch(reason)
16593 {
16594 case 0:
16595 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16596 break;
16597 case REASON_OS_REQUESTED_ROAMING_NOW:
16598 csrNeighborRoamProceedWithHandoffReq(pMac);
16599 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053016600 case REASON_INITIAL_FORCED_ROAM_TO_5G:
16601 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
16602 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016603 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016604 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 -070016605 }
16606 return eHAL_STATUS_SUCCESS;
16607}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016608#endif
16609
Jeff Johnson295189b2012-06-20 16:38:30 -070016610tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16611 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16612{
16613 tANI_BOOLEAN found = FALSE;
16614 eHalStatus status = eHAL_STATUS_SUCCESS;
16615 tCsrPeStatsReqInfo staEntry;
16616 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16617 tListElem *pStaEntry = NULL;
16618 VOS_STATUS vosStatus;
16619 tPmcPowerState powerState;
16620 *pFound = FALSE;
16621
16622 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16623 if(pStaEntry)
16624 {
16625 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16626 if(pTempStaEntry->periodicity)
16627 {
16628 pTempStaEntry->periodicity =
16629 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16630 }
16631 else
16632 {
16633 pTempStaEntry->periodicity = periodicity;
16634 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016635 pTempStaEntry->numClient++;
16636 found = TRUE;
16637 }
16638 else
16639 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016640 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016641 staEntry.numClient = 1;
16642 staEntry.periodicity = periodicity;
16643 staEntry.pMac = pMac;
16644 staEntry.rspPending = FALSE;
16645 staEntry.staId = staId;
16646 staEntry.statsMask = statsMask;
16647 staEntry.timerRunning = FALSE;
16648 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16649 if(!pTempStaEntry)
16650 {
16651 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016652 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016653 return NULL;
16654 }
16655 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016656 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16657 if(ePMC_FULL_POWER == powerState)
16658 {
16659 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16660 {
16661 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16662 }
16663 }
16664 else
16665 {
16666 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16667 {
16668 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16669 }
16670 }
16671 if(!pTempStaEntry->timerRunning)
16672 {
16673 //send down a req in case of one time req, for periodic ones wait for timer to expire
16674 if(!pTempStaEntry->rspPending &&
16675 !pTempStaEntry->periodicity)
16676 {
16677 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16678 if(!HAL_STATUS_SUCCESS(status))
16679 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016680 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016681 }
16682 else
16683 {
16684 pTempStaEntry->rspPending = TRUE;
16685 }
16686 }
16687 if(pTempStaEntry->periodicity)
16688 {
16689 if(!found)
16690 {
16691
16692 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16693 csrRoamPeStatsTimerHandler, pTempStaEntry );
16694 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16695 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016696 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016697 return NULL;
16698 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016699 }
16700 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016701 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016702 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16703 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16704 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016705 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016706 return NULL;
16707 }
16708 pTempStaEntry->timerRunning = TRUE;
16709 }
16710 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016711 *pFound = found;
16712 return pTempStaEntry;
16713}
16714
Jeff Johnson295189b2012-06-20 16:38:30 -070016715/*
16716 pStaEntry is no longer invalid upon the return of this function.
16717*/
16718static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16719{
16720 if(pEntry)
16721 {
16722 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16723 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016724 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016725 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016726 }
16727 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016728
16729void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16730{
16731 tListElem *pEntry;
16732 tCsrPeStatsReqInfo *pTempStaEntry;
16733 VOS_STATUS vosStatus;
16734 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016735 if(!pEntry)
16736 {
16737 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016738 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016739 return;
16740 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016741 while( pEntry )
16742 {
16743 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016744 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16745 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016746 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016747 if(pTempStaEntry->timerRunning)
16748 {
16749 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16750 /* If we are not able to stop the timer here, just remove
16751 * the entry from the linked list. Destroy the timer object
16752 * and free the memory in the timer CB
16753 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016754 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016755 {
16756 /* the timer is successfully stopped */
16757 pTempStaEntry->timerRunning = FALSE;
16758
16759 /* Destroy the timer */
16760 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16761 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16762 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016763 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016764 }
16765 }
16766 else
16767 {
16768 // the timer could not be stopped. Hence destroy and free the
16769 // memory for the PE stat entry in the timer CB.
16770 pTempStaEntry->timerStopFailed = TRUE;
16771 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016772 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016773
16774 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16775 {
16776 // Only free the memory if we could stop the timer successfully
16777 if(!pTempStaEntry->timerStopFailed)
16778 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016779 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016780 pTempStaEntry = NULL;
16781 }
16782 break;
16783 }
16784
16785 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16786 }
16787 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016788 return;
16789}
16790
16791
Jeff Johnsone7245742012-09-05 17:12:55 -070016792void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016793{
16794
Jeff Johnsone7245742012-09-05 17:12:55 -070016795 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16796 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16797 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16798 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16799 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16800 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16801 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016802 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016803 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16804 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16805 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16806 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16807 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16808 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016809 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016810 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16811 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016812
16813}
16814
Jeff Johnson295189b2012-06-20 16:38:30 -070016815void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16816 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16817{
16818 tANI_U8 stats[500];
16819 tANI_U8 *pStats = NULL;
16820 tANI_U32 tempMask = 0;
16821 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016822 if(!callback)
16823 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016824 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016825 return;
16826 }
16827 if(!statsMask)
16828 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016829 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016830 return;
16831 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016832 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016833 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016834 while(tempMask)
16835 {
16836 if(tempMask & 1)
16837 {
16838 //new stats info from PE, fill up the stats strucutres in PMAC
16839 switch(counter)
16840 {
16841 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016842 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016843 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16844 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016845 pStats += sizeof(tCsrSummaryStatsInfo);
16846 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016847 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016848 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016849 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16850 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016851 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016852 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016853 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016854 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016855 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16856 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016857 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016858 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016859 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016860 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016861 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16862 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016863 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016864 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016865 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016866 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016867 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16868 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016869 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016870 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016871 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016872 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016873 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16874 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016875 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016876 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016877 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016878 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016879 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016880 }
16881 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016882 tempMask >>=1;
16883 counter++;
16884 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016885 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016886}
16887
Jeff Johnson295189b2012-06-20 16:38:30 -070016888eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16889{
16890 tListElem *pEntry = NULL;
16891 tListElem *pPrevEntry = NULL;
16892 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16893 eHalStatus status = eHAL_STATUS_SUCCESS;
16894 VOS_STATUS vosStatus;
16895 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016896 if(!pEntry)
16897 {
16898 //list empty
16899 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016900 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016901 return status;
16902 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016903 while( pEntry )
16904 {
16905 if(pPrevEntry)
16906 {
16907 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16908 //send up the stats report
16909 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16910 pTempStaEntry->staId, pTempStaEntry->pContext);
16911 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16912 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016913 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016914 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16915 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016916 pTempStaEntry->pPeStaEntry->numClient--;
16917 //check if we need to delete the entry from peStatsReqList too
16918 if(!pTempStaEntry->pPeStaEntry->numClient)
16919 {
16920 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16921 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016922 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016923 //check if we need to stop the tl stats timer too
16924 pMac->roam.tlStatsReqInfo.numClient--;
16925 if(!pMac->roam.tlStatsReqInfo.numClient)
16926 {
16927 if(pMac->roam.tlStatsReqInfo.timerRunning)
16928 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016929 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16930 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016931 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016932 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016933 //we will continue
16934 }
16935 }
16936 pMac->roam.tlStatsReqInfo.periodicity = 0;
16937 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16938 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016939 if (pTempStaEntry->periodicity)
16940 {
16941 //While creating StaEntry in csrGetStatistics,
16942 //Initializing and starting timer only when periodicity is set.
16943 //So Stop and Destroy timer only when periodicity is set.
16944
Jeff Johnsone7245742012-09-05 17:12:55 -070016945 vos_timer_stop( &pTempStaEntry->timer );
16946 // Destroy the vos timer...
16947 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16948 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16949 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016950 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016951 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016952 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016953
Jeff Johnson295189b2012-06-20 16:38:30 -070016954
16955 pPrevEntry = pEntry;
16956 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16957 }
16958 //the last one
16959 if(pPrevEntry)
16960 {
16961 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16962 //send up the stats report
16963 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16964 pTempStaEntry->staId, pTempStaEntry->pContext);
16965 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16966 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016967 return status;
16968
16969}
16970
Jeff Johnson295189b2012-06-20 16:38:30 -070016971eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16972 tRequestFullPowerReason *pReason,
16973 tANI_BOOLEAN *pfNeedPower )
16974{
16975 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16976 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16977 tPmcState pmcState;
16978 eHalStatus status = eHAL_STATUS_SUCCESS;
16979 // TODO : Session info unavailable
16980 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016981 if( pfNeedPower )
16982 {
16983 *pfNeedPower = eANI_BOOLEAN_FALSE;
16984 }
16985 //We only handle CSR commands
16986 if( !(eSmeCsrCommandMask & pCommand->command) )
16987 {
16988 return eHAL_STATUS_SUCCESS;
16989 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016990 //Check PMC state first
16991 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016992 switch( pmcState )
16993 {
16994 case REQUEST_IMPS:
16995 case IMPS:
16996 if( eSmeCommandScan == pCommand->command )
16997 {
16998 switch( pCommand->u.scanCmd.reason )
16999 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017000#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17001 case eCsrScanGetLfrResult:
17002#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017003 case eCsrScanGetResult:
17004 case eCsrScanBGScanAbort:
17005 case eCsrScanBGScanEnable:
17006 case eCsrScanGetScanChnInfo:
17007 //Internal process, no need for full power
17008 fNeedFullPower = eANI_BOOLEAN_FALSE;
17009 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017010 default:
17011 //Other scans are real scan, ask for power
17012 fNeedFullPower = eANI_BOOLEAN_TRUE;
17013 break;
17014 } //switch
17015 }
17016 else
17017 {
17018 //ask for power for roam and status change
17019 fNeedFullPower = eANI_BOOLEAN_TRUE;
17020 }
17021 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017022 case REQUEST_BMPS:
17023 case BMPS:
17024 case REQUEST_START_UAPSD:
17025 case UAPSD:
17026 //We treat WOWL same as BMPS
17027 case REQUEST_ENTER_WOWL:
17028 case WOWL:
17029 if( eSmeCommandRoam == pCommand->command )
17030 {
17031 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
17032 tCsrScanResult *pScanResult;
17033 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070017034 switch ( pCommand->u.roamCmd.roamReason )
17035 {
17036 case eCsrForcedDisassoc:
17037 case eCsrForcedDisassocMICFailure:
17038 reason = eSME_LINK_DISCONNECTED_BY_HDD;
17039 fNeedFullPower = eANI_BOOLEAN_TRUE;
17040 break;
17041 case eCsrSmeIssuedDisassocForHandoff:
17042 case eCsrForcedDeauth:
17043 case eCsrHddIssuedReassocToSameAP:
17044 case eCsrSmeIssuedReassocToSameAP:
17045 fNeedFullPower = eANI_BOOLEAN_TRUE;
17046 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017047 case eCsrCapsChange:
17048 fNeedFullPower = eANI_BOOLEAN_TRUE;
17049 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017050 default:
17051 //Check whether the profile is already connected. If so, no need for full power
17052 //Note: IBSS is ignored for now because we don't support powersave in IBSS
17053 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
17054 {
17055 //Only need to check the first one
17056 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
17057 if( pEntry )
17058 {
17059 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
17060#if 0
17061 // TODO : Session Specific info pConnectBssDesc
17062 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
17063 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
17064 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
17065 {
17066 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
17067 // with Authenticating first. To force this, stop the current association (Disassociate) and
17068 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
17069 // a new Association.
17070 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
17071 {
17072 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
17073 {
17074 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
17075 //No need for full power
17076 //Set the flag so the code later can avoid to do the above
17077 //check again.
17078 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
17079 break;
17080 }
17081 }
17082 }
17083#endif
17084 }
17085 }
17086 //If we are here, full power is needed
17087 fNeedFullPower = eANI_BOOLEAN_TRUE;
17088 break;
17089 }
17090 }
17091 else if( eSmeCommandWmStatusChange == pCommand->command )
17092 {
17093 //need full power for all
17094 fNeedFullPower = eANI_BOOLEAN_TRUE;
17095 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
17096 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080017097#ifdef FEATURE_WLAN_TDLS
17098 else if( eSmeCommandTdlsAddPeer == pCommand->command )
17099 {
17100 //TDLS link is getting established. need full power
17101 fNeedFullPower = eANI_BOOLEAN_TRUE;
17102 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
17103 }
17104#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017105 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017106 case REQUEST_STOP_UAPSD:
17107 case REQUEST_EXIT_WOWL:
17108 if( eSmeCommandRoam == pCommand->command )
17109 {
17110 fNeedFullPower = eANI_BOOLEAN_TRUE;
17111 switch ( pCommand->u.roamCmd.roamReason )
17112 {
17113 case eCsrForcedDisassoc:
17114 case eCsrForcedDisassocMICFailure:
17115 reason = eSME_LINK_DISCONNECTED_BY_HDD;
17116 break;
17117 default:
17118 break;
17119 }
17120 }
17121 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017122 case STOPPED:
17123 case REQUEST_STANDBY:
17124 case STANDBY:
17125 case LOW_POWER:
17126 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053017127 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
17128 " stopped/standby state %s (%d)" ),
17129 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070017130 status = eHAL_STATUS_FAILURE;
17131 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017132 case FULL_POWER:
17133 case REQUEST_FULL_POWER:
17134 default:
17135 //No need to ask for full power. This has to be FULL_POWER state
17136 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017137 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070017138 if( pReason )
17139 {
17140 *pReason = reason;
17141 }
17142 if( pfNeedPower )
17143 {
17144 *pfNeedPower = fNeedFullPower;
17145 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017146 return ( status );
17147}
17148
Jeff Johnson295189b2012-06-20 16:38:30 -070017149static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
17150{
17151 eHalStatus status = eHAL_STATUS_SUCCESS;
17152 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
17153 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070017154 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070017155 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
17156 {
17157 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
17158 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017159 return ( status );
17160}
17161
Jeff Johnson295189b2012-06-20 16:38:30 -070017162tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
17163{
17164 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070017165 if( pCmd )
17166 {
17167 pMac->roam.sPendingCommands++;
17168 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017169 return ( pCmd );
17170}
17171
Jeff Johnson295189b2012-06-20 16:38:30 -070017172void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
17173{
17174 if (pMac->roam.sPendingCommands > 0)
17175 {
17176 //All command allocated through csrGetCommandBuffer need to
17177 //decrement the pending count when releasing.
17178 pMac->roam.sPendingCommands--;
17179 smeReleaseCommand( pMac, pCommand );
17180 }
17181 else
17182 {
17183 smsLog(pMac, LOGE, FL( "no pending commands"));
17184 VOS_ASSERT(0);
17185 }
17186}
17187
Jeff Johnson295189b2012-06-20 16:38:30 -070017188//Return SUCCESS is the command is queued, failed
17189eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
17190{
17191 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017192 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
17193 {
17194 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
17195 pCommand->u.scanCmd.reason);
17196 return eHAL_STATUS_CSR_WRONG_STATE;
17197 }
17198
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017199 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
17200 {
17201 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
17202 &pCommand->Link, LL_ACCESS_LOCK);
17203 // process the command queue...
17204 smeProcessPendingQueue(pMac);
17205 status = eHAL_STATUS_SUCCESS;
17206 goto end;
17207 }
17208
Jeff Johnson295189b2012-06-20 16:38:30 -070017209 //We can call request full power first before putting the command into pending Q
17210 //because we are holding SME lock at this point.
17211 status = csrRequestFullPower( pMac, pCommand );
17212 if( HAL_STATUS_SUCCESS( status ) )
17213 {
17214 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070017215 //make sure roamCmdPendingList is not empty first
17216 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
17217 if( fNoCmdPending )
17218 {
17219 smePushCommand( pMac, pCommand, fHighPriority );
17220 }
17221 else
17222 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017223 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070017224 //no list lock is needed since SME lock is held
17225 if( !fHighPriority )
17226 {
17227 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17228 }
17229 else {
17230 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17231 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017232 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017233 }
17234 else if( eHAL_STATUS_PMC_PENDING == status )
17235 {
17236 //no list lock is needed since SME lock is held
17237 if( !fHighPriority )
17238 {
17239 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17240 }
17241 else {
17242 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17243 }
17244 //Let caller know the command is queue
17245 status = eHAL_STATUS_SUCCESS;
17246 }
17247 else
17248 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017249 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070017250 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017251 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070017252 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017253end:
Jeff Johnson295189b2012-06-20 16:38:30 -070017254 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070017255}
Jeff Johnson295189b2012-06-20 16:38:30 -070017256eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
17257{
17258 eHalStatus status = eHAL_STATUS_SUCCESS;
17259 tSirUpdateAPWPSIEsReq *pMsg;
17260 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
17261
17262 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17263 if (NULL == pSession)
17264 {
17265 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17266 return eHAL_STATUS_FAILURE;
17267 }
17268
Jeff Johnson295189b2012-06-20 16:38:30 -070017269 do
17270 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017271 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
17272 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17273 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017274 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
17275
17276 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070017277 VOS_ASSERT(pBuf);
17278
Jeff Johnson295189b2012-06-20 16:38:30 -070017279 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017280 // transactionId
17281 *pBuf = 0;
17282 *( pBuf + 1 ) = 0;
17283 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070017284 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017285 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17286 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017287 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017288 //sessionId
17289 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017290 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017291 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070017292 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070017293 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017294 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017295 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017296 return ( status );
17297}
Jeff Johnson295189b2012-06-20 16:38:30 -070017298eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
17299{
17300 eHalStatus status = eHAL_STATUS_SUCCESS;
17301 tSirUpdateAPWPARSNIEsReq *pMsg;
17302 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017303 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17304 if (NULL == pSession)
17305 {
17306 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17307 return eHAL_STATUS_FAILURE;
17308 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017309 do
17310 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017311 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
17312 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17313 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017314 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070017315 pBuf = (tANI_U8 *)&pMsg->transactionId;
17316 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017317 // transactionId
17318 *pBuf = 0;
17319 *( pBuf + 1 ) = 0;
17320 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070017321 VOS_ASSERT(pBuf);
17322
Jeff Johnson295189b2012-06-20 16:38:30 -070017323 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017324 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17325 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017326 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017327 // sessionId
17328 *pBuf++ = (tANI_U8)sessionId;
17329
17330 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017331 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070017332 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070017333 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017334 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017335 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017336 return ( status );
17337}
Jeff Johnson295189b2012-06-20 16:38:30 -070017338
17339#ifdef WLAN_FEATURE_VOWIFI_11R
17340//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
17341eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
17342{
17343 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17344 tpSirFTPreAuthReq pftPreAuthReq;
17345 tANI_U16 auth_req_len = 0;
17346 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017347 auth_req_len = sizeof(tSirFTPreAuthReq);
17348 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053017349 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070017350 {
17351 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
17352 return eHAL_STATUS_RESOURCES;
17353 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017354 // Save the SME Session ID here. We need it while processing the preauth response
17355 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017356 vos_mem_zero(pftPreAuthReq, auth_req_len);
17357
17358 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
17359 sizeof(pBssDescription->length) + pBssDescription->length);
17360
17361 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
17362
17363 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
17364
Kiet Lam64c1b492013-07-12 13:56:44 +053017365 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
17366 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
17367 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
17368 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017369
Jeff Johnson295189b2012-06-20 16:38:30 -070017370#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080017371 if (csrRoamIs11rAssoc(pMac) &&
17372 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070017373 {
17374 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053017375 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
17376 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070017377 }
17378 else
17379#endif
17380 {
17381 pftPreAuthReq->ft_ies_length = 0;
17382 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070017383 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
17384 sizeof(pBssDescription->length) + pBssDescription->length);
17385 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070017386 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
17387}
Jeff Johnson295189b2012-06-20 16:38:30 -070017388/*--------------------------------------------------------------------------
17389 * This will receive and process the FT Pre Auth Rsp from the current
17390 * associated ap.
17391 *
17392 * This will invoke the hdd call back. This is so that hdd can now
17393 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
17394 ------------------------------------------------------------------------*/
17395void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
17396{
17397 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17398 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017399#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017400 tCsrRoamInfo roamInfo;
17401#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017402 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070017403
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017404#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080017405 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017406 if (status != eHAL_STATUS_SUCCESS) {
17407 /*
17408 * Bail out if pre-auth was not even processed.
17409 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017410 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
17411 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017412 return;
17413 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017414#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017415 /* The below function calls/timers should be invoked only if the pre-auth is successful */
17416 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
17417 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070017418 // Implies a success
17419 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017420 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
17421 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053017422 /* No need to notify qos module if this is a non 11r & ESE roam*/
17423 if (csrRoamIs11rAssoc(pMac)
17424#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
17425 || csrRoamIsESEAssoc(pMac)
17426#endif
17427 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070017428 {
17429 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
17430 }
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053017431#ifdef DEBUG_ROAM_DELAY
17432 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
17433#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017434 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
17435 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017436 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
17437 60);
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053017438#ifdef DEBUG_ROAM_DELAY
17439 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
17440#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017441 if (eHAL_STATUS_SUCCESS != status)
17442 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017443 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017444 return;
17445 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017446 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017447 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
17448 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070017449 if (csrRoamIs11rAssoc(pMac))
17450 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
17451 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
17452
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017453#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
17454 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017455 {
17456 /* read TSF */
17457 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
17458
17459 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017460 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017461 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
17462 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017463#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017464#ifdef FEATURE_WLAN_LFR
17465 // If Legacy Fast Roaming is enabled, signal the supplicant
17466 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053017467 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017468 {
17469 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017470 vos_mem_copy((void *)&roamInfo.bssid,
17471 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017472 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
17473 }
17474
17475#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017476
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017477 // If its an Open Auth, FT IEs are not provided by supplicant
17478 // Hence populate them here
17479 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
17480 pMac->ft.ftSmeContext.addMDIE = FALSE;
17481 if( csrRoamIs11rAssoc(pMac) &&
17482 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
17483 {
17484 tANI_U16 ft_ies_length;
17485 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
17486
17487 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
17488 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
17489 {
17490 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
17491 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
17492 }
17493
17494 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
17495 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
17496 {
17497 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
17498 }
17499 else
17500 {
17501 // Copy the RIC IEs to reassoc IEs
17502 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
17503 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
17504 pFTPreAuthRsp->ric_ies_length);
17505 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
17506 pMac->ft.ftSmeContext.addMDIE = TRUE;
17507 }
17508 }
17509
Jeff Johnson295189b2012-06-20 16:38:30 -070017510 // Done with it, init it.
17511 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
17512}
17513#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017514
Jeff Johnson295189b2012-06-20 16:38:30 -070017515#ifdef FEATURE_WLAN_BTAMP_UT_RF
17516void csrRoamJoinRetryTimerHandler(void *pv)
17517{
17518 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
17519 tpAniSirGlobal pMac = pInfo->pMac;
17520 tANI_U32 sessionId = pInfo->sessionId;
17521 tCsrRoamSession *pSession;
17522
17523 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17524 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017525 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017526 pSession = CSR_GET_SESSION( pMac, sessionId );
17527 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
17528 {
17529 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
17530 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017531 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017532 }
17533 }
17534 }
17535}
Jeff Johnson295189b2012-06-20 16:38:30 -070017536eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
17537{
17538 eHalStatus status = eHAL_STATUS_FAILURE;
17539 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17540
17541 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
17542 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017543 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070017544 pSession->maxRetryCount--;
17545 pSession->joinRetryTimerInfo.pMac = pMac;
17546 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017547 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
17548 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017549 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017550 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017551 }
17552 }
17553 else
17554 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017555 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070017556 pSession->maxRetryCount);
17557 }
17558
17559 return (status);
17560}
Jeff Johnson295189b2012-06-20 16:38:30 -070017561eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
17562{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017563 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070017564 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17565 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017566 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070017567 }
17568
17569 return eHAL_STATUS_SUCCESS;
17570}
17571#endif
17572
17573
17574/*
17575 pBuf points to the beginning of the message
17576 LIM packs disassoc rsp as below,
17577 messageType - 2 bytes
17578 messageLength - 2 bytes
17579 sessionId - 1 byte
17580 transactionId - 2 bytes (tANI_U16)
17581 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17582 peerMacAddr - 6 bytes
17583 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17584*/
17585static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
17586{
17587 if(pBuf && pRsp)
17588 {
17589 pBuf += 4; //skip type and length
17590 pRsp->sessionId = *pBuf++;
17591 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
17592 pBuf += 2;
17593 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
17594 pBuf += 4;
17595 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17596 }
17597}
17598
Jeff Johnsond13512a2012-07-17 11:42:19 -070017599eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17600{
17601 static uNvTables nvTables;
17602 eHalStatus status = eHAL_STATUS_SUCCESS;
17603 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17604
17605 /* read the country code from NV and use it */
17606 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17607 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017608 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17609 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017610 return status;
17611 }
17612 else
17613 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017614 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017615 status = eHAL_STATUS_FAILURE;
17616 return status;
17617 }
17618}
17619
17620eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17621{
Kiet Lam64c1b492013-07-12 13:56:44 +053017622 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017623 return eHAL_STATUS_SUCCESS;
17624}
schang86c22c42013-03-13 18:41:24 -070017625
17626eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17627{
17628 tSirSetTxPowerReq *pMsg = NULL;
17629 eHalStatus status = eHAL_STATUS_SUCCESS;
17630 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17631
17632 if (!pSession)
17633 {
17634 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17635 return eHAL_STATUS_FAILURE;
17636 }
17637
Kiet Lam64c1b492013-07-12 13:56:44 +053017638 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17639 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17640 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17641 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17642 pMsg->length = sizeof(tSirSetTxPowerReq);
17643 pMsg->mwPower = mW;
17644 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17645 sizeof(tSirMacAddr));
17646 status = palSendMBMessage(pMac->hHdd, pMsg);
17647 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017648 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017649 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17650 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017651 }
17652 return status;
17653}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017654
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017655eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
17656{
17657 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
17658 eHalStatus status = eHAL_STATUS_SUCCESS;
17659 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17660
17661 if (!pSession)
17662 {
17663 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17664 return eHAL_STATUS_FAILURE;
17665 }
17666 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
17667 {
17668 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053017669
17670 if( NULL == pMsg )
17671 {
17672 smsLog(pMac, LOGE, FL("PMsg is NULL "));
17673 return eHAL_STATUS_FAILURE;
17674 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017675 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
17676 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
17677 pMsg->length = sizeof(tANI_U8);
17678 pMsg->seesionId = sessionId;
17679 status = palSendMBMessage(pMac->hHdd, pMsg);
17680 if (!HAL_STATUS_SUCCESS(status))
17681 {
17682 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
17683 //pMsg is freed by palSendMBMessage
17684 }
17685 }
17686 else
17687 {
17688 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
17689 status = eHAL_STATUS_FAILURE;
17690 }
17691 return status;
17692}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017693/* Returns whether a session is in VOS_STA_MODE...or not */
17694tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17695{
17696 tCsrRoamSession *pSession = NULL;
17697 pSession = CSR_GET_SESSION ( pMac, sessionId );
17698 if(!pSession)
17699 {
17700 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17701 return eANI_BOOLEAN_FALSE;
17702 }
17703 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17704 {
17705 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17706 return eANI_BOOLEAN_FALSE;
17707 }
17708 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17709 {
17710 return eANI_BOOLEAN_FALSE;
17711 }
17712 /* There is a possibility that the above check may fail,because
17713 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17714 * when it is connected.So,we may sneak through the above check even
17715 * if we are not a STA mode INFRA station. So, if we sneak through
17716 * the above condition, we can use the following check if we are
17717 * really in STA Mode.*/
17718
17719 if ( NULL != pSession->pCurRoamProfile )
17720 {
17721 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17722 {
17723 return eANI_BOOLEAN_TRUE;
17724 } else {
17725 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17726 return eANI_BOOLEAN_FALSE;
17727 }
17728 }
17729
17730 return eANI_BOOLEAN_FALSE;
17731}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017732
17733#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17734eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17735 tCsrHandoffRequest *pHandoffInfo)
17736{
17737 eHalStatus status = eHAL_STATUS_SUCCESS;
17738 vos_msg_t msg;
17739
17740 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017741 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17742 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017743 {
17744 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017745 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017746 }
17747 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17748 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17749 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17750 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017751 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017752 pHandoffInfo->bssid,
17753 6);
17754 msg.type = eWNI_SME_HANDOFF_REQ;
17755 msg.bodyptr = pMsg;
17756 msg.reserved = 0;
17757 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17758 {
17759 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017760 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017761 status = eHAL_STATUS_FAILURE;
17762 }
17763 return status;
17764}
17765#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017766
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017767
17768#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017769/* ---------------------------------------------------------------------------
17770 \fn csrSetCCKMIe
17771 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17772 data structure and this IE will be packed inside reassociation request
17773 \param pMac - pMac global structure
17774 \param sessionId - Current session id
17775 \param pCckmIe - pointer to CCKM IE data
17776 \param ccKmIeLen - length of the CCKM IE
17777 \- return Success or failure
17778 -------------------------------------------------------------------------*/
17779VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17780 const tANI_U8 *pCckmIe,
17781 const tANI_U8 ccKmIeLen)
17782{
17783 eHalStatus status = eHAL_STATUS_SUCCESS;
17784 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17785
17786 if (!pSession)
17787 {
17788 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17789 return eHAL_STATUS_FAILURE;
17790 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017791 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017792 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17793 return status;
17794}
17795
17796/* ---------------------------------------------------------------------------
17797 \fn csrRoamReadTSF
17798 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17799 probe response reception from the hand off AP to arrive at the latest TSF value.
17800 \param pMac - pMac global structure
17801 \param pTimestamp - output TSF timestamp
17802 \- return Success or failure
17803 -------------------------------------------------------------------------*/
17804VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17805{
17806 eHalStatus status = eHAL_STATUS_SUCCESS;
17807 tCsrNeighborRoamBSSInfo handoffNode;
17808 tANI_U32 timer_diff = 0;
17809 tANI_U32 timeStamp[2];
17810 tpSirBssDescription pBssDescription = NULL;
17811
17812 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17813 pBssDescription = handoffNode.pBssDescription;
17814
17815 // Get the time diff in milli seconds
17816 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17817 // Convert msec to micro sec timer
17818 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17819
17820 timeStamp[0] = pBssDescription->timeStamp[0];
17821 timeStamp[1] = pBssDescription->timeStamp[1];
17822
17823 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17824
Kiet Lamf2f201e2013-11-16 21:24:16 +053017825 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017826 sizeof (tANI_U32) * 2);
17827 return status;
17828}
17829
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017830#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017831
Agarwal Ashish738843c2014-09-25 12:27:56 +053017832/* ---------------------------------------------------------------------------
17833 \fn csrDisableDfsChannel
17834 \brief This function will call csrApplyChannelPowerCountryInfo to
17835 \ to trim the list on basis of NO_DFS flag.
17836 \param pMac - pMac global structure
17837 \- return void
17838 -------------------------------------------------------------------------*/
17839void csrDisableDfsChannel(tpAniSirGlobal pMac)
17840{
17841 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
17842 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE);
17843}