blob: 73538c2d1609f9ba0af271ef90ef4bff94b0eb72 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam0fb93dd2014-02-19 00:32:59 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21
22/*
Kiet Lama7f454d2014-07-24 12:04:06 -070023 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
Kiet Lam0fb93dd2014-02-19 00:32:59 -080026 */
27
28
Kiet Lama7f454d2014-07-24 12:04:06 -070029
30
Jeff Johnson295189b2012-06-20 16:38:30 -070031/** ------------------------------------------------------------------------- *
32 ------------------------------------------------------------------------- *
Jeff Johnsone7245742012-09-05 17:12:55 -070033
Jeff Johnson295189b2012-06-20 16:38:30 -070034
35 \file csrApiRoam.c
36
37 Implementation for the Common Roaming interfaces.
38
Kiet Lamaa8e15a2014-02-11 23:30:06 -080039 Copyright (C) 2008 Qualcomm, Incorporated
40
Jeff Johnson295189b2012-06-20 16:38:30 -070041
42 ========================================================================== */
Jeff Johnson295189b2012-06-20 16:38:30 -070043/*===========================================================================
Jeff Johnson295189b2012-06-20 16:38:30 -070044 EDIT HISTORY FOR FILE
45
Jeff Johnson295189b2012-06-20 16:38:30 -070046 This section contains comments describing changes made to the module.
47 Notice that changes are listed in reverse chronological order.
48
Jeff Johnson295189b2012-06-20 16:38:30 -070049 when who what, where, why
50---------- --- --------------------------------------------------------
5106/03/10 js Added support to hostapd driven
52 * deauth/disassoc/mic failure
Jeff Johnson295189b2012-06-20 16:38:30 -070053===========================================================================*/
Jeff Johnson295189b2012-06-20 16:38:30 -070054#include "aniGlobal.h" //for tpAniSirGlobal
55#include "wlan_qct_wda.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070056#include "halMsgApi.h" //for HAL_STA_INVALID_IDX.
Jeff Johnsone7245742012-09-05 17:12:55 -070057#include "limUtils.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070058#include "palApi.h"
59#include "csrInsideApi.h"
60#include "smsDebug.h"
61#include "logDump.h"
62#include "smeQosInternal.h"
63#include "wlan_qct_tl.h"
64#include "smeInside.h"
65#include "vos_diag_core_event.h"
66#include "vos_diag_core_log.h"
67#include "csrApi.h"
68#include "pmc.h"
69#include "vos_nvitem.h"
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053070#include "macTrace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070071#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
72#include "csrNeighborRoam.h"
73#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080074#if defined(FEATURE_WLAN_ESE) && !defined(FEATURE_WLAN_ESE_UPLOAD)
75#include "csrEse.h"
76#endif /* FEATURE_WLAN_ESE && !FEATURE_WLAN_ESE_UPLOAD */
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053077#ifdef DEBUG_ROAM_DELAY
78#include "vos_utils.h"
79#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070080#define CSR_NUM_IBSS_START_CHANNELS_50 4
81#define CSR_NUM_IBSS_START_CHANNELS_24 3
82#define CSR_DEF_IBSS_START_CHANNEL_50 36
83#define CSR_DEF_IBSS_START_CHANNEL_24 1
Srikant Kuppa2062aaf2012-12-27 17:36:41 -080084#define CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD ( 5 * PAL_TIMER_TO_SEC_UNIT ) // 5 seconds, for WPA, WPA2, CCKM
Jeff Johnson295189b2012-06-20 16:38:30 -070085#define CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD ( 120 * PAL_TIMER_TO_SEC_UNIT ) // 120 seconds, for WPS
86/*---------------------------------------------------------------------------
87 OBIWAN recommends [8 10]% : pick 9%
88---------------------------------------------------------------------------*/
89#define CSR_VCC_UL_MAC_LOSS_THRESHOLD 9
Jeff Johnson295189b2012-06-20 16:38:30 -070090/*---------------------------------------------------------------------------
91 OBIWAN recommends -85dBm
92---------------------------------------------------------------------------*/
93#define CSR_VCC_RSSI_THRESHOLD 80
94#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD 500 //ms
95#define CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS 2000 //ms
96#define CSR_MIN_TL_STAT_QUERY_PERIOD 500 //ms
97#define CSR_DIAG_LOG_STAT_PERIOD 3000 //ms
Jeff Johnson295189b2012-06-20 16:38:30 -070098//We use constatnt 4 here
99//This macro returns true when higher AC parameter is bigger than lower AC for a difference
100//The bigger the number, the less chance of TX
101//It must put lower AC as the first parameter.
102#define SME_DETECT_AC_WEIGHT_DIFF(loAC, hiAC) (v_BOOL_t)(((hiAC) > (loAC)) ? (((hiAC)-(loAC)) > 4) : 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700103//Flag to send/do not send disassoc frame over the air
104#define CSR_DONT_SEND_DISASSOC_OVER_THE_AIR 1
Jeff Johnson295189b2012-06-20 16:38:30 -0700105#define RSSI_HACK_BMPS (-40)
Jeff Johnsone7245742012-09-05 17:12:55 -0700106#define MAX_CB_VALUE_IN_INI (2)
107
Srinivas Girigowda577ed652013-08-14 11:38:29 -0700108#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
109static tANI_BOOLEAN bRoamScanOffloadStarted = VOS_FALSE;
110#endif
111
Jeff Johnson295189b2012-06-20 16:38:30 -0700112/*--------------------------------------------------------------------------
113 Static Type declarations
114 ------------------------------------------------------------------------*/
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800115static tCsrRoamSession csrRoamRoamSession[CSR_ROAM_SESSION_MAX];
Srinivas Girigowdade697412013-02-14 16:31:48 -0800116
Jeff Johnson295189b2012-06-20 16:38:30 -0700117/*--------------------------------------------------------------------------
118 Type declarations
119 ------------------------------------------------------------------------*/
120#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700121int diagAuthTypeFromCSRType(eCsrAuthType authType)
122{
123 int n = AUTH_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700124 switch(authType)
125 {
126 case eCSR_AUTH_TYPE_SHARED_KEY:
127 n = AUTH_SHARED;
128 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700129 case eCSR_AUTH_TYPE_WPA:
130 n = AUTH_WPA_EAP;
131 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700132 case eCSR_AUTH_TYPE_WPA_PSK:
133 n = AUTH_WPA_PSK;
134 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700135 case eCSR_AUTH_TYPE_RSN:
Abhishek Singhae408032014-09-25 17:22:04 +0530136#ifdef WLAN_FEATURE_11W
137 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
138#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700139 n = AUTH_WPA2_EAP;
140 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700141 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -0700142#ifdef WLAN_FEATURE_11W
143 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
144#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700145 n = AUTH_WPA2_PSK;
146 break;
147#ifdef FEATURE_WLAN_WAPI
148 case eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE:
149 n = AUTH_WAPI_CERT;
150 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 case eCSR_AUTH_TYPE_WAPI_WAI_PSK:
152 n = AUTH_WAPI_PSK;
153 break;
154#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -0700155 default:
156 break;
157 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700158 return (n);
159}
Jeff Johnson295189b2012-06-20 16:38:30 -0700160int diagEncTypeFromCSRType(eCsrEncryptionType encType)
161{
162 int n = ENC_MODE_OPEN;
Jeff Johnson295189b2012-06-20 16:38:30 -0700163 switch(encType)
164 {
165 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
166 case eCSR_ENCRYPT_TYPE_WEP40:
167 n = ENC_MODE_WEP40;
168 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
170 case eCSR_ENCRYPT_TYPE_WEP104:
171 n = ENC_MODE_WEP104;
172 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700173 case eCSR_ENCRYPT_TYPE_TKIP:
174 n = ENC_MODE_TKIP;
175 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700176 case eCSR_ENCRYPT_TYPE_AES:
177 n = ENC_MODE_AES;
178 break;
Jeff Johnson295189b2012-06-20 16:38:30 -0700179#ifdef FEATURE_WLAN_WAPI
180 case eCSR_ENCRYPT_TYPE_WPI:
181 n = ENC_MODE_SMS4;
182 break;
183#endif /* FEATURE_WLAN_WAPI */
184 default:
185 break;
186 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700187 return (n);
188}
Jeff Johnson295189b2012-06-20 16:38:30 -0700189#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -0700190static const tANI_U8 csrStartIbssChannels50[ CSR_NUM_IBSS_START_CHANNELS_50 ] = { 36, 40, 44, 48};
191static const tANI_U8 csrStartIbssChannels24[ CSR_NUM_IBSS_START_CHANNELS_24 ] = { 1, 6, 11 };
Jeff Johnson295189b2012-06-20 16:38:30 -0700192static void initConfigParam(tpAniSirGlobal pMac);
193static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
194 eCsrRoamCompleteResult Result, void *Context );
195static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId,
196 tCsrRoamProfile *pProfile,
197 tANI_BOOLEAN *pfSameIbss );
198static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirSmeNewBssInfo *pNewBss );
199static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -0700200 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes);
201static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -0700202eHalStatus csrInitGetChannels(tpAniSirGlobal pMac);
203static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result );
204eHalStatus csrRoamOpen(tpAniSirGlobal pMac);
205eHalStatus csrRoamClose(tpAniSirGlobal pMac);
206void csrRoamMICErrorTimerHandler(void *pv);
207void csrRoamTKIPCounterMeasureTimerHandler(void *pv);
208tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2);
209
210static eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval);
211static eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId);
212static void csrRoamRoamingTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700213eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval);
214eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac);
215static void csrRoamWaitForKeyTimeOutHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700216static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnsone7245742012-09-05 17:12:55 -0700217static eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700218static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo );
219eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
220 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
221 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
222 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
223 tANI_U8 *pKeyRsc );
224static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
225 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes,
226 tCsrRoamProfile *pProfile );
227void csrRoamStatisticsTimerHandler(void *pv);
228void csrRoamStatsGlobalClassDTimerHandler(void *pv);
Jeff Johnson295189b2012-06-20 16:38:30 -0700229static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid);
230VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
231 v_U8_t rssiNotification,
232 void * context);
233static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId);
234void csrRoamVccTrigger(tpAniSirGlobal pMac);
235eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId);
236/*
237 pStaEntry is no longer invalid upon the return of this function.
238*/
239static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -0700240static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,tANI_U8 operationChn, eCsrBand *pBand );
Jeff Johnson295189b2012-06-20 16:38:30 -0700241static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700242tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
243 tDblLinkList *pStaList,
244 tCsrStatsClientReqInfo *pStaEntry);
245void csrRoamStatsClientTimerHandler(void *pv);
246tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
247 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId);
248void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
249 tCsrStatsCallback callback, tANI_U8 staId, void *pContext);
Jeff Johnsone7245742012-09-05 17:12:55 -0700250void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats);
Jeff Johnson295189b2012-06-20 16:38:30 -0700251void csrRoamTlStatsTimerHandler(void *pv);
252void csrRoamPeStatsTimerHandler(void *pv);
253tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
254void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry);
255tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask);
256eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac);
257static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac );
258static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc );
259static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId );
260static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
261 tCsrRoamSetKey *pSetKey, tANI_U32 roamId );
262//static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand );
263static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc);
264void csrRoamReissueRoamCommand(tpAniSirGlobal pMac);
265#ifdef FEATURE_WLAN_BTAMP_UT_RF
266void csrRoamJoinRetryTimerHandler(void *pv);
267#endif
Atul Mittalb849d5a2014-07-29 12:08:39 +0530268void limInitOperatingClasses( tHalHandle hHal );
Jeff Johnson295189b2012-06-20 16:38:30 -0700269extern void SysProcessMmhMsg(tpAniSirGlobal pMac, tSirMsgQ* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700270extern void btampEstablishLogLinkHdlr(void* pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -0700271static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700272void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand);
Jeff Johnson295189b2012-06-20 16:38:30 -0700273
274//Initialize global variables
275static void csrRoamInitGlobals(tpAniSirGlobal pMac)
276{
277 if(pMac)
278 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800279 vos_mem_zero(&csrRoamRoamSession, sizeof(csrRoamRoamSession));
280 pMac->roam.roamSession = csrRoamRoamSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700281 }
282 return;
283}
284
Jeff Johnson295189b2012-06-20 16:38:30 -0700285static void csrRoamDeInitGlobals(tpAniSirGlobal pMac)
286{
287 if(pMac)
288 {
Madan Mohan Koyyalamudi84b7f0a2012-11-28 15:15:14 -0800289 pMac->roam.roamSession = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700290 }
291 return;
292}
Jeff Johnson295189b2012-06-20 16:38:30 -0700293eHalStatus csrOpen(tpAniSirGlobal pMac)
294{
295 eHalStatus status = eHAL_STATUS_SUCCESS;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530296#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 static uNvTables nvTables;
298 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700299 v_REGDOMAIN_t regId;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530300#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700301 tANI_U32 i;
302
303 do
304 {
305 /* Initialize CSR Roam Globals */
306 csrRoamInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700307 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
308 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i);
309
310 initConfigParam(pMac);
311 if(!HAL_STATUS_SUCCESS((status = csrScanOpen(pMac))))
312 break;
313 if(!HAL_STATUS_SUCCESS((status = csrRoamOpen(pMac))))
314 break;
315 pMac->roam.nextRoamId = 1; //Must not be 0
316 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.statsClientReqList)))
317 break;
318 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.peStatsReqList)))
319 break;
320 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &pMac->roam.roamCmdPendingList)))
321 break;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530322
323#ifndef CONFIG_ENABLE_LINUX_REG
Jeff Johnson295189b2012-06-20 16:38:30 -0700324 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
325 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
326 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530327 vos_mem_copy(pMac->scan.countryCodeDefault, nvTables.defaultCountryTable.countryCode,
328 WNI_CFG_COUNTRY_CODE_LEN);
329 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700330 }
331 else
332 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800333 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 //hardcoded for now
335 pMac->scan.countryCodeDefault[0] = 'U';
336 pMac->scan.countryCodeDefault[1] = 'S';
337 pMac->scan.countryCodeDefault[2] = 'I';
338 //status = eHAL_STATUS_SUCCESS;
339 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700340 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
Kiet Lam6c583332013-10-14 05:37:09 +0530341
342 if (!('0' == pMac->scan.countryCodeDefault[0] &&
343 '0' == pMac->scan.countryCodeDefault[1]))
344 {
345 csrGetRegulatoryDomainForCountry(pMac, pMac->scan.countryCodeDefault,
346 &regId, COUNTRY_NV);
347 }
348 else
349 {
350 regId = REGDOMAIN_WORLD;
351 }
Abhishek Singha306a442013-11-07 18:39:01 +0530352 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700353 pMac->scan.domainIdDefault = regId;
354 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Kiet Lam64c1b492013-07-12 13:56:44 +0530355 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
356 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700357 status = csrInitGetChannels( pMac );
Mihir Shetee1093ba2014-01-21 20:13:32 +0530358#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 }while(0);
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530360
Jeff Johnson295189b2012-06-20 16:38:30 -0700361 return (status);
362}
363
Mihir Shetee1093ba2014-01-21 20:13:32 +0530364/* --------------------------------------------------------------------------
365 \fn csrInitChannels
366 \brief This function must be called to initialize CSR channel lists
367 \return eHalStatus
368 ----------------------------------------------------------------------------*/
369eHalStatus csrInitChannels(tpAniSirGlobal pMac)
370{
371 eHalStatus status = eHAL_STATUS_SUCCESS;
372 static uNvTables nvTables;
373 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530374 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Mihir Shetee1093ba2014-01-21 20:13:32 +0530375
376 vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
377 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
378 {
379 vos_mem_copy(pMac->scan.countryCodeDefault,
380 nvTables.defaultCountryTable.countryCode,
381 WNI_CFG_COUNTRY_CODE_LEN);
382 }
383 else
384 {
385 smsLog( pMac, LOGE, FL(" fail to get NV_FIELD_IMAGE") );
386 //hardcoded for now
387 pMac->scan.countryCodeDefault[0] = 'U';
388 pMac->scan.countryCodeDefault[1] = 'S';
389 pMac->scan.countryCodeDefault[2] = 'I';
390 }
391 smsLog( pMac, LOG1, FL(" country Code from nvRam %.2s"), pMac->scan.countryCodeDefault );
392
Mihir Shetee1093ba2014-01-21 20:13:32 +0530393 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
394 pMac->scan.domainIdDefault = regId;
395 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
396 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
397 WNI_CFG_COUNTRY_CODE_LEN);
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530398 vos_mem_copy(pMac->scan.countryCodeElected, pMac->scan.countryCodeDefault,
399 WNI_CFG_COUNTRY_CODE_LEN);
Agarwal Ashishcd9b8e62014-07-21 19:48:24 +0530400 vos_mem_copy(pMac->scan.countryCode11d, pMac->scan.countryCodeDefault,
401 WNI_CFG_COUNTRY_CODE_LEN);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530402 status = csrInitGetChannels( pMac );
Agrawal Ashish0b6984f2014-04-05 18:35:45 +0530403 csrClearVotesForCountryInfo(pMac);
Mihir Shetee1093ba2014-01-21 20:13:32 +0530404
405 return status;
406}
407
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530408eHalStatus csrInitChannelsForCC(tpAniSirGlobal pMac, driver_load_type init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530409{
410 eHalStatus status = eHAL_STATUS_SUCCESS;
411 v_REGDOMAIN_t regId = REGDOMAIN_WORLD;
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530412 tANI_U8 cc[WNI_CFG_COUNTRY_CODE_LEN];
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530413
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530414 /* In case of driver load ; driver need to get channel
415 * list with default Countrycode.
416 * In case of SSR; driver need to get channel list
417 * with old country code. 0 is for init and
418 * 1 is for reinit
419 */
420 switch (init)
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530421 {
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530422 case INIT:
423 vos_mem_copy(cc, pMac->scan.countryCodeDefault,
424 WNI_CFG_COUNTRY_CODE_LEN);
425 if (!('0' == cc[0] &&
426 '0' == cc[1]))
427 {
428 csrGetRegulatoryDomainForCountry(pMac, cc,
429 &regId, COUNTRY_NV);
430 }
431 else
432 {
433 return status;
434 }
435 pMac->scan.domainIdDefault = regId;
436 break;
437 case REINIT:
438 vos_getCurrentCountryCode(&cc[0]);
439 status = csrGetRegulatoryDomainForCountry(pMac,
440 cc, &regId, COUNTRY_QUERY);
441 break;
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530442 }
443 WDA_SetRegDomain(pMac, regId, eSIR_TRUE);
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530444 pMac->scan.domainIdCurrent = regId;
445 vos_mem_copy(pMac->scan.countryCodeCurrent, cc,
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530446 WNI_CFG_COUNTRY_CODE_LEN);
447 status = csrInitGetChannels( pMac );
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530448
Agarwal Ashish6db9d532014-09-30 18:19:10 +0530449 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
450 FL("Current Country is %c%c "), pMac->scan.countryCodeCurrent[0],
451 pMac->scan.countryCodeCurrent[1]);
452
Agarwal Ashishf3298ac2014-07-26 19:34:17 +0530453 /* reset info based on new cc, and we are done */
454 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_TRUE);
455 csrScanFilterResults(pMac);
456
Mahesh A Saptasagar74289d22014-05-14 12:43:37 +0530457 return status;
458}
459
Jeff Johnson295189b2012-06-20 16:38:30 -0700460eHalStatus csrSetRegInfo(tHalHandle hHal, tANI_U8 *apCntryCode)
461{
462 eHalStatus status = eHAL_STATUS_SUCCESS;
463 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
464 v_REGDOMAIN_t regId;
465 v_U8_t cntryCodeLength;
Jeff Johnson295189b2012-06-20 16:38:30 -0700466 if(NULL == apCntryCode)
467 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530468 smsLog( pMac, LOGE, FL(" Invalid country Code Pointer") );
Jeff Johnson295189b2012-06-20 16:38:30 -0700469 return eHAL_STATUS_FAILURE;
470 }
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +0530471 smsLog( pMac, LOG1, FL(" country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700472 /* To get correct Regulatory domain from NV table
473 * 2 character Country code should be used
474 * 3rd charater is optional for indoor/outdoor setting */
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700475 cntryCodeLength = WNI_CFG_COUNTRY_CODE_LEN;
476/*
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 cntryCodeLength = strlen(apCntryCode);
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700478
479 if (cntryCodeLength > WNI_CFG_COUNTRY_CODE_LEN)
480 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800481 smsLog( pMac, LOGW, FL(" Invalid Country Code Length") );
Madan Mohan Koyyalamudib666eb12012-09-18 17:29:47 -0700482 return eHAL_STATUS_FAILURE;
483 }
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700484*/
Kiet Lam6c583332013-10-14 05:37:09 +0530485 status = csrGetRegulatoryDomainForCountry(pMac, apCntryCode, &regId,
486 COUNTRY_USER);
Jeff Johnson295189b2012-06-20 16:38:30 -0700487 if (status != eHAL_STATUS_SUCCESS)
488 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700489 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 return status;
491 }
Abhishek Singha306a442013-11-07 18:39:01 +0530492 status = WDA_SetRegDomain(hHal, regId, eSIR_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 if (status != eHAL_STATUS_SUCCESS)
494 {
Gopichand Nakkala114718f2013-03-25 19:19:46 -0700495 smsLog( pMac, LOGE, FL(" fail to get regId for country Code %.2s"), apCntryCode );
Jeff Johnson295189b2012-06-20 16:38:30 -0700496 return status;
497 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700498 pMac->scan.domainIdDefault = regId;
499 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Jeff Johnson295189b2012-06-20 16:38:30 -0700500 /* Clear CC field */
Kiet Lam64c1b492013-07-12 13:56:44 +0530501 vos_mem_set(pMac->scan.countryCodeDefault, WNI_CFG_COUNTRY_CODE_LEN, 0);
502
Jeff Johnson295189b2012-06-20 16:38:30 -0700503 /* Copy 2 or 3 bytes country code */
Kiet Lam64c1b492013-07-12 13:56:44 +0530504 vos_mem_copy(pMac->scan.countryCodeDefault, apCntryCode, cntryCodeLength);
505
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 /* If 2 bytes country code, 3rd byte must be filled with space */
507 if((WNI_CFG_COUNTRY_CODE_LEN - 1) == cntryCodeLength)
508 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530509 vos_mem_set(pMac->scan.countryCodeDefault + 2, 1, 0x20);
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530511 vos_mem_copy(pMac->scan.countryCodeCurrent, pMac->scan.countryCodeDefault,
512 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700513 status = csrInitGetChannels( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -0700514 return status;
515}
Jeff Johnson295189b2012-06-20 16:38:30 -0700516eHalStatus csrSetChannels(tHalHandle hHal, tCsrConfigParam *pParam )
517{
518 eHalStatus status = eHAL_STATUS_SUCCESS;
519 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
520 tANI_U8 index = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +0530521 vos_mem_copy(pParam->Csr11dinfo.countryCode, pMac->scan.countryCodeCurrent,
522 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 for ( index = 0; index < pMac->scan.base20MHzChannels.numChannels ; index++)
524 {
525 pParam->Csr11dinfo.Channels.channelList[index] = pMac->scan.base20MHzChannels.channelList[ index ];
526 pParam->Csr11dinfo.ChnPower[index].firstChannel = pMac->scan.base20MHzChannels.channelList[ index ];
527 pParam->Csr11dinfo.ChnPower[index].numChannels = 1;
528 pParam->Csr11dinfo.ChnPower[index].maxtxPower = pMac->scan.defaultPowerTable[index].pwr;
529 }
530 pParam->Csr11dinfo.Channels.numChannels = pMac->scan.base20MHzChannels.numChannels;
531
532 return status;
533}
Jeff Johnson295189b2012-06-20 16:38:30 -0700534eHalStatus csrClose(tpAniSirGlobal pMac)
535{
536 eHalStatus status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800537
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 csrRoamClose(pMac);
539 csrScanClose(pMac);
540 csrLLClose(&pMac->roam.statsClientReqList);
541 csrLLClose(&pMac->roam.peStatsReqList);
542 csrLLClose(&pMac->roam.roamCmdPendingList);
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 /* DeInit Globals */
544 csrRoamDeInitGlobals(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 return (status);
546}
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530547
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800548eHalStatus csrUpdateChannelList(tpAniSirGlobal pMac)
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530549{
550 tSirUpdateChanList *pChanList;
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800551 tCsrScanStruct *pScan = &pMac->scan;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530552 tANI_U32 numChan = 0;
553 tANI_U32 bufLen ;
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530554 vos_msg_t msg;
555 tANI_U8 i;
556
Atul Mittalb849d5a2014-07-29 12:08:39 +0530557 limInitOperatingClasses((tHalHandle)pMac);
Agarwal Ashish738843c2014-09-25 12:27:56 +0530558 numChan = sizeof(pMac->roam.validChannelList);
559
560 if ( !HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac,
561 (tANI_U8 *)pMac->roam.validChannelList, &numChan)))
562 {
563 smsLog( pMac, LOGE, "Failed to get Channel list from CFG");
564 return eHAL_STATUS_FAILED_ALLOC;
565 }
566
567 bufLen = sizeof(tSirUpdateChanList) +
568 (sizeof(tSirUpdateChanParam) * (numChan - 1));
569
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530570 pChanList = (tSirUpdateChanList *) vos_mem_malloc(bufLen);
571 if (!pChanList)
572 {
573 VOS_TRACE(VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
574 "Failed to allocate memory for tSirUpdateChanList");
575 return eHAL_STATUS_FAILED_ALLOC;
576 }
577
578 msg.type = WDA_UPDATE_CHAN_LIST_REQ;
579 msg.reserved = 0;
580 msg.bodyptr = pChanList;
581 pChanList->numChan = numChan;
582 for (i = 0; i < pChanList->numChan; i++)
583 {
Agarwal Ashish738843c2014-09-25 12:27:56 +0530584 pChanList->chanParam[i].chanId = pMac->roam.validChannelList[i];
Leela Venkata Kiran Kumar Reddy Chiralac6663f72014-02-03 21:04:58 -0800585 pChanList->chanParam[i].pwr = cfgGetRegulatoryMaxTransmitPower(pMac,
586 pScan->defaultPowerTable[i].chanId);
587 if (vos_nv_getChannelEnabledState(pChanList->chanParam[i].chanId) ==
588 NV_CHANNEL_DFS)
589 pChanList->chanParam[i].dfsSet = VOS_TRUE;
590 else
591 pChanList->chanParam[i].dfsSet = VOS_FALSE;
Agarwal Ashish738843c2014-09-25 12:27:56 +0530592 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
593 "%s Supported Channel: %d\n", __func__, pChanList->chanParam[i].chanId);
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530594 }
595
596 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MODULE_ID_WDA, &msg))
597 {
598 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
599 "%s: Failed to post msg to WDA", __func__);
600 vos_mem_free(pChanList);
601 return eHAL_STATUS_FAILURE;
602 }
603
604 return eHAL_STATUS_SUCCESS;
605}
606
Jeff Johnson295189b2012-06-20 16:38:30 -0700607eHalStatus csrStart(tpAniSirGlobal pMac)
608{
609 eHalStatus status = eHAL_STATUS_SUCCESS;
610 tANI_U32 i;
611
612 do
613 {
614 //save the global vos context
615 pMac->roam.gVosContext = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
616 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
617 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, i );
618
619 status = csrRoamStart(pMac);
620 if(!HAL_STATUS_SUCCESS(status)) break;
621 pMac->scan.f11dInfoApplied = eANI_BOOLEAN_FALSE;
622 status = pmcRegisterPowerSaveCheck(pMac, csrCheckPSReady, pMac);
623 if(!HAL_STATUS_SUCCESS(status)) break;
624 pMac->roam.sPendingCommands = 0;
625 csrScanEnable(pMac);
626#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
627 status = csrNeighborRoamInit(pMac);
628#endif /* WLAN_FEATURE_NEIGHBOR_ROAMING */
629 pMac->roam.tlStatsReqInfo.numClient = 0;
630 pMac->roam.tlStatsReqInfo.periodicity = 0;
631 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
632 //init the link quality indication also
633 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_MIN_IND;
634 if(!HAL_STATUS_SUCCESS(status))
635 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800636 smsLog(pMac, LOGW, " csrStart: Couldn't Init HO control blk ");
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 break;
638 }
Gopichand Nakkalaf72a3872013-06-11 17:51:13 +0530639
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700641#if defined(ANI_LOGDUMP)
642 csrDumpInit(pMac);
643#endif //#if defined(ANI_LOGDUMP)
Jeff Johnson295189b2012-06-20 16:38:30 -0700644 return (status);
645}
646
Kiet Lama72a2322013-11-15 11:18:11 +0530647eHalStatus csrStop(tpAniSirGlobal pMac, tHalStopType stopType)
Jeff Johnson295189b2012-06-20 16:38:30 -0700648{
649 tANI_U32 sessionId;
650 tANI_U32 i;
651
652 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
653 {
654 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
655 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700656 csrScanDisable(pMac);
657 pMac->scan.fCancelIdleScan = eANI_BOOLEAN_FALSE;
658 pMac->scan.fRestartIdleScan = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700659 csrLLPurge( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_TRUE );
660
661#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
662 csrNeighborRoamClose(pMac);
663#endif
664 csrScanFlushResult(pMac); //Do we want to do this?
Jeff Johnson295189b2012-06-20 16:38:30 -0700665 // deregister from PMC since we register during csrStart()
666 // (ignore status since there is nothing we can do if it fails)
667 (void) pmcDeregisterPowerSaveCheck(pMac, csrCheckPSReady);
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 //Reset the domain back to the deault
669 pMac->scan.domainIdCurrent = pMac->scan.domainIdDefault;
Gopichand Nakkalab9185f22012-12-21 08:03:42 -0800670 csrResetCountryInformation(pMac, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -0700671
672 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
673 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530674 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_STOP, i );
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 pMac->roam.curSubState[i] = eCSR_ROAM_SUBSTATE_NONE;
676 }
677
Kiet Lama72a2322013-11-15 11:18:11 +0530678#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
679 /* When HAL resets all the context information
680 * in HAL is lost, so we might need to send the
681 * scan offload request again when it comes
682 * out of reset for scan offload to be functional
683 */
684 if (HAL_STOP_TYPE_SYS_RESET == stopType)
685 {
686 bRoamScanOffloadStarted = VOS_FALSE;
687 }
688#endif
689
Jeff Johnson295189b2012-06-20 16:38:30 -0700690 return (eHAL_STATUS_SUCCESS);
691}
692
Jeff Johnson295189b2012-06-20 16:38:30 -0700693eHalStatus csrReady(tpAniSirGlobal pMac)
694{
695 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 csrScanGetSupportedChannels( pMac );
697 //WNI_CFG_VALID_CHANNEL_LIST should be set by this time
698 //use it to init the background scan list
699 csrInitBGScanChannelList(pMac);
700 /* HDD issues the init scan */
701 csrScanStartResultAgingTimer(pMac);
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -0800702 /* If the gScanAgingTime is set to '0' then scan results aging timeout
703 based on timer feature is not enabled*/
704 if(0 != pMac->scan.scanResultCfgAgingTime )
705 {
706 csrScanStartResultCfgAgingTimer(pMac);
707 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700708 //Store the AC weights in TL for later use
709 WLANTL_GetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 status = csrInitChannelList( pMac );
711 if ( ! HAL_STATUS_SUCCESS( status ) )
712 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800713 smsLog( pMac, LOGE, "csrInitChannelList failed during csrReady with status=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 status );
715 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 return (status);
717}
Jeff Johnson295189b2012-06-20 16:38:30 -0700718void csrSetDefaultDot11Mode( tpAniSirGlobal pMac )
719{
720 v_U32_t wniDot11mode = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 wniDot11mode = csrTranslateToWNICfgDot11Mode(pMac,pMac->roam.configParam.uCfgDot11Mode);
722 ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, wniDot11mode, NULL, eANI_BOOLEAN_FALSE);
723}
Jeff Johnson295189b2012-06-20 16:38:30 -0700724void csrSetGlobalCfgs( tpAniSirGlobal pMac )
725{
Jeff Johnsone7245742012-09-05 17:12:55 -0700726
Jeff Johnson295189b2012-06-20 16:38:30 -0700727 ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
728 ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
729 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
730 ((pMac->roam.configParam.Is11hSupportEnabled) ? pMac->roam.configParam.Is11dSupportEnabled : pMac->roam.configParam.Is11dSupportEnabled),
731 NULL, eANI_BOOLEAN_FALSE);
732 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnsone7245742012-09-05 17:12:55 -0700733 /* For now we will just use the 5GHz CB mode ini parameter to decide whether CB supported or not in Probes when there is no session
734 * Once session is established we will use the session related params stored in PE session for CB mode
735 */
736 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, !!(pMac->roam.configParam.channelBondingMode5GHz), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -0700737 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, pMac->roam.configParam.HeartbeatThresh24, NULL, eANI_BOOLEAN_FALSE);
738
739 //Update the operating mode to configured value during initialization,
740 //So that client can advertise full capabilities in Probe request frame.
741 csrSetDefaultDot11Mode( pMac );
742}
743
Jeff Johnson295189b2012-06-20 16:38:30 -0700744eHalStatus csrRoamOpen(tpAniSirGlobal pMac)
745{
746 eHalStatus status = eHAL_STATUS_SUCCESS;
747 tANI_U32 i;
748 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -0700749 do
750 {
751 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
752 {
753 pSession = CSR_GET_SESSION( pMac, i );
754 pSession->roamingTimerInfo.pMac = pMac;
755 pSession->roamingTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
756 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 pMac->roam.WaitForKeyTimerInfo.pMac = pMac;
758 pMac->roam.WaitForKeyTimerInfo.sessionId = CSR_SESSION_ID_INVALID;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530759 status = vos_timer_init(&pMac->roam.hTimerWaitForKey, VOS_TIMER_TYPE_SW,
760 csrRoamWaitForKeyTimeOutHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -0700761 &pMac->roam.WaitForKeyTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530762 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700763 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800764 smsLog(pMac, LOGE, FL("cannot allocate memory for WaitForKey time out timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700765 break;
766 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530767 status = vos_timer_init(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
768 VOS_TIMER_TYPE_SW, csrRoamTlStatsTimerHandler, pMac);
769 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -0800771 smsLog(pMac, LOGE, FL("cannot allocate memory for summary Statistics timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 return eHAL_STATUS_FAILURE;
773 }
774 }while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 return (status);
776}
777
Jeff Johnson295189b2012-06-20 16:38:30 -0700778eHalStatus csrRoamClose(tpAniSirGlobal pMac)
779{
780 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -0700781 for(sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++)
782 {
783 csrRoamCloseSession(pMac, sessionId, TRUE, NULL, NULL);
784 }
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +0530785 vos_timer_stop(&pMac->roam.hTimerWaitForKey);
786 vos_timer_destroy(&pMac->roam.hTimerWaitForKey);
787 vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
788 vos_timer_destroy(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
Jeff Johnson295189b2012-06-20 16:38:30 -0700789 return (eHAL_STATUS_SUCCESS);
790}
791
Jeff Johnson295189b2012-06-20 16:38:30 -0700792eHalStatus csrRoamStart(tpAniSirGlobal pMac)
793{
794 (void)pMac;
Jeff Johnson295189b2012-06-20 16:38:30 -0700795 return (eHAL_STATUS_SUCCESS);
796}
797
Jeff Johnson295189b2012-06-20 16:38:30 -0700798void csrRoamStop(tpAniSirGlobal pMac, tANI_U32 sessionId)
799{
800 csrRoamStopRoamingTimer(pMac, sessionId);
801 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
802 csrRoamDeregStatisticsReq(pMac);
803}
Jeff Johnson295189b2012-06-20 16:38:30 -0700804eHalStatus csrRoamGetConnectState(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrConnectState *pState)
805{
806 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Srinivas Girigowdac84c57c2013-02-19 17:41:56 -0800807 if ( CSR_IS_SESSION_VALID(pMac, sessionId) && (NULL != pState) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700808 {
809 status = eHAL_STATUS_SUCCESS;
810 *pState = pMac->roam.roamSession[sessionId].connectState;
811 }
812 return (status);
813}
814
Jeff Johnson295189b2012-06-20 16:38:30 -0700815eHalStatus csrRoamCopyConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
816{
817 eHalStatus status = eHAL_STATUS_FAILURE;
818 tANI_U32 size = 0;
819 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -0700820
821 if(!pSession)
822 {
823 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
824 return eHAL_STATUS_FAILURE;
825 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700826
827 if(pProfile)
828 {
829 if(pSession->pConnectBssDesc)
830 {
831 do
832 {
833 size = pSession->pConnectBssDesc->length + sizeof(pSession->pConnectBssDesc->length);
834 if(size)
835 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530836 pProfile->pBssDesc = vos_mem_malloc(size);
837 if ( NULL != pProfile->pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530839 vos_mem_copy(pProfile->pBssDesc,
840 pSession->pConnectBssDesc, size);
841 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 }
843 else
844 break;
845 }
846 else
847 {
848 pProfile->pBssDesc = NULL;
849 }
850 pProfile->AuthType = pSession->connectedProfile.AuthType;
851 pProfile->EncryptionType = pSession->connectedProfile.EncryptionType;
852 pProfile->mcEncryptionType = pSession->connectedProfile.mcEncryptionType;
853 pProfile->BSSType = pSession->connectedProfile.BSSType;
854 pProfile->operationChannel = pSession->connectedProfile.operationChannel;
855 pProfile->CBMode = pSession->connectedProfile.CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +0530856 vos_mem_copy(&pProfile->bssid, &pSession->connectedProfile.bssid,
857 sizeof(tCsrBssid));
858 vos_mem_copy(&pProfile->SSID, &pSession->connectedProfile.SSID,
859 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -0700860#ifdef WLAN_FEATURE_VOWIFI_11R
861 if (pSession->connectedProfile.MDID.mdiePresent)
862 {
863 pProfile->MDID.mdiePresent = 1;
864 pProfile->MDID.mobilityDomain = pSession->connectedProfile.MDID.mobilityDomain;
865 }
866 else
867 {
868 pProfile->MDID.mdiePresent = 0;
869 pProfile->MDID.mobilityDomain = 0;
870 }
871#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800872#ifdef FEATURE_WLAN_ESE
873 pProfile->isESEAssoc = pSession->connectedProfile.isESEAssoc;
874 if (csrIsAuthTypeESE(pSession->connectedProfile.AuthType))
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800876 vos_mem_copy (pProfile->eseCckmInfo.krk,
877 pSession->connectedProfile.eseCckmInfo.krk,
Kiet Lam64c1b492013-07-12 13:56:44 +0530878 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800879 pProfile->eseCckmInfo.reassoc_req_num=
880 pSession->connectedProfile.eseCckmInfo.reassoc_req_num;
881 pProfile->eseCckmInfo.krk_plumbed =
882 pSession->connectedProfile.eseCckmInfo.krk_plumbed;
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 }
884#endif
885 }while(0);
886 }
887 }
888
889 return (status);
890}
891
Jeff Johnson295189b2012-06-20 16:38:30 -0700892eHalStatus csrRoamGetConnectProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamConnectedProfile *pProfile)
893{
894 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700895
896 if((csrIsConnStateConnected(pMac, sessionId)) ||
897 (csrIsConnStateIbss(pMac, sessionId)))
Jeff Johnson295189b2012-06-20 16:38:30 -0700898 {
899 if(pProfile)
900 {
901 status = csrRoamCopyConnectProfile(pMac, sessionId, pProfile);
902 }
903 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 return (status);
905}
Jeff Johnsonfec1ecb2013-05-03 08:10:33 -0700906
Jeff Johnson295189b2012-06-20 16:38:30 -0700907eHalStatus csrRoamFreeConnectProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile)
908{
909 eHalStatus status = eHAL_STATUS_SUCCESS;
910
Kiet Lam64c1b492013-07-12 13:56:44 +0530911 if (pProfile->pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530913 vos_mem_free(pProfile->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530915 if (pProfile->pAddIEAssoc)
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700916 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530917 vos_mem_free(pProfile->pAddIEAssoc);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -0700918 }
Kiet Lam64c1b492013-07-12 13:56:44 +0530919 vos_mem_set(pProfile, sizeof(tCsrRoamConnectedProfile), 0);
920
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 pProfile->AuthType = eCSR_AUTH_TYPE_UNKNOWN;
922 return (status);
923}
924
Jeff Johnson295189b2012-06-20 16:38:30 -0700925static eHalStatus csrRoamFreeConnectedInfo( tpAniSirGlobal pMac, tCsrRoamConnectedInfo *pConnectedInfo )
926{
927 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -0700928 if( pConnectedInfo->pbFrames )
929 {
Kiet Lam64c1b492013-07-12 13:56:44 +0530930 vos_mem_free(pConnectedInfo->pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -0700931 pConnectedInfo->pbFrames = NULL;
932 }
933 pConnectedInfo->nBeaconLength = 0;
934 pConnectedInfo->nAssocReqLength = 0;
935 pConnectedInfo->nAssocRspLength = 0;
936 pConnectedInfo->staId = 0;
937#ifdef WLAN_FEATURE_VOWIFI_11R
938 pConnectedInfo->nRICRspLength = 0;
939#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800940#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700941 pConnectedInfo->nTspecIeLength = 0;
942#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700943 return ( status );
944}
945
Jeff Johnson295189b2012-06-20 16:38:30 -0700946
947
Jeff Johnsone7245742012-09-05 17:12:55 -0700948
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -0700949void csrReleaseCommandPreauth(tpAniSirGlobal pMac, tSmeCmd *pCommand)
950{
951 csrReinitPreauthCmd(pMac, pCommand);
952 csrReleaseCommand( pMac, pCommand );
953}
954
Jeff Johnson295189b2012-06-20 16:38:30 -0700955void csrReleaseCommandRoam(tpAniSirGlobal pMac, tSmeCmd *pCommand)
956{
957 csrReinitRoamCmd(pMac, pCommand);
958 csrReleaseCommand( pMac, pCommand );
959}
960
Jeff Johnson295189b2012-06-20 16:38:30 -0700961void csrReleaseCommandScan(tpAniSirGlobal pMac, tSmeCmd *pCommand)
962{
963 csrReinitScanCmd(pMac, pCommand);
964 csrReleaseCommand( pMac, pCommand );
965}
966
Jeff Johnson295189b2012-06-20 16:38:30 -0700967void csrReleaseCommandWmStatusChange(tpAniSirGlobal pMac, tSmeCmd *pCommand)
968{
969 csrReinitWmStatusChangeCmd(pMac, pCommand);
970 csrReleaseCommand( pMac, pCommand );
971}
972
Jeff Johnson295189b2012-06-20 16:38:30 -0700973void csrReinitSetKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
974{
Kiet Lam64c1b492013-07-12 13:56:44 +0530975 vos_mem_set(&pCommand->u.setKeyCmd, sizeof(tSetKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700976}
977
Jeff Johnson295189b2012-06-20 16:38:30 -0700978void csrReinitRemoveKeyCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
979{
Kiet Lam64c1b492013-07-12 13:56:44 +0530980 vos_mem_set(&pCommand->u.removeKeyCmd, sizeof(tRemoveKeyCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -0700981}
982
Jeff Johnson295189b2012-06-20 16:38:30 -0700983void csrReleaseCommandSetKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
984{
985 csrReinitSetKeyCmd(pMac, pCommand);
986 csrReleaseCommand( pMac, pCommand );
987}
Jeff Johnson295189b2012-06-20 16:38:30 -0700988void csrReleaseCommandRemoveKey(tpAniSirGlobal pMac, tSmeCmd *pCommand)
989{
990 csrReinitRemoveKeyCmd(pMac, pCommand);
991 csrReleaseCommand( pMac, pCommand );
992}
Jeff Johnson295189b2012-06-20 16:38:30 -0700993void csrAbortCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fStopping )
994{
995
996 if( eSmeCsrCommandMask & pCommand->command )
997 {
998 switch (pCommand->command)
999 {
1000 case eSmeCommandScan:
Jeff Johnson1250df42012-12-10 14:31:52 -08001001 // We need to inform the requester before dropping the scan command
Jeff Johnsonc7c54b12013-11-17 11:49:03 -08001002 smsLog( pMac, LOGW, "%s: Drop scan reason %d callback %p",
1003 __func__, pCommand->u.scanCmd.reason,
1004 pCommand->u.scanCmd.callback);
Jeff Johnson295189b2012-06-20 16:38:30 -07001005 if (NULL != pCommand->u.scanCmd.callback)
1006 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001007 smsLog( pMac, LOGW, "%s callback scan requester", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 csrScanCallCallback(pMac, pCommand, eCSR_SCAN_ABORT);
1009 }
1010 csrReleaseCommandScan( pMac, pCommand );
1011 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07001012 case eSmeCommandRoam:
1013 csrReleaseCommandRoam( pMac, pCommand );
1014 break;
1015
1016 case eSmeCommandWmStatusChange:
1017 csrReleaseCommandWmStatusChange( pMac, pCommand );
1018 break;
1019
1020 case eSmeCommandSetKey:
1021 csrReleaseCommandSetKey( pMac, pCommand );
1022 break;
1023
1024 case eSmeCommandRemoveKey:
1025 csrReleaseCommandRemoveKey( pMac, pCommand );
1026 break;
1027
1028 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001029 smsLog( pMac, LOGW, " CSR abort standard command %d", pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 csrReleaseCommand( pMac, pCommand );
1031 break;
1032 }
1033 }
1034}
1035
Jeff Johnson295189b2012-06-20 16:38:30 -07001036void csrRoamSubstateChange( tpAniSirGlobal pMac, eCsrRoamSubState NewSubstate, tANI_U32 sessionId)
1037{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301038 smsLog(pMac, LOG1, FL("CSR RoamSubstate: [ %s <== %s ]"),
1039 macTraceGetcsrRoamSubState(NewSubstate),
1040 macTraceGetcsrRoamSubState(pMac->roam.curSubState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001041
Jeff Johnson295189b2012-06-20 16:38:30 -07001042 if(pMac->roam.curSubState[sessionId] == NewSubstate)
1043 {
1044 return;
Jeff Johnsone7245742012-09-05 17:12:55 -07001045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001046 pMac->roam.curSubState[sessionId] = NewSubstate;
1047}
1048
Jeff Johnson295189b2012-06-20 16:38:30 -07001049eCsrRoamState csrRoamStateChange( tpAniSirGlobal pMac, eCsrRoamState NewRoamState, tANI_U8 sessionId)
1050{
1051 eCsrRoamState PreviousState;
1052
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05301053 smsLog(pMac, LOG1, FL("CSR RoamState[%hu]: [ %s <== %s ]"), sessionId,
1054 macTraceGetcsrRoamState(NewRoamState),
1055 macTraceGetcsrRoamState(pMac->roam.curState[sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07001056
1057 PreviousState = pMac->roam.curState[sessionId];
1058
1059 if ( NewRoamState != pMac->roam.curState[sessionId] )
1060 {
1061 // Whenever we transition OUT of the Roaming state, clear the Roaming substate...
1062 if ( CSR_IS_ROAM_JOINING(pMac, sessionId) )
1063 {
1064 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
1065 }
1066
1067 pMac->roam.curState[sessionId] = NewRoamState;
1068 }
1069 return( PreviousState );
1070}
1071
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001072void csrAssignRssiForCategory(tpAniSirGlobal pMac, tANI_S8 bestApRssi, tANI_U8 catOffset)
Jeff Johnson295189b2012-06-20 16:38:30 -07001073{
1074 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 if(catOffset)
1076 {
1077 pMac->roam.configParam.bCatRssiOffset = catOffset;
1078 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1079 {
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001080 pMac->roam.configParam.RSSICat[CSR_NUM_RSSI_CAT - i - 1] = (int)bestApRssi - pMac->roam.configParam.nSelect5GHzMargin - (int)(i * catOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001081 }
1082 }
1083}
1084
Jeff Johnson295189b2012-06-20 16:38:30 -07001085static void initConfigParam(tpAniSirGlobal pMac)
1086{
1087 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 pMac->roam.configParam.agingCount = CSR_AGING_COUNT;
Sandeep Puligilla60342762014-01-30 21:05:37 +05301089 pMac->roam.configParam.channelBondingMode24GHz =
1090 WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
1091 pMac->roam.configParam.channelBondingMode5GHz =
1092 WNI_CFG_CHANNEL_BONDING_MODE_ENABLE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001093 pMac->roam.configParam.phyMode = eCSR_DOT11_MODE_TAURUS;
1094 pMac->roam.configParam.eBand = eCSR_BAND_ALL;
1095 pMac->roam.configParam.uCfgDot11Mode = eCSR_CFG_DOT11_MODE_TAURUS;
1096 pMac->roam.configParam.FragmentationThreshold = eCSR_DOT11_FRAG_THRESH_DEFAULT;
1097 pMac->roam.configParam.HeartbeatThresh24 = 40;
1098 pMac->roam.configParam.HeartbeatThresh50 = 40;
1099 pMac->roam.configParam.Is11dSupportEnabled = eANI_BOOLEAN_FALSE;
1100 pMac->roam.configParam.Is11dSupportEnabledOriginal = eANI_BOOLEAN_FALSE;
1101 pMac->roam.configParam.Is11eSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnsone7245742012-09-05 17:12:55 -07001102 pMac->roam.configParam.Is11hSupportEnabled = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 pMac->roam.configParam.RTSThreshold = 2346;
1104 pMac->roam.configParam.shortSlotTime = eANI_BOOLEAN_TRUE;
1105 pMac->roam.configParam.WMMSupportMode = eCsrRoamWmmAuto;
1106 pMac->roam.configParam.ProprietaryRatesEnabled = eANI_BOOLEAN_TRUE;
1107 pMac->roam.configParam.TxRate = eCSR_TX_RATE_AUTO;
1108 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1109 pMac->roam.configParam.scanAgeTimeNCNPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_NO_PS;
1110 pMac->roam.configParam.scanAgeTimeNCPS = CSR_SCAN_AGING_TIME_NOT_CONNECT_W_PS;
1111 pMac->roam.configParam.scanAgeTimeCNPS = CSR_SCAN_AGING_TIME_CONNECT_NO_PS;
1112 pMac->roam.configParam.scanAgeTimeCPS = CSR_SCAN_AGING_TIME_CONNECT_W_PS;
1113 for(i = 0; i < CSR_NUM_RSSI_CAT; i++)
1114 {
1115 pMac->roam.configParam.BssPreferValue[i] = i;
1116 }
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001117 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, CSR_DEFAULT_RSSI_DB_GAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07001118 pMac->roam.configParam.nRoamingTime = CSR_DEFAULT_ROAMING_TIME;
1119 pMac->roam.configParam.fEnforce11dChannels = eANI_BOOLEAN_FALSE;
1120 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001121 pMac->roam.configParam.fEnforceCountryCodeMatch = eANI_BOOLEAN_FALSE;
1122 pMac->roam.configParam.fEnforceDefaultDomain = eANI_BOOLEAN_FALSE;
Abhishek Singh2ec36ab2014-08-07 16:14:25 +05301123 pMac->roam.configParam.fEnforceCountryCode = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001124 pMac->roam.configParam.nActiveMaxChnTime = CSR_ACTIVE_MAX_CHANNEL_TIME;
1125 pMac->roam.configParam.nActiveMinChnTime = CSR_ACTIVE_MIN_CHANNEL_TIME;
1126 pMac->roam.configParam.nPassiveMaxChnTime = CSR_PASSIVE_MAX_CHANNEL_TIME;
1127 pMac->roam.configParam.nPassiveMinChnTime = CSR_PASSIVE_MIN_CHANNEL_TIME;
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001128 pMac->roam.configParam.nActiveMaxChnTimeBtc = CSR_ACTIVE_MAX_CHANNEL_TIME_BTC;
1129 pMac->roam.configParam.nActiveMinChnTimeBtc = CSR_ACTIVE_MIN_CHANNEL_TIME_BTC;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001130 pMac->roam.configParam.disableAggWithBtc = eANI_BOOLEAN_TRUE;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001131#ifdef WLAN_AP_STA_CONCURRENCY
1132 pMac->roam.configParam.nActiveMaxChnTimeConc = CSR_ACTIVE_MAX_CHANNEL_TIME_CONC;
1133 pMac->roam.configParam.nActiveMinChnTimeConc = CSR_ACTIVE_MIN_CHANNEL_TIME_CONC;
1134 pMac->roam.configParam.nPassiveMaxChnTimeConc = CSR_PASSIVE_MAX_CHANNEL_TIME_CONC;
1135 pMac->roam.configParam.nPassiveMinChnTimeConc = CSR_PASSIVE_MIN_CHANNEL_TIME_CONC;
1136 pMac->roam.configParam.nRestTimeConc = CSR_REST_TIME_CONC;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001137 pMac->roam.configParam.nNumStaChanCombinedConc = CSR_NUM_STA_CHAN_COMBINED_CONC;
1138 pMac->roam.configParam.nNumP2PChanCombinedConc = CSR_NUM_P2P_CHAN_COMBINED_CONC;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001139#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 pMac->roam.configParam.IsIdleScanEnabled = TRUE; //enable the idle scan by default
1141 pMac->roam.configParam.nTxPowerCap = CSR_MAX_TX_POWER;
1142 pMac->roam.configParam.statsReqPeriodicity = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD;
1143 pMac->roam.configParam.statsReqPeriodicityInPS = CSR_MIN_GLOBAL_STAT_QUERY_PERIOD_IN_BMPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001144#ifdef WLAN_FEATURE_VOWIFI_11R
1145 pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported = 0;
1146#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001147#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
1148 pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries = 3;
1149 pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold = 120;
1150 pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold = 125;
1151 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime = 20;
1152 pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime = 40;
1153 pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod = 200;
1154 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels = 3;
1155 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[0] = 1;
1156 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[1] = 6;
1157 pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[2] = 11;
1158 pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod = 20000; //20 seconds
Srinivas Girigowdade697412013-02-14 16:31:48 -08001159 pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod = 0;
Mukul Sharma20aa6582014-08-07 21:36:12 +05301160 pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001161#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001162#ifdef WLAN_FEATURE_11AC
1163 pMac->roam.configParam.nVhtChannelWidth = WNI_CFG_VHT_CHANNEL_WIDTH_80MHZ + 1;
1164#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001165
1166 pMac->roam.configParam.addTSWhenACMIsOff = 0;
1167 pMac->roam.configParam.fScanTwice = eANI_BOOLEAN_FALSE;
Mohit Khanna349bc392012-09-11 17:24:52 -07001168
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001169 //Remove this code once SLM_Sessionization is supported
1170 //BMPS_WORKAROUND_NOT_NEEDED
Jeff Johnsone7245742012-09-05 17:12:55 -07001171 pMac->roam.configParam.doBMPSWorkaround = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07001172
Jeff Johnsone7245742012-09-05 17:12:55 -07001173}
Jeff Johnson295189b2012-06-20 16:38:30 -07001174eCsrBand csrGetCurrentBand(tHalHandle hHal)
1175{
1176 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1177 return pMac->roam.configParam.bandCapability;
1178}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001179
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001180
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001181#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001182/*
1183 This function flushes the roam scan cache
1184*/
1185eHalStatus csrFlushRoamScanRoamChannelList(tpAniSirGlobal pMac)
1186{
1187 eHalStatus status = eHAL_STATUS_SUCCESS;
1188 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1189
1190 /* Free up the memory first (if required) */
1191 if (NULL != pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList)
1192 {
1193 vos_mem_free(pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList);
1194 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.ChannelList = NULL;
1195 pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo.numOfChannels = 0;
1196 }
1197 return status;
1198}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001199#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001200
1201
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001202#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001203/*
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001204 This function flushes the roam scan cache
Srinivas Girigowdade697412013-02-14 16:31:48 -08001205*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001206eHalStatus csrFlushCfgBgScanRoamChannelList(tpAniSirGlobal pMac)
Srinivas Girigowdade697412013-02-14 16:31:48 -08001207{
1208 eHalStatus status = eHAL_STATUS_SUCCESS;
1209 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1210
1211 /* Free up the memory first (if required) */
1212 if (NULL != pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1213 {
1214 vos_mem_free(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList);
1215 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList = NULL;
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001216 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
Srinivas Girigowdade697412013-02-14 16:31:48 -08001217 }
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001218 return status;
1219}
1220
1221
1222
1223/*
1224 This function flushes the roam scan cache and creates fresh cache
1225 based on the input channel list
1226*/
1227eHalStatus csrCreateBgScanRoamChannelList(tpAniSirGlobal pMac,
1228 const tANI_U8 *pChannelList,
1229 const tANI_U8 numChannels)
1230{
1231 eHalStatus status = eHAL_STATUS_SUCCESS;
1232 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1233
Srinivas Girigowdade697412013-02-14 16:31:48 -08001234 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = numChannels;
1235
1236 pNeighborRoamInfo->cfgParams.channelInfo.ChannelList =
1237 vos_mem_malloc(pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
1238
1239 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1240 {
1241 smsLog(pMac, LOGE, FL("Memory Allocation for CFG Channel List failed"));
1242 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels = 0;
1243 return eHAL_STATUS_RESOURCES;
1244 }
1245
1246 /* Update the roam global structure */
Kiet Lam64c1b492013-07-12 13:56:44 +05301247 vos_mem_copy(pNeighborRoamInfo->cfgParams.channelInfo.ChannelList,
1248 pChannelList,
1249 pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001250 return status;
1251}
1252
1253/* This function modifies the bgscan channel list set via config ini or
1254 runtime, whenever the band changes.
1255 if the band is auto, then no operation is performed on the channel list
1256 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1257 if the band is 5G, then make sure channel list contains only 5G valid channels
1258*/
1259eHalStatus csrUpdateBgScanConfigIniChannelList(tpAniSirGlobal pMac,
1260 eCsrBand eBand)
1261{
1262 eHalStatus status = eHAL_STATUS_SUCCESS;
1263 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1264 tANI_U8 outNumChannels = 0;
1265 tANI_U8 inNumChannels = 0;
1266 tANI_U8 *inPtr = NULL;
1267 tANI_U8 i = 0;
1268 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1269
1270 if (NULL == pNeighborRoamInfo->cfgParams.channelInfo.ChannelList)
1271
1272 {
1273 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
1274 "No update required for channel list "
1275 "either cfg.ini channel list is not set up or "
1276 "auto band (Band %d)", eBand);
1277 return status;
1278 }
1279
1280 inNumChannels = pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels;
1281 inPtr = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
1282 if (eCSR_BAND_24 == eBand)
1283 {
1284 for (i = 0; i < inNumChannels; i++)
1285 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001286 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
Srinivas Girigowdade697412013-02-14 16:31:48 -08001287 {
1288 ChannelList[outNumChannels++] = inPtr[i];
1289 }
1290 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001291 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001292 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001293 }
1294 else if (eCSR_BAND_5G == eBand)
1295 {
1296 for (i = 0; i < inNumChannels; i++)
1297 {
1298 /* Add 5G Non-DFS channel */
1299 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
Srinivas Girigowda56076852013-08-20 14:00:50 -07001300 csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001301 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1302 {
1303 ChannelList[outNumChannels++] = inPtr[i];
1304 }
1305 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001306 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001307 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001308 }
1309 else if (eCSR_BAND_ALL == eBand)
1310 {
1311 for (i = 0; i < inNumChannels; i++)
1312 {
Srinivas Girigowda56076852013-08-20 14:00:50 -07001313 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
Srinivas Girigowdade697412013-02-14 16:31:48 -08001314 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1315 {
1316 ChannelList[outNumChannels++] = inPtr[i];
1317 }
1318 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001319 csrFlushCfgBgScanRoamChannelList(pMac);
Srinivas Girigowda100eb322013-03-15 16:48:20 -07001320 csrCreateBgScanRoamChannelList(pMac, ChannelList, outNumChannels);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001321 }
1322 else
1323 {
1324 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1325 "Invalid band, No operation carried out (Band %d)", eBand);
1326 status = eHAL_STATUS_INVALID_PARAMETER;
1327 }
1328
1329 return status;
1330}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001331#endif
1332
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001333#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001334/* This function modifies the roam scan channel list as per AP neighbor
1335 report; AP neighbor report may be empty or may include only other AP
1336 channels; in any case, we merge the channel list with the learned occupied
1337 channels list.
1338 if the band is 2.4G, then make sure channel list contains only 2.4G valid channels
1339 if the band is 5G, then make sure channel list contains only 5G valid channels
1340*/
1341eHalStatus csrCreateRoamScanChannelList(tpAniSirGlobal pMac,
1342 tANI_U8 *pChannelList,
1343 tANI_U8 numChannels,
1344 const eCsrBand eBand)
1345{
1346 eHalStatus status = eHAL_STATUS_SUCCESS;
1347 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
1348 tANI_U8 outNumChannels = 0;
1349 tANI_U8 inNumChannels = numChannels;
1350 tANI_U8 *inPtr = pChannelList;
1351 tANI_U8 i = 0;
1352 tANI_U8 ChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1353 tANI_U8 tmpChannelList[WNI_CFG_VALID_CHANNEL_LIST_LEN] = {0};
1354 tANI_U8 mergedOutputNumOfChannels = 0;
1355 tpCsrChannelInfo currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
1356
1357 /* Create a Union of occupied channel list learnt by the DUT along with the Neighbor
1358 * report Channels. This increases the chances of the DUT to get a candidate AP while
1359 * roaming even if the Neighbor Report is not able to provide sufficient information. */
1360 if (pMac->scan.occupiedChannels.numChannels)
1361 {
1362 csrNeighborRoamMergeChannelLists(pMac,
1363 &pMac->scan.occupiedChannels.channelList[0],
1364 pMac->scan.occupiedChannels.numChannels,
1365 inPtr,
1366 inNumChannels,
1367 &mergedOutputNumOfChannels);
1368 inNumChannels = mergedOutputNumOfChannels;
1369 }
1370
1371 if (eCSR_BAND_24 == eBand)
1372 {
1373 for (i = 0; i < inNumChannels; i++)
1374 {
1375 if (CSR_IS_CHANNEL_24GHZ(inPtr[i]) && csrRoamIsChannelValid(pMac, inPtr[i]))
1376 {
1377 ChannelList[outNumChannels++] = inPtr[i];
1378 }
1379 }
1380 }
1381 else if (eCSR_BAND_5G == eBand)
1382 {
1383 for (i = 0; i < inNumChannels; i++)
1384 {
1385 /* Add 5G Non-DFS channel */
1386 if (CSR_IS_CHANNEL_5GHZ(inPtr[i]) &&
1387 csrRoamIsChannelValid(pMac, inPtr[i]) &&
1388 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1389 {
1390 ChannelList[outNumChannels++] = inPtr[i];
1391 }
1392 }
1393 }
1394 else if (eCSR_BAND_ALL == eBand)
1395 {
1396 for (i = 0; i < inNumChannels; i++)
1397 {
1398 if (csrRoamIsChannelValid(pMac, inPtr[i]) &&
1399 !CSR_IS_CHANNEL_DFS(inPtr[i]))
1400 {
1401 ChannelList[outNumChannels++] = inPtr[i];
1402 }
1403 }
1404 }
1405 else
1406 {
1407 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
1408 "Invalid band, No operation carried out (Band %d)", eBand);
1409 return eHAL_STATUS_INVALID_PARAMETER;
1410 }
1411
1412 /* if roaming within band is enabled, then select only the
1413 in band channels .
1414 This is required only if the band capability is set to ALL,
1415 E.g., if band capability is only 2.4G then all the channels in the
1416 list are already filtered for 2.4G channels, hence ignore this check*/
1417
1418 if ((eCSR_BAND_ALL == eBand) && CSR_IS_ROAM_INTRA_BAND_ENABLED(pMac))
1419 {
Mukul Sharma20aa6582014-08-07 21:36:12 +05301420 csrNeighborRoamChannelsFilterByBand(
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001421 pMac,
1422 ChannelList,
1423 outNumChannels,
1424 tmpChannelList,
Mukul Sharma20aa6582014-08-07 21:36:12 +05301425 &outNumChannels,
1426 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel));
Kiet Lamf2f201e2013-11-16 21:24:16 +05301427 vos_mem_copy(ChannelList,
1428 tmpChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001429 }
1430
1431 /* Prepare final roam scan channel list */
1432 if(outNumChannels)
1433 {
1434 /* Clear the channel list first */
1435 if (NULL != currChannelListInfo->ChannelList)
1436 {
1437 vos_mem_free(currChannelListInfo->ChannelList);
1438 currChannelListInfo->ChannelList = NULL;
1439 currChannelListInfo->numOfChannels = 0;
1440 }
1441
1442 currChannelListInfo->ChannelList = vos_mem_malloc(outNumChannels * sizeof(tANI_U8));
1443 if (NULL == currChannelListInfo->ChannelList)
1444 {
1445 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
1446 "Failed to allocate memory for roam scan channel list");
1447 currChannelListInfo->numOfChannels = 0;
1448 return VOS_STATUS_E_RESOURCES;
1449 }
Kiet Lamf2f201e2013-11-16 21:24:16 +05301450 vos_mem_copy(currChannelListInfo->ChannelList,
1451 ChannelList, outNumChannels);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001452 }
1453 return status;
1454}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001455#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07001456
Jeff Johnson295189b2012-06-20 16:38:30 -07001457eHalStatus csrSetBand(tHalHandle hHal, eCsrBand eBand)
1458{
1459 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
1460 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 if (CSR_IS_PHY_MODE_A_ONLY(pMac) &&
1462 (eBand == eCSR_BAND_24))
1463 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001464 /* DOT11 mode configured to 11a only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001465 request to change the band to 2.4 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001466 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001467 "failed to set band cfg80211 = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001468 pMac->roam.configParam.uCfgDot11Mode, eBand);
1469 return eHAL_STATUS_INVALID_PARAMETER;
1470 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 if ((CSR_IS_PHY_MODE_B_ONLY(pMac) ||
1472 CSR_IS_PHY_MODE_G_ONLY(pMac)) &&
1473 (eBand == eCSR_BAND_5G))
1474 {
Srinivas Girigowdade697412013-02-14 16:31:48 -08001475 /* DOT11 mode configured to 11b/11g only and received
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 request to change the band to 5 GHz */
Srinivas Girigowdade697412013-02-14 16:31:48 -08001477 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001478 "failed to set band dot11mode = %u, band = %u",
Jeff Johnson295189b2012-06-20 16:38:30 -07001479 pMac->roam.configParam.uCfgDot11Mode, eBand);
1480 return eHAL_STATUS_INVALID_PARAMETER;
1481 }
Srinivas Girigowdade697412013-02-14 16:31:48 -08001482 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001483 "Band changed to %u (0 - ALL, 1 - 2.4 GHZ, 2 - 5GHZ)", eBand);
Srinivas Girigowdade697412013-02-14 16:31:48 -08001484 pMac->roam.configParam.eBand = eBand;
1485 pMac->roam.configParam.bandCapability = eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001486 csrScanGetSupportedChannels( pMac );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001487#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -08001488 if (!csrRoamIsRoamOffloadScanEnabled(pMac))
1489 csrUpdateBgScanConfigIniChannelList( pMac, eBand );
Srinivas Girigowdade697412013-02-14 16:31:48 -08001490#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001491 status = csrInitGetChannels( pMac );
1492 if (eHAL_STATUS_SUCCESS == status)
1493 csrInitChannelList( hHal );
1494 return status;
1495}
Srinivas Girigowdade697412013-02-14 16:31:48 -08001496
1497
Jeff Johnsone7245742012-09-05 17:12:55 -07001498/* The funcns csrConvertCBIniValueToPhyCBState and csrConvertPhyCBStateToIniValue have been
1499 * introduced to convert the ini value to the ENUM used in csr and MAC for CB state
1500 * Ideally we should have kept the ini value and enum value same and representing the same
1501 * cb values as in 11n standard i.e.
1502 * Set to 1 (SCA) if the secondary channel is above the primary channel
1503 * Set to 3 (SCB) if the secondary channel is below the primary channel
1504 * Set to 0 (SCN) if no secondary channel is present
1505 * However, since our driver is already distributed we will keep the ini definition as it is which is:
1506 * 0 - secondary none
1507 * 1 - secondary LOW
1508 * 2 - secondary HIGH
1509 * and convert to enum value used within the driver in csrChangeDefaultConfigParam using this funcn
1510 * The enum values are as follows:
1511 * PHY_SINGLE_CHANNEL_CENTERED = 0
1512 * PHY_DOUBLE_CHANNEL_LOW_PRIMARY = 1
1513 * PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
1514 */
1515ePhyChanBondState csrConvertCBIniValueToPhyCBState(v_U32_t cbIniValue)
1516{
1517
1518 ePhyChanBondState phyCbState;
1519 switch (cbIniValue) {
1520 // secondary none
1521 case 0:
1522 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1523 break;
1524 // secondary LOW
1525 case 1:
1526 phyCbState = PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
1527 break;
1528 // secondary HIGH
1529 case 2:
1530 phyCbState = PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
1531 break;
1532#ifdef WLAN_FEATURE_11AC
1533 case 3:
1534 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED;
1535 break;
1536 case 4:
1537 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1538 break;
1539 case 5:
1540 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED;
1541 break;
1542 case 6:
1543 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW;
1544 break;
1545 case 7:
1546 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW;
1547 break;
1548 case 8:
1549 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH;
1550 break;
1551 case 9:
1552 phyCbState = PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH;
1553 break;
1554#endif
1555 default:
1556 // If an invalid value is passed, disable CHANNEL BONDING
1557 phyCbState = PHY_SINGLE_CHANNEL_CENTERED;
1558 break;
1559 }
1560 return phyCbState;
1561}
1562
1563v_U32_t csrConvertPhyCBStateToIniValue(ePhyChanBondState phyCbState)
1564{
1565
1566 v_U32_t cbIniValue;
1567 switch (phyCbState) {
1568 // secondary none
1569 case PHY_SINGLE_CHANNEL_CENTERED:
1570 cbIniValue = 0;
1571 break;
1572 // secondary LOW
1573 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
1574 cbIniValue = 1;
1575 break;
1576 // secondary HIGH
1577 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
1578 cbIniValue = 2;
1579 break;
1580#ifdef WLAN_FEATURE_11AC
1581 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
1582 cbIniValue = 3;
1583 break;
1584 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
1585 cbIniValue = 4;
1586 break;
1587 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
1588 cbIniValue = 5;
1589 break;
1590 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
1591 cbIniValue = 6;
1592 break;
1593 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
1594 cbIniValue = 7;
1595 break;
1596 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
1597 cbIniValue = 8;
1598 break;
1599 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
1600 cbIniValue = 9;
1601 break;
1602#endif
1603 default:
1604 // return some invalid value
1605 cbIniValue = 10;
1606 break;
1607 }
1608 return cbIniValue;
1609}
Jeff Johnson295189b2012-06-20 16:38:30 -07001610
1611eHalStatus csrChangeDefaultConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1612{
1613 eHalStatus status = eHAL_STATUS_SUCCESS;
1614
1615 if(pParam)
1616 {
1617 pMac->roam.configParam.WMMSupportMode = pParam->WMMSupportMode;
1618 pMac->roam.configParam.Is11eSupportEnabled = pParam->Is11eSupportEnabled;
1619 pMac->roam.configParam.FragmentationThreshold = pParam->FragmentationThreshold;
1620 pMac->roam.configParam.Is11dSupportEnabled = pParam->Is11dSupportEnabled;
1621 pMac->roam.configParam.Is11dSupportEnabledOriginal = pParam->Is11dSupportEnabled;
1622 pMac->roam.configParam.Is11hSupportEnabled = pParam->Is11hSupportEnabled;
1623
1624 pMac->roam.configParam.fenableMCCMode = pParam->fEnableMCCMode;
Mohit Khanna7ed53f02012-09-11 17:52:10 -07001625 pMac->roam.configParam.fAllowMCCGODiffBI = pParam->fAllowMCCGODiffBI;
1626
Jeff Johnsone7245742012-09-05 17:12:55 -07001627 /* channelBondingMode5GHz plays a dual role right now
1628 * 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
1629 * This is how channelBondingMode5GHz works now and this is kept intact to avoid any cfg.ini change
1630 */
1631 if (pParam->channelBondingMode24GHz > MAX_CB_VALUE_IN_INI)
1632 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001633 smsLog( pMac, LOGW, "Invalid CB value from ini in 2.4GHz band %d, CB DISABLED", pParam->channelBondingMode24GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001634 }
1635 pMac->roam.configParam.channelBondingMode24GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode24GHz);
1636 if (pParam->channelBondingMode5GHz > MAX_CB_VALUE_IN_INI)
1637 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001638 smsLog( pMac, LOGW, "Invalid CB value from ini in 5GHz band %d, CB DISABLED", pParam->channelBondingMode5GHz);
Jeff Johnsone7245742012-09-05 17:12:55 -07001639 }
1640 pMac->roam.configParam.channelBondingMode5GHz = csrConvertCBIniValueToPhyCBState(pParam->channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001641 pMac->roam.configParam.RTSThreshold = pParam->RTSThreshold;
1642 pMac->roam.configParam.phyMode = pParam->phyMode;
1643 pMac->roam.configParam.shortSlotTime = pParam->shortSlotTime;
1644 pMac->roam.configParam.HeartbeatThresh24 = pParam->HeartbeatThresh24;
1645 pMac->roam.configParam.HeartbeatThresh50 = pParam->HeartbeatThresh50;
1646 pMac->roam.configParam.ProprietaryRatesEnabled = pParam->ProprietaryRatesEnabled;
1647 pMac->roam.configParam.TxRate = pParam->TxRate;
1648 pMac->roam.configParam.AdHocChannel24 = pParam->AdHocChannel24;
1649 pMac->roam.configParam.AdHocChannel5G = pParam->AdHocChannel5G;
1650 pMac->roam.configParam.bandCapability = pParam->bandCapability;
1651 pMac->roam.configParam.cbChoice = pParam->cbChoice;
1652 pMac->roam.configParam.bgScanInterval = pParam->bgScanInterval;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001653 pMac->roam.configParam.disableAggWithBtc = pParam->disableAggWithBtc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001654 //if HDD passed down non zero values then only update,
1655 //otherwise keep using the defaults
c_hpothu059edb02014-03-12 21:44:28 +05301656 if (pParam->nInitialDwellTime)
1657 {
1658 pMac->roam.configParam.nInitialDwellTime =
1659 pParam->nInitialDwellTime;
1660 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001661 if (pParam->nActiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 {
1663 pMac->roam.configParam.nActiveMaxChnTime = pParam->nActiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301664 cfgSetInt(pMac, WNI_CFG_ACTIVE_MAXIMUM_CHANNEL_TIME,
1665 pParam->nActiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001667 if (pParam->nActiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 {
1669 pMac->roam.configParam.nActiveMinChnTime = pParam->nActiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301670 cfgSetInt(pMac, WNI_CFG_ACTIVE_MINIMUM_CHANNEL_TIME,
1671 pParam->nActiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001673 if (pParam->nPassiveMaxChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 {
1675 pMac->roam.configParam.nPassiveMaxChnTime = pParam->nPassiveMaxChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301676 cfgSetInt(pMac, WNI_CFG_PASSIVE_MAXIMUM_CHANNEL_TIME,
1677 pParam->nPassiveMaxChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001679 if (pParam->nPassiveMinChnTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001680 {
1681 pMac->roam.configParam.nPassiveMinChnTime = pParam->nPassiveMinChnTime;
Rajesh Babu Prathipatib09815c2014-07-05 11:22:24 +05301682 cfgSetInt(pMac, WNI_CFG_PASSIVE_MINIMUM_CHANNEL_TIME,
1683 pParam->nPassiveMinChnTime);
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001685 if (pParam->nActiveMaxChnTimeBtc)
1686 {
1687 pMac->roam.configParam.nActiveMaxChnTimeBtc = pParam->nActiveMaxChnTimeBtc;
1688 }
1689 if (pParam->nActiveMinChnTimeBtc)
1690 {
1691 pMac->roam.configParam.nActiveMinChnTimeBtc = pParam->nActiveMinChnTimeBtc;
1692 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001693#ifdef WLAN_AP_STA_CONCURRENCY
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001694 if (pParam->nActiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001695 {
1696 pMac->roam.configParam.nActiveMaxChnTimeConc = pParam->nActiveMaxChnTimeConc;
1697 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001698 if (pParam->nActiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001699 {
1700 pMac->roam.configParam.nActiveMinChnTimeConc = pParam->nActiveMinChnTimeConc;
1701 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001702 if (pParam->nPassiveMaxChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001703 {
1704 pMac->roam.configParam.nPassiveMaxChnTimeConc = pParam->nPassiveMaxChnTimeConc;
1705 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001706 if (pParam->nPassiveMinChnTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001707 {
1708 pMac->roam.configParam.nPassiveMinChnTimeConc = pParam->nPassiveMinChnTimeConc;
1709 }
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001710 if (pParam->nRestTimeConc)
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001711 {
1712 pMac->roam.configParam.nRestTimeConc = pParam->nRestTimeConc;
1713 }
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001714 if (pParam->nNumStaChanCombinedConc)
Vinay Malekal05fdc812012-12-17 13:04:30 -08001715 {
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001716 pMac->roam.configParam.nNumStaChanCombinedConc = pParam->nNumStaChanCombinedConc;
1717 }
1718 if (pParam->nNumP2PChanCombinedConc)
1719 {
1720 pMac->roam.configParam.nNumP2PChanCombinedConc = pParam->nNumP2PChanCombinedConc;
Vinay Malekal05fdc812012-12-17 13:04:30 -08001721 }
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001722#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001723 //if upper layer wants to disable idle scan altogether set it to 0
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001724 if (pParam->impsSleepTime)
Jeff Johnson295189b2012-06-20 16:38:30 -07001725 {
1726 //Change the unit from second to microsecond
1727 tANI_U32 impsSleepTime = pParam->impsSleepTime * PAL_TIMER_TO_SEC_UNIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07001728 if(CSR_IDLE_SCAN_NO_PS_INTERVAL_MIN <= impsSleepTime)
1729 {
1730 pMac->roam.configParam.impsSleepTime = impsSleepTime;
1731 }
1732 else
1733 {
1734 pMac->roam.configParam.impsSleepTime = CSR_IDLE_SCAN_NO_PS_INTERVAL;
1735 }
1736 }
1737 else
1738 {
1739 pMac->roam.configParam.impsSleepTime = 0;
1740 }
1741 pMac->roam.configParam.eBand = pParam->eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 pMac->roam.configParam.uCfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(NULL, pMac->roam.configParam.phyMode,
1743 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -07001744 //if HDD passed down non zero values for age params, then only update,
1745 //otherwise keep using the defaults
Kiran Kumar Lokere3527f0c2013-02-24 22:21:28 -08001746 if (pParam->nScanResultAgeCount)
Jeff Johnson295189b2012-06-20 16:38:30 -07001747 {
1748 pMac->roam.configParam.agingCount = pParam->nScanResultAgeCount;
1749 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001750 if(pParam->scanAgeTimeNCNPS)
1751 {
1752 pMac->roam.configParam.scanAgeTimeNCNPS = pParam->scanAgeTimeNCNPS;
1753 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001754 if(pParam->scanAgeTimeNCPS)
1755 {
1756 pMac->roam.configParam.scanAgeTimeNCPS = pParam->scanAgeTimeNCPS;
1757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001758 if(pParam->scanAgeTimeCNPS)
1759 {
1760 pMac->roam.configParam.scanAgeTimeCNPS = pParam->scanAgeTimeCNPS;
1761 }
1762 if(pParam->scanAgeTimeCPS)
1763 {
1764 pMac->roam.configParam.scanAgeTimeCPS = pParam->scanAgeTimeCPS;
1765 }
c_hpothu0d5a7352014-03-22 12:30:25 +05301766 if (pParam->initialScanSkipDFSCh)
1767 {
1768 pMac->roam.configParam.initialScanSkipDFSCh =
1769 pParam->initialScanSkipDFSCh;
1770 }
1771
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001772 csrAssignRssiForCategory(pMac, CSR_BEST_RSSI_VALUE, pParam->bCatRssiOffset);
Jeff Johnson295189b2012-06-20 16:38:30 -07001773 pMac->roam.configParam.nRoamingTime = pParam->nRoamingTime;
1774 pMac->roam.configParam.fEnforce11dChannels = pParam->fEnforce11dChannels;
1775 pMac->roam.configParam.fSupplicantCountryCodeHasPriority = pParam->fSupplicantCountryCodeHasPriority;
1776 pMac->roam.configParam.fEnforceCountryCodeMatch = pParam->fEnforceCountryCodeMatch;
1777 pMac->roam.configParam.fEnforceDefaultDomain = pParam->fEnforceDefaultDomain;
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 pMac->roam.configParam.vccRssiThreshold = pParam->vccRssiThreshold;
1779 pMac->roam.configParam.vccUlMacLossThreshold = pParam->vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001780 pMac->roam.configParam.IsIdleScanEnabled = pParam->IsIdleScanEnabled;
1781 pMac->roam.configParam.statsReqPeriodicity = pParam->statsReqPeriodicity;
1782 pMac->roam.configParam.statsReqPeriodicityInPS = pParam->statsReqPeriodicityInPS;
1783 //Assign this before calling CsrInit11dInfo
1784 pMac->roam.configParam.nTxPowerCap = pParam->nTxPowerCap;
Jeff Johnson295189b2012-06-20 16:38:30 -07001785 if( csrIs11dSupported( pMac ) )
1786 {
1787 status = CsrInit11dInfo(pMac, &pParam->Csr11dinfo);
1788 }
1789 else
1790 {
1791 pMac->scan.curScanType = eSIR_ACTIVE_SCAN;
1792 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001793
1794 /* Initialize the power + channel information if 11h is enabled.
1795 If 11d is enabled this information has already been initialized */
1796 if( csrIs11hSupported( pMac ) && !csrIs11dSupported( pMac ) )
1797 {
1798 csrInitChannelPowerList(pMac, &pParam->Csr11dinfo);
1799 }
1800
1801
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +05301802#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301803 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1804 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001805 smsLog( pMac, LOG1, "IsFTResourceReqSupp = %d", pMac->roam.configParam.csr11rConfig.IsFTResourceReqSupported);
Jeff Johnson295189b2012-06-20 16:38:30 -07001806#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001807#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001808 pMac->roam.configParam.isFastTransitionEnabled = pParam->isFastTransitionEnabled;
Jeff Johnson43971f52012-07-17 12:26:56 -07001809 pMac->roam.configParam.RoamRssiDiff = pParam->RoamRssiDiff;
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001810 pMac->roam.configParam.nImmediateRoamRssiDiff = pParam->nImmediateRoamRssiDiff;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001811 smsLog( pMac, LOG1, "nImmediateRoamRssiDiff = %d",
Madan Mohan Koyyalamudi62b55b02012-12-03 16:45:39 -08001812 pMac->roam.configParam.nImmediateRoamRssiDiff );
Madan Mohan Koyyalamudid5026072012-11-30 14:56:21 -08001813 pMac->roam.configParam.nRoamPrefer5GHz = pParam->nRoamPrefer5GHz;
Srinivas Girigowdabbd16eb2013-03-21 12:34:46 -07001814 pMac->roam.configParam.nRoamIntraBand = pParam->nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001815 pMac->roam.configParam.isWESModeEnabled = pParam->isWESModeEnabled;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -07001816 pMac->roam.configParam.nProbes = pParam->nProbes;
1817 pMac->roam.configParam.nRoamScanHomeAwayTime = pParam->nRoamScanHomeAwayTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001818#endif
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001819#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1820 pMac->roam.configParam.isRoamOffloadScanEnabled = pParam->isRoamOffloadScanEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001821 pMac->roam.configParam.bFastRoamInConIniFeatureEnabled = pParam->bFastRoamInConIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07001822#endif
1823#ifdef FEATURE_WLAN_LFR
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001824 pMac->roam.configParam.isFastRoamIniFeatureEnabled = pParam->isFastRoamIniFeatureEnabled;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -08001825 pMac->roam.configParam.MAWCEnabled = pParam->MAWCEnabled;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001826#endif
1827
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001828#ifdef FEATURE_WLAN_ESE
1829 pMac->roam.configParam.isEseIniFeatureEnabled = pParam->isEseIniFeatureEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07001830#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001831#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301832 vos_mem_copy(&pMac->roam.configParam.neighborRoamConfig,
1833 &pParam->neighborRoamConfig, sizeof(tCsrNeighborRoamConfigParams));
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001834 smsLog( pMac, LOG1, "nNeighborScanTimerPerioid = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanTimerPeriod);
1835 smsLog( pMac, LOG1, "nNeighborReassocRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborReassocRssiThreshold);
1836 smsLog( pMac, LOG1, "nNeighborLookupRssiThreshold = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborLookupRssiThreshold);
1837 smsLog( pMac, LOG1, "nNeighborScanMinChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMinChanTime);
1838 smsLog( pMac, LOG1, "nNeighborScanMaxChanTime = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborScanMaxChanTime);
1839 smsLog( pMac, LOG1, "nMaxNeighborRetries = %d", pMac->roam.configParam.neighborRoamConfig.nMaxNeighborRetries);
1840 smsLog( pMac, LOG1, "nNeighborResultsRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborResultsRefreshPeriod);
1841 smsLog( pMac, LOG1, "nEmptyScanRefreshPeriod = %d", pMac->roam.configParam.neighborRoamConfig.nEmptyScanRefreshPeriod);
Mukul Sharma20aa6582014-08-07 21:36:12 +05301842 smsLog( pMac, LOG1, "nNeighborInitialForcedRoamTo5GhEnable = %d", pMac->roam.configParam.neighborRoamConfig.nNeighborInitialForcedRoamTo5GhEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07001843 {
1844 int i;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08001845 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 -07001846 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
1847 {
1848 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
1849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001850 }
1851#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001852 pMac->roam.configParam.addTSWhenACMIsOff = pParam->addTSWhenACMIsOff;
1853 pMac->scan.fValidateList = pParam->fValidateList;
1854 pMac->scan.fEnableBypass11d = pParam->fEnableBypass11d;
1855 pMac->scan.fEnableDFSChnlScan = pParam->fEnableDFSChnlScan;
Sandeep Puligilla2b6dc632012-12-17 14:44:16 -08001856 pMac->scan.scanResultCfgAgingTime = pParam->scanCfgAgingTime;
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 pMac->roam.configParam.fScanTwice = pParam->fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001858 pMac->scan.fFirstScanOnly2GChnl = pParam->fFirstScanOnly2GChnl;
Peng Xu2446a892014-09-05 17:21:18 +05301859 pMac->scan.scanBandPreference = pParam->scanBandPreference;
Jeff Johnsone7245742012-09-05 17:12:55 -07001860 /* This parameter is not available in cfg and not passed from upper layers. Instead it is initialized here
1861 * This paramtere is used in concurrency to determine if there are concurrent active sessions.
1862 * Is used as a temporary fix to disconnect all active sessions when BMPS enabled so the active session if Infra STA
1863 * will automatically connect back and resume BMPS since resume BMPS is not working when moving from concurrent to
1864 * single session
1865 */
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07001866 //Remove this code once SLM_Sessionization is supported
1867 //BMPS_WORKAROUND_NOT_NEEDED
Mohit Khanna349bc392012-09-11 17:24:52 -07001868 pMac->roam.configParam.doBMPSWorkaround = 0;
1869
Jeff Johnsone7245742012-09-05 17:12:55 -07001870#ifdef WLAN_FEATURE_11AC
1871 pMac->roam.configParam.nVhtChannelWidth = pParam->nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001872 pMac->roam.configParam.txBFEnable= pParam->enableTxBF;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001873 pMac->roam.configParam.txBFCsnValue = pParam->txBFCsnValue;
Ravi Joshi83bfaa12013-05-28 22:12:08 -07001874 pMac->roam.configParam.enableVhtFor24GHz = pParam->enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301875 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1876 if ( pParam->enableTxBF )
1877 pMac->roam.configParam.txMuBformee= pParam->enableMuBformee;
1878 else
1879 pMac->roam.configParam.txMuBformee= 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001880#endif
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -08001881 pMac->roam.configParam.txLdpcEnable = pParam->enableTxLdpc;
krunal soni5afa96c2013-09-06 22:19:02 -07001882
1883 pMac->roam.configParam.isAmsduSupportInAMPDU = pParam->isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07001884 pMac->roam.configParam.nSelect5GHzMargin = pParam->nSelect5GHzMargin;
krunal sonie9002db2013-11-25 14:24:17 -08001885 pMac->roam.configParam.isCoalesingInIBSSAllowed =
1886 pParam->isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05301887 pMac->roam.configParam.allowDFSChannelRoam = pParam->allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05301888 pMac->roam.configParam.sendDeauthBeforeCon = pParam->sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 }
1890
1891 return status;
1892}
1893
Jeff Johnson295189b2012-06-20 16:38:30 -07001894eHalStatus csrGetConfigParam(tpAniSirGlobal pMac, tCsrConfigParam *pParam)
1895{
1896 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001897 if(pParam)
1898 {
1899 pParam->WMMSupportMode = pMac->roam.configParam.WMMSupportMode;
1900 pParam->Is11eSupportEnabled = pMac->roam.configParam.Is11eSupportEnabled;
1901 pParam->FragmentationThreshold = pMac->roam.configParam.FragmentationThreshold;
1902 pParam->Is11dSupportEnabled = pMac->roam.configParam.Is11dSupportEnabled;
1903 pParam->Is11dSupportEnabledOriginal = pMac->roam.configParam.Is11dSupportEnabledOriginal;
1904 pParam->Is11hSupportEnabled = pMac->roam.configParam.Is11hSupportEnabled;
Jeff Johnsone7245742012-09-05 17:12:55 -07001905 pParam->channelBondingMode24GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode24GHz);
1906 pParam->channelBondingMode5GHz = csrConvertPhyCBStateToIniValue(pMac->roam.configParam.channelBondingMode5GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07001907 pParam->RTSThreshold = pMac->roam.configParam.RTSThreshold;
1908 pParam->phyMode = pMac->roam.configParam.phyMode;
1909 pParam->shortSlotTime = pMac->roam.configParam.shortSlotTime;
1910 pParam->HeartbeatThresh24 = pMac->roam.configParam.HeartbeatThresh24;
1911 pParam->HeartbeatThresh50 = pMac->roam.configParam.HeartbeatThresh50;
1912 pParam->ProprietaryRatesEnabled = pMac->roam.configParam.ProprietaryRatesEnabled;
1913 pParam->TxRate = pMac->roam.configParam.TxRate;
1914 pParam->AdHocChannel24 = pMac->roam.configParam.AdHocChannel24;
1915 pParam->AdHocChannel5G = pMac->roam.configParam.AdHocChannel5G;
1916 pParam->bandCapability = pMac->roam.configParam.bandCapability;
1917 pParam->cbChoice = pMac->roam.configParam.cbChoice;
1918 pParam->bgScanInterval = pMac->roam.configParam.bgScanInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07001919 pParam->nActiveMaxChnTime = pMac->roam.configParam.nActiveMaxChnTime;
1920 pParam->nActiveMinChnTime = pMac->roam.configParam.nActiveMinChnTime;
1921 pParam->nPassiveMaxChnTime = pMac->roam.configParam.nPassiveMaxChnTime;
1922 pParam->nPassiveMinChnTime = pMac->roam.configParam.nPassiveMinChnTime;
Kiran Kumar Lokere458d7322013-05-29 14:29:43 -07001923 pParam->nActiveMaxChnTimeBtc = pMac->roam.configParam.nActiveMaxChnTimeBtc;
1924 pParam->nActiveMinChnTimeBtc = pMac->roam.configParam.nActiveMinChnTimeBtc;
1925 pParam->disableAggWithBtc = pMac->roam.configParam.disableAggWithBtc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001926#ifdef WLAN_AP_STA_CONCURRENCY
1927 pParam->nActiveMaxChnTimeConc = pMac->roam.configParam.nActiveMaxChnTimeConc;
1928 pParam->nActiveMinChnTimeConc = pMac->roam.configParam.nActiveMinChnTimeConc;
1929 pParam->nPassiveMaxChnTimeConc = pMac->roam.configParam.nPassiveMaxChnTimeConc;
1930 pParam->nPassiveMinChnTimeConc = pMac->roam.configParam.nPassiveMinChnTimeConc;
1931 pParam->nRestTimeConc = pMac->roam.configParam.nRestTimeConc;
Sudhir Sattayappa Kohallieb97d502013-05-22 23:16:42 -07001932 pParam->nNumStaChanCombinedConc = pMac->roam.configParam.nNumStaChanCombinedConc;
1933 pParam->nNumP2PChanCombinedConc = pMac->roam.configParam.nNumP2PChanCombinedConc;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -07001934#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001935 //Change the unit from microsecond to second
1936 pParam->impsSleepTime = pMac->roam.configParam.impsSleepTime / PAL_TIMER_TO_SEC_UNIT;
1937 pParam->eBand = pMac->roam.configParam.eBand;
1938 pParam->nScanResultAgeCount = pMac->roam.configParam.agingCount;
1939 pParam->scanAgeTimeNCNPS = pMac->roam.configParam.scanAgeTimeNCNPS;
1940 pParam->scanAgeTimeNCPS = pMac->roam.configParam.scanAgeTimeNCPS;
1941 pParam->scanAgeTimeCNPS = pMac->roam.configParam.scanAgeTimeCNPS;
1942 pParam->scanAgeTimeCPS = pMac->roam.configParam.scanAgeTimeCPS;
1943 pParam->bCatRssiOffset = pMac->roam.configParam.bCatRssiOffset;
1944 pParam->nRoamingTime = pMac->roam.configParam.nRoamingTime;
1945 pParam->fEnforce11dChannels = pMac->roam.configParam.fEnforce11dChannels;
1946 pParam->fSupplicantCountryCodeHasPriority = pMac->roam.configParam.fSupplicantCountryCodeHasPriority;
1947 pParam->fEnforceCountryCodeMatch = pMac->roam.configParam.fEnforceCountryCodeMatch;
1948 pParam->fEnforceDefaultDomain = pMac->roam.configParam.fEnforceDefaultDomain;
1949 pParam->vccRssiThreshold = pMac->roam.configParam.vccRssiThreshold;
1950 pParam->vccUlMacLossThreshold = pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 pParam->IsIdleScanEnabled = pMac->roam.configParam.IsIdleScanEnabled;
1952 pParam->nTxPowerCap = pMac->roam.configParam.nTxPowerCap;
1953 pParam->statsReqPeriodicity = pMac->roam.configParam.statsReqPeriodicity;
1954 pParam->statsReqPeriodicityInPS = pMac->roam.configParam.statsReqPeriodicityInPS;
Jeff Johnson295189b2012-06-20 16:38:30 -07001955 pParam->addTSWhenACMIsOff = pMac->roam.configParam.addTSWhenACMIsOff;
1956 pParam->fValidateList = pMac->roam.configParam.fValidateList;
1957 pParam->fEnableBypass11d = pMac->scan.fEnableBypass11d;
1958 pParam->fEnableDFSChnlScan = pMac->scan.fEnableDFSChnlScan;
1959 pParam->fScanTwice = pMac->roam.configParam.fScanTwice;
Jeff Johnsone7245742012-09-05 17:12:55 -07001960 pParam->fFirstScanOnly2GChnl = pMac->scan.fFirstScanOnly2GChnl;
Madan Mohan Koyyalamudied419512012-11-29 15:53:46 -08001961 pParam->fEnableMCCMode = pMac->roam.configParam.fenableMCCMode;
Madan Mohan Koyyalamudi057bd802012-11-29 16:02:39 -08001962 pParam->fAllowMCCGODiffBI = pMac->roam.configParam.fAllowMCCGODiffBI;
Sunil Ravi39b2e532013-01-20 23:45:53 -08001963 pParam->scanCfgAgingTime = pMac->scan.scanResultCfgAgingTime;
Peng Xu2446a892014-09-05 17:21:18 +05301964 pParam->scanBandPreference = pMac->scan.scanBandPreference;
Jeff Johnson295189b2012-06-20 16:38:30 -07001965#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05301966 vos_mem_copy(&pParam->neighborRoamConfig,
1967 &pMac->roam.configParam.neighborRoamConfig,
1968 sizeof(tCsrNeighborRoamConfigParams));
Jeff Johnson295189b2012-06-20 16:38:30 -07001969#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07001970#ifdef WLAN_FEATURE_11AC
1971 pParam->nVhtChannelWidth = pMac->roam.configParam.nVhtChannelWidth;
Shailender Karmuchi08f87c22013-01-17 12:51:24 -08001972 pParam->enableTxBF = pMac->roam.configParam.txBFEnable;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -08001973 pParam->txBFCsnValue = pMac->roam.configParam.txBFCsnValue;
Ravi Joshiacc81822013-10-10 15:30:41 -07001974 pParam->enableVhtFor24GHz = pMac->roam.configParam.enableVhtFor24GHz;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +05301975 /* Consider Mu-beamformee only if SU-beamformee is enabled */
1976 if ( pParam->enableTxBF )
1977 pParam->enableMuBformee = pMac->roam.configParam.txMuBformee;
1978 else
1979 pParam->enableMuBformee = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07001980#endif
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001981#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05301982 vos_mem_copy(&pMac->roam.configParam.csr11rConfig,
1983 &pParam->csr11rConfig, sizeof(tCsr11rConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001984#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001985#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001986 pParam->isFastTransitionEnabled = pMac->roam.configParam.isFastTransitionEnabled;
1987 pParam->RoamRssiDiff = pMac->roam.configParam.RoamRssiDiff;
1988 pParam->nImmediateRoamRssiDiff = pMac->roam.configParam.nImmediateRoamRssiDiff;
1989 pParam->nRoamPrefer5GHz = pMac->roam.configParam.nRoamPrefer5GHz;
1990 pParam->nRoamIntraBand = pMac->roam.configParam.nRoamIntraBand;
Srinivas Girigowdaad34ca92013-10-22 10:54:29 -07001991 pParam->isWESModeEnabled = pMac->roam.configParam.isWESModeEnabled;
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -07001992 pParam->nProbes = pMac->roam.configParam.nProbes;
1993 pParam->nRoamScanHomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07001994#endif
1995#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1996 pParam->isRoamOffloadScanEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
1997 pParam->bFastRoamInConIniFeatureEnabled = pMac->roam.configParam.bFastRoamInConIniFeatureEnabled;
1998#endif
1999#ifdef FEATURE_WLAN_LFR
2000 pParam->isFastRoamIniFeatureEnabled = pMac->roam.configParam.isFastRoamIniFeatureEnabled;
2001#endif
2002
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002003#ifdef FEATURE_WLAN_ESE
2004 pParam->isEseIniFeatureEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002005#endif
2006#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Kiet Lam64c1b492013-07-12 13:56:44 +05302007 vos_mem_copy(&pParam->neighborRoamConfig,
2008 &pMac->roam.configParam.neighborRoamConfig,
2009 sizeof(tCsrNeighborRoamConfigParams));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002010 {
2011 int i;
2012 smsLog( pMac, LOG1, FL("Num of Channels in CFG Channel List: %d"), pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels);
2013 for( i=0; i< pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.numChannels; i++)
2014 {
2015 smsLog( pMac, LOG1, "%d ", pMac->roam.configParam.neighborRoamConfig.neighborScanChanList.channelList[i] );
2016 }
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07002017 }
2018#endif
2019
Venkata Prathyusha Kuntupallif2695c12013-04-17 15:41:23 -07002020 pParam->enableTxLdpc = pMac->roam.configParam.txLdpcEnable;
krunal soni4f087d22013-07-29 16:32:26 -07002021
krunal soni5afa96c2013-09-06 22:19:02 -07002022 pParam->isAmsduSupportInAMPDU = pMac->roam.configParam.isAmsduSupportInAMPDU;
Srinivas Girigowda41c7c5f2013-10-21 19:01:38 -07002023 pParam->nSelect5GHzMargin = pMac->roam.configParam.nSelect5GHzMargin;
krunal soni5afa96c2013-09-06 22:19:02 -07002024
krunal sonie9002db2013-11-25 14:24:17 -08002025 pParam->isCoalesingInIBSSAllowed =
2026 pMac->roam.configParam.isCoalesingInIBSSAllowed;
Sandeep Puligillac80f26e2014-03-11 18:36:10 +05302027 pParam->allowDFSChannelRoam =
2028 pMac->roam.configParam.allowDFSChannelRoam;
Abhishek Singhde51a412014-05-20 19:17:26 +05302029 pParam->sendDeauthBeforeCon = pMac->roam.configParam.sendDeauthBeforeCon;
Jeff Johnson295189b2012-06-20 16:38:30 -07002030 csrSetChannels(pMac, pParam);
2031
2032 status = eHAL_STATUS_SUCCESS;
2033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002034 return (status);
2035}
2036
Jeff Johnson295189b2012-06-20 16:38:30 -07002037eHalStatus csrSetPhyMode(tHalHandle hHal, tANI_U32 phyMode, eCsrBand eBand, tANI_BOOLEAN *pfRestartNeeded)
2038{
2039 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
2040 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2041 tANI_BOOLEAN fRestartNeeded = eANI_BOOLEAN_FALSE;
2042 eCsrPhyMode newPhyMode = eCSR_DOT11_MODE_AUTO;
Jeff Johnson295189b2012-06-20 16:38:30 -07002043 do
2044 {
2045 if(eCSR_BAND_24 == eBand)
2046 {
2047 if(CSR_IS_RADIO_A_ONLY(pMac)) break;
2048 if((eCSR_DOT11_MODE_11a & phyMode) || (eCSR_DOT11_MODE_11a_ONLY & phyMode)) break;
2049 }
2050 if(eCSR_BAND_5G == eBand)
2051 {
2052 if(CSR_IS_RADIO_BG_ONLY(pMac)) break;
2053 if((eCSR_DOT11_MODE_11b & phyMode) || (eCSR_DOT11_MODE_11b_ONLY & phyMode) ||
2054 (eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11g_ONLY & phyMode)
2055 )
2056 {
2057 break;
2058 }
2059 }
2060 if((0 == phyMode) || (eCSR_DOT11_MODE_TAURUS & phyMode))
2061 {
2062 newPhyMode = eCSR_DOT11_MODE_TAURUS;
2063 }
2064 else if(eCSR_DOT11_MODE_AUTO & phyMode)
2065 {
2066 newPhyMode = eCSR_DOT11_MODE_AUTO;
2067 }
2068 else
2069 {
2070 //Check for dual band and higher capability first
2071 if(eCSR_DOT11_MODE_11n_ONLY & phyMode)
2072 {
2073 if(eCSR_DOT11_MODE_11n_ONLY != phyMode) break;
2074 newPhyMode = eCSR_DOT11_MODE_11n_ONLY;
2075 }
2076 else if(eCSR_DOT11_MODE_11a_ONLY & phyMode)
2077 {
2078 if(eCSR_DOT11_MODE_11a_ONLY != phyMode) break;
2079 if(eCSR_BAND_24 == eBand) break;
2080 newPhyMode = eCSR_DOT11_MODE_11a_ONLY;
2081 eBand = eCSR_BAND_5G;
2082 }
2083 else if(eCSR_DOT11_MODE_11g_ONLY & phyMode)
2084 {
2085 if(eCSR_DOT11_MODE_11g_ONLY != phyMode) break;
2086 if(eCSR_BAND_5G == eBand) break;
2087 newPhyMode = eCSR_DOT11_MODE_11g_ONLY;
2088 eBand = eCSR_BAND_24;
2089 }
2090 else if(eCSR_DOT11_MODE_11b_ONLY & phyMode)
2091 {
2092 if(eCSR_DOT11_MODE_11b_ONLY != phyMode) break;
2093 if(eCSR_BAND_5G == eBand) break;
2094 newPhyMode = eCSR_DOT11_MODE_11b_ONLY;
2095 eBand = eCSR_BAND_24;
2096 }
2097 else if(eCSR_DOT11_MODE_11n & phyMode)
2098 {
2099 newPhyMode = eCSR_DOT11_MODE_11n;
2100 }
2101 else if(eCSR_DOT11_MODE_abg & phyMode)
2102 {
2103 newPhyMode = eCSR_DOT11_MODE_abg;
2104 }
2105 else if(eCSR_DOT11_MODE_11a & phyMode)
2106 {
2107 if((eCSR_DOT11_MODE_11g & phyMode) || (eCSR_DOT11_MODE_11b & phyMode))
2108 {
2109 if(eCSR_BAND_ALL == eBand)
2110 {
2111 newPhyMode = eCSR_DOT11_MODE_abg;
2112 }
2113 else
2114 {
2115 //bad setting
2116 break;
2117 }
2118 }
2119 else
2120 {
2121 newPhyMode = eCSR_DOT11_MODE_11a;
2122 eBand = eCSR_BAND_5G;
2123 }
2124 }
2125 else if(eCSR_DOT11_MODE_11g & phyMode)
2126 {
2127 newPhyMode = eCSR_DOT11_MODE_11g;
2128 eBand = eCSR_BAND_24;
2129 }
2130 else if(eCSR_DOT11_MODE_11b & phyMode)
2131 {
2132 newPhyMode = eCSR_DOT11_MODE_11b;
2133 eBand = eCSR_BAND_24;
2134 }
2135 else
2136 {
2137 //We will never be here
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002138 smsLog( pMac, LOGE, FL(" cannot recognize the phy mode 0x%08X"), phyMode );
Jeff Johnson295189b2012-06-20 16:38:30 -07002139 newPhyMode = eCSR_DOT11_MODE_AUTO;
2140 }
2141 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002142 //Done validating
2143 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002144 //Now we need to check whether a restart is needed.
2145 if(eBand != pMac->roam.configParam.eBand)
2146 {
2147 fRestartNeeded = eANI_BOOLEAN_TRUE;
2148 break;
2149 }
2150 if(newPhyMode != pMac->roam.configParam.phyMode)
2151 {
2152 fRestartNeeded = eANI_BOOLEAN_TRUE;
2153 break;
2154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002155 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 if(HAL_STATUS_SUCCESS(status))
2157 {
2158 pMac->roam.configParam.eBand = eBand;
2159 pMac->roam.configParam.phyMode = newPhyMode;
2160 if(pfRestartNeeded)
2161 {
2162 *pfRestartNeeded = fRestartNeeded;
2163 }
2164 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 return (status);
2166}
2167
Jeff Johnson295189b2012-06-20 16:38:30 -07002168void csrPruneChannelListForMode( tpAniSirGlobal pMac, tCsrChannel *pChannelList )
2169{
2170 tANI_U8 Index;
2171 tANI_U8 cChannels;
Jeff Johnson295189b2012-06-20 16:38:30 -07002172 // for dual band NICs, don't need to trim the channel list....
2173 if ( !CSR_IS_OPEARTING_DUAL_BAND( pMac ) )
2174 {
2175 // 2.4 GHz band operation requires the channel list to be trimmed to
2176 // the 2.4 GHz channels only...
2177 if ( CSR_IS_24_BAND_ONLY( pMac ) )
2178 {
2179 for( Index = 0, cChannels = 0; Index < pChannelList->numChannels;
2180 Index++ )
2181 {
2182 if ( CSR_IS_CHANNEL_24GHZ(pChannelList->channelList[ Index ]) )
2183 {
2184 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2185 cChannels++;
2186 }
2187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002188 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2189 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2190 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2191 // only if we need to.
2192 //
2193 // The amount of memory to clear is the number of channesl that we trimmed
2194 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2195
2196 if ( pChannelList->numChannels > cChannels )
2197 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302198 vos_mem_set(&pChannelList->channelList[ cChannels ],
2199 sizeof( pChannelList->channelList[ 0 ] ) *
2200 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 }
2202
2203 pChannelList->numChannels = cChannels;
2204 }
2205 else if ( CSR_IS_5G_BAND_ONLY( pMac ) )
2206 {
2207 for ( Index = 0, cChannels = 0; Index < pChannelList->numChannels; Index++ )
2208 {
2209 if ( CSR_IS_CHANNEL_5GHZ(pChannelList->channelList[ Index ]) )
2210 {
2211 pChannelList->channelList[ cChannels ] = pChannelList->channelList[ Index ];
2212 cChannels++;
2213 }
2214 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002215 // Cleanup the rest of channels. Note we only need to clean up the channels if we had
2216 // to trim the list. Calling palZeroMemory() with a 0 size is going to throw asserts on
2217 // the debug builds so let's be a bit smarter about that. Zero out the reset of the channels
2218 // only if we need to.
2219 //
2220 // The amount of memory to clear is the number of channesl that we trimmed
2221 // (pChannelList->numChannels - cChannels) times the size of a channel in the structure.
2222 if ( pChannelList->numChannels > cChannels )
2223 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302224 vos_mem_set(&pChannelList->channelList[ cChannels ],
2225 sizeof( pChannelList->channelList[ 0 ] ) *
2226 ( pChannelList->numChannels - cChannels ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 }
2228
2229 pChannelList->numChannels = cChannels;
2230 }
2231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002232}
Jeff Johnson295189b2012-06-20 16:38:30 -07002233#define INFRA_AP_DEFAULT_CHANNEL 6
2234eHalStatus csrIsValidChannel(tpAniSirGlobal pMac, tANI_U8 chnNum)
2235{
2236 tANI_U8 index= 0;
2237 eHalStatus status = eHAL_STATUS_FAILURE;
2238 for (index=0; index < pMac->scan.base20MHzChannels.numChannels ;index++)
2239 {
2240 if(pMac->scan.base20MHzChannels.channelList[ index ] == chnNum){
2241 status = eHAL_STATUS_SUCCESS;
2242 break;
2243 }
2244 }
2245 return status;
2246}
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002247
Venkata Prathyusha Kuntupalli316247e2013-03-15 17:45:25 -07002248
Jeff Johnson295189b2012-06-20 16:38:30 -07002249eHalStatus csrInitGetChannels(tpAniSirGlobal pMac)
2250{
2251 eHalStatus status = eHAL_STATUS_SUCCESS;
2252 tANI_U8 num20MHzChannelsFound = 0;
2253 VOS_STATUS vosStatus;
2254 tANI_U8 Index = 0;
2255 tANI_U8 num40MHzChannelsFound = 0;
Jeff Johnsone7245742012-09-05 17:12:55 -07002256
Jeff Johnson295189b2012-06-20 16:38:30 -07002257
2258 //TODO: this interface changed to include the 40MHz channel list
2259 // this needs to be tied into the adapter structure somehow and referenced appropriately for CB operation
2260 // Read the scan channel list (including the power limit) from EEPROM
2261 vosStatus = vos_nv_getChannelListWithPower( pMac->scan.defaultPowerTable, &num20MHzChannelsFound,
2262 pMac->scan.defaultPowerTable40MHz, &num40MHzChannelsFound);
2263 if ( (VOS_STATUS_SUCCESS != vosStatus) || (num20MHzChannelsFound == 0) )
2264 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002265 smsLog( pMac, LOGE, FL("failed to get channels "));
Jeff Johnson295189b2012-06-20 16:38:30 -07002266 status = eHAL_STATUS_FAILURE;
2267 }
2268 else
2269 {
2270 if ( num20MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN )
2271 {
2272 num20MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2273 }
2274 pMac->scan.numChannelsDefault = num20MHzChannelsFound;
2275 // Move the channel list to the global data
2276 // structure -- this will be used as the scan list
2277 for ( Index = 0; Index < num20MHzChannelsFound; Index++)
2278 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002279 pMac->scan.base20MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable[ Index ].chanId;
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 }
2281 pMac->scan.base20MHzChannels.numChannels = num20MHzChannelsFound;
2282 if(num40MHzChannelsFound > WNI_CFG_VALID_CHANNEL_LIST_LEN)
2283 {
2284 num40MHzChannelsFound = WNI_CFG_VALID_CHANNEL_LIST_LEN;
2285 }
2286 for ( Index = 0; Index < num40MHzChannelsFound; Index++)
2287 {
2288 pMac->scan.base40MHzChannels.channelList[ Index ] = pMac->scan.defaultPowerTable40MHz[ Index ].chanId;
2289 }
2290 pMac->scan.base40MHzChannels.numChannels = num40MHzChannelsFound;
2291 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 return (status);
2293}
Jeff Johnson295189b2012-06-20 16:38:30 -07002294eHalStatus csrInitChannelList( tHalHandle hHal )
2295{
2296 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
2297 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 csrPruneChannelListForMode(pMac, &pMac->scan.baseChannels);
2299 csrPruneChannelListForMode(pMac, &pMac->scan.base20MHzChannels);
Kiran4a17ebe2013-01-31 10:43:43 -08002300 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_FALSE);
2301 csrSaveChannelPowerForBand(pMac, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002302 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002303 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Atul Mittalb849d5a2014-07-29 12:08:39 +05302304 limInitOperatingClasses(hHal);
Jeff Johnson295189b2012-06-20 16:38:30 -07002305 return (status);
2306}
Jeff Johnson295189b2012-06-20 16:38:30 -07002307eHalStatus csrChangeConfigParams(tpAniSirGlobal pMac,
2308 tCsrUpdateConfigParam *pUpdateConfigParam)
2309{
2310 eHalStatus status = eHAL_STATUS_FAILURE;
2311 tCsr11dinfo *ps11dinfo = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 ps11dinfo = &pUpdateConfigParam->Csr11dinfo;
2313 status = CsrInit11dInfo(pMac, ps11dinfo);
2314 return status;
2315}
2316
Jeff Johnson295189b2012-06-20 16:38:30 -07002317static eHalStatus CsrInit11dInfo(tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2318{
2319 eHalStatus status = eHAL_STATUS_FAILURE;
2320 tANI_U8 index;
2321 tANI_U32 count=0;
2322 tSirMacChanInfo *pChanInfo;
2323 tSirMacChanInfo *pChanInfoStart;
2324 tANI_BOOLEAN applyConfig = TRUE;
2325
Mihir Shetebc866f62014-02-13 16:08:53 +05302326 pMac->scan.currentCountryRSSI = -128;
2327
Jeff Johnson295189b2012-06-20 16:38:30 -07002328 if(!ps11dinfo)
2329 {
2330 return (status);
2331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002332 if ( ps11dinfo->Channels.numChannels && ( WNI_CFG_VALID_CHANNEL_LIST_LEN >= ps11dinfo->Channels.numChannels ) )
2333 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302334 pMac->scan.base20MHzChannels.numChannels = ps11dinfo->Channels.numChannels;
2335 vos_mem_copy(pMac->scan.base20MHzChannels.channelList,
2336 ps11dinfo->Channels.channelList,
2337 ps11dinfo->Channels.numChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07002338 }
2339 else
2340 {
2341 //No change
2342 return (eHAL_STATUS_SUCCESS);
2343 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002344 //legacy maintenance
Kiet Lam64c1b492013-07-12 13:56:44 +05302345
2346 vos_mem_copy(pMac->scan.countryCodeDefault, ps11dinfo->countryCode,
2347 WNI_CFG_COUNTRY_CODE_LEN);
2348
2349
Jeff Johnson295189b2012-06-20 16:38:30 -07002350 //Tush: at csropen get this initialized with default, during csr reset if this
2351 // already set with some value no need initilaize with default again
2352 if(0 == pMac->scan.countryCodeCurrent[0])
2353 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302354 vos_mem_copy(pMac->scan.countryCodeCurrent, ps11dinfo->countryCode,
2355 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07002356 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002357 // need to add the max power channel list
Kiet Lam64c1b492013-07-12 13:56:44 +05302358 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2359 if (pChanInfo != NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002360 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302361 vos_mem_set(pChanInfo,
2362 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN ,
2363 0);
2364
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 pChanInfoStart = pChanInfo;
Jeff Johnsone7245742012-09-05 17:12:55 -07002366 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2367 {
2368 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2369 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2370 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2371 pChanInfo++;
2372 count++;
2373 }
2374 if(count)
2375 {
2376 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2377 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302378 vos_mem_free(pChanInfoStart);
Jeff Johnsone7245742012-09-05 17:12:55 -07002379 }
2380 //Only apply them to CFG when not in STOP state. Otherwise they will be applied later
2381 if( HAL_STATUS_SUCCESS(status) )
2382 {
2383 for( index = 0; index < CSR_ROAM_SESSION_MAX; index++ )
2384 {
2385 if((CSR_IS_SESSION_VALID(pMac, index)) && CSR_IS_ROAM_STOP(pMac, index))
2386 {
2387 applyConfig = FALSE;
2388 }
2389 }
2390
2391 if(TRUE == applyConfig)
2392 {
2393 // Apply the base channel list, power info, and set the Country code...
Gopichand Nakkalab9185f22012-12-21 08:03:42 -08002394 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels, pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE );
Jeff Johnsone7245742012-09-05 17:12:55 -07002395 }
2396
2397 }
2398 return (status);
2399}
2400/* Initialize the Channel + Power List in the local cache and in the CFG */
2401eHalStatus csrInitChannelPowerList( tpAniSirGlobal pMac, tCsr11dinfo *ps11dinfo)
2402{
2403 tANI_U8 index;
2404 tANI_U32 count=0;
2405 tSirMacChanInfo *pChanInfo;
2406 tSirMacChanInfo *pChanInfoStart;
2407
2408 if(!ps11dinfo || !pMac)
2409 {
2410 return eHAL_STATUS_FAILURE;
2411 }
2412
Kiet Lam64c1b492013-07-12 13:56:44 +05302413 pChanInfo = vos_mem_malloc(sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN);
2414 if (pChanInfo != NULL)
Jeff Johnsone7245742012-09-05 17:12:55 -07002415 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302416 vos_mem_set(pChanInfo,
2417 sizeof(tSirMacChanInfo) * WNI_CFG_VALID_CHANNEL_LIST_LEN,
2418 0);
Jeff Johnsone7245742012-09-05 17:12:55 -07002419 pChanInfoStart = pChanInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07002420
2421 for(index = 0; index < ps11dinfo->Channels.numChannels; index++)
2422 {
2423 pChanInfo->firstChanNum = ps11dinfo->ChnPower[index].firstChannel;
2424 pChanInfo->numChannels = ps11dinfo->ChnPower[index].numChannels;
2425 pChanInfo->maxTxPower = CSR_ROAM_MIN( ps11dinfo->ChnPower[index].maxtxPower, pMac->roam.configParam.nTxPowerCap );
2426 pChanInfo++;
2427 count++;
2428 }
2429 if(count)
2430 {
2431 csrSaveToChannelPower2G_5G( pMac, count * sizeof(tSirMacChanInfo), pChanInfoStart );
2432 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302433 vos_mem_free(pChanInfoStart);
Jeff Johnson295189b2012-06-20 16:38:30 -07002434 }
2435
Jeff Johnsone7245742012-09-05 17:12:55 -07002436 return eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07002437}
2438
2439//pCommand may be NULL
2440//Pass in sessionId in case pCommand is NULL. sessionId is not used in case pCommand is not NULL.
2441void csrRoamRemoveDuplicateCommand(tpAniSirGlobal pMac, tANI_U32 sessionId, tSmeCmd *pCommand, eCsrRoamReason eRoamReason)
2442{
2443 tListElem *pEntry, *pNextEntry;
2444 tSmeCmd *pDupCommand;
2445 tDblLinkList localList;
2446
2447 vos_mem_zero(&localList, sizeof(tDblLinkList));
2448 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
2449 {
2450 smsLog(pMac, LOGE, FL(" failed to open list"));
2451 return;
2452 }
2453 csrLLLock( &pMac->sme.smeCmdPendingList );
2454 pEntry = csrLLPeekHead( &pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK );
2455 while( pEntry )
2456 {
2457 pNextEntry = csrLLNext( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK );
2458 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07002459 // Remove the previous command if..
2460 // - the new roam command is for the same RoamReason...
2461 // - the new roam command is a NewProfileList.
2462 // - the new roam command is a Forced Dissoc
2463 // - the new roam command is from an 802.11 OID (OID_SSID or OID_BSSID).
2464 if (
2465 (pCommand && ( pCommand->sessionId == pDupCommand->sessionId ) &&
2466 ((pCommand->command == pDupCommand->command) &&
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -08002467 /* This peermac check is requried for Softap/GO scenarios
2468 * For STA scenario below OR check will suffice as pCommand will
2469 * always be NULL for STA scenarios
2470 */
2471 (vos_mem_compare(pDupCommand->u.roamCmd.peerMac, pCommand->u.roamCmd.peerMac, sizeof(v_MACADDR_t))) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002472 (pCommand->u.roamCmd.roamReason == pDupCommand->u.roamCmd.roamReason ||
2473 eCsrForcedDisassoc == pCommand->u.roamCmd.roamReason ||
2474 eCsrHddIssued == pCommand->u.roamCmd.roamReason)))
2475 ||
2476 //below the pCommand is NULL
Jeff Johnson43971f52012-07-17 12:26:56 -07002477 ( (sessionId == pDupCommand->sessionId) &&
2478 (eSmeCommandRoam == pDupCommand->command) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07002479 ((eCsrForcedDisassoc == eRoamReason) ||
2480 (eCsrHddIssued == eRoamReason))
2481 )
2482 )
2483 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002484 smsLog(pMac, LOGW, FL(" roamReason = %d"), pDupCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07002485 // Remove the 'stale' roam command from the pending list...
2486 if(csrLLRemoveEntry( &pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK ))
2487 {
2488 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
2489 }
2490 }
2491 pEntry = pNextEntry;
2492 }
2493 csrLLUnlock( &pMac->sme.smeCmdPendingList );
2494
2495 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
2496 {
2497 pDupCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
2498 //Tell caller that the command is cancelled
2499 csrRoamCallCallback(pMac, pDupCommand->sessionId, NULL, pDupCommand->u.roamCmd.roamId,
2500 eCSR_ROAM_CANCELLED, eCSR_ROAM_RESULT_NONE);
2501 csrReleaseCommandRoam(pMac, pDupCommand);
2502 }
2503 csrLLClose(&localList);
2504}
Jeff Johnson295189b2012-06-20 16:38:30 -07002505eHalStatus csrRoamCallCallback(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo,
2506 tANI_U32 roamId, eRoamCmdStatus u1, eCsrRoamResult u2)
2507{
2508 eHalStatus status = eHAL_STATUS_SUCCESS;
2509#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
2510 WLAN_VOS_DIAG_EVENT_DEF(connectionStatus, vos_event_wlan_status_payload_type);
2511#endif
2512 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07002513 if( CSR_IS_SESSION_VALID( pMac, sessionId) )
2514 {
2515 pSession = CSR_GET_SESSION( pMac, sessionId );
2516 }
2517 else
2518 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002519 smsLog(pMac, LOGE, "Session ID:%d is not valid", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002520 VOS_ASSERT(0);
2521 return eHAL_STATUS_FAILURE;
2522 }
krunal soni587bf012014-02-04 12:35:11 -08002523
2524 if (eANI_BOOLEAN_FALSE == pSession->sessionActive)
2525 {
2526 smsLog(pMac, LOG1, "%s Session is not Active", __func__);
2527 return eHAL_STATUS_FAILURE;
2528 }
krunal soni7f7d2c92014-02-06 15:08:43 -08002529
krunal soni587bf012014-02-04 12:35:11 -08002530 smsLog(pMac, LOG4, "Recieved RoamCmdStatus %d with Roam Result %d", u1, u2);
2531
krunal soni7f7d2c92014-02-06 15:08:43 -08002532 if(eCSR_ROAM_ASSOCIATION_COMPLETION == u1 && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002533 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002534 smsLog(pMac, LOGW, " Assoc complete result = %d statusCode = %d reasonCode = %d", u2, pRoamInfo->statusCode, pRoamInfo->reasonCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07002535 }
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07002536 if ((u1 == eCSR_ROAM_FT_REASSOC_FAILED) && (pSession->bRefAssocStartCnt)) {
2537 /*
2538 * Decrement bRefAssocStartCnt for FT reassoc failure.
2539 * Reason: For FT reassoc failures, we first call
2540 * csrRoamCallCallback before notifying a failed roam
2541 * completion through csrRoamComplete. The latter in
2542 * turn calls csrRoamProcessResults which tries to
2543 * once again call csrRoamCallCallback if bRefAssocStartCnt
2544 * is non-zero. Since this is redundant for FT reassoc
2545 * failure, decrement bRefAssocStartCnt.
2546 */
2547 pSession->bRefAssocStartCnt--;
2548 }
2549
Jeff Johnson295189b2012-06-20 16:38:30 -07002550 if(NULL != pSession->callback)
2551 {
2552 if( pRoamInfo )
2553 {
2554 pRoamInfo->sessionId = (tANI_U8)sessionId;
2555 }
2556
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05302557 /* avoid holding the global lock when making the roaming callback, original change came
2558 from a raised CR (CR304874). Since this callback is in HDD a potential deadlock
2559 is possible on other OS ports where the callback may need to take locks to protect
2560 HDD state
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 UPDATE : revert this change but keep the comments here. Need to revisit as there are callbacks
2562 that may actually depend on the lock being held */
2563 // TODO: revisit: sme_ReleaseGlobalLock( &pMac->sme );
2564 status = pSession->callback(pSession->pContext, pRoamInfo, roamId, u1, u2);
2565 // TODO: revisit: sme_AcquireGlobalLock( &pMac->sme );
2566 }
2567 //EVENT_WLAN_STATUS: eCSR_ROAM_ASSOCIATION_COMPLETION,
2568 // eCSR_ROAM_LOSTLINK, eCSR_ROAM_DISASSOCIATED,
2569#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiet Lam64c1b492013-07-12 13:56:44 +05302570 vos_mem_set(&connectionStatus,
2571 sizeof(vos_event_wlan_status_payload_type), 0);
2572
krunal soni7f7d2c92014-02-06 15:08:43 -08002573 if((eCSR_ROAM_ASSOCIATION_COMPLETION == u1) && (eCSR_ROAM_RESULT_ASSOCIATED == u2) && pRoamInfo)
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 {
2575 connectionStatus.eventId = eCSR_WLAN_STATUS_CONNECT;
2576 connectionStatus.bssType = pRoamInfo->u.pConnectedProfile->BSSType;
2577 if(NULL != pRoamInfo->pBssDesc)
2578 {
2579 connectionStatus.rssi = pRoamInfo->pBssDesc->rssi * (-1);
2580 connectionStatus.channel = pRoamInfo->pBssDesc->channelId;
2581 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002582 connectionStatus.qosCapability = pRoamInfo->u.pConnectedProfile->qosConnection;
2583 connectionStatus.authType = (v_U8_t)diagAuthTypeFromCSRType(pRoamInfo->u.pConnectedProfile->AuthType);
2584 connectionStatus.encryptionType = (v_U8_t)diagEncTypeFromCSRType(pRoamInfo->u.pConnectedProfile->EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05302585 vos_mem_copy(connectionStatus.ssid,
2586 pRoamInfo->u.pConnectedProfile->SSID.ssId, 6);
2587
Jeff Johnson295189b2012-06-20 16:38:30 -07002588 connectionStatus.reason = eCSR_REASON_UNSPECIFIED;
2589 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2590 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002591 if((eCSR_ROAM_MIC_ERROR_IND == u1) || (eCSR_ROAM_RESULT_MIC_FAILURE == u2))
2592 {
2593 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2594 connectionStatus.reason = eCSR_REASON_MIC_ERROR;
2595 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2596 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 if(eCSR_ROAM_RESULT_FORCED == u2)
2598 {
2599 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2600 connectionStatus.reason = eCSR_REASON_USER_REQUESTED;
2601 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2602 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002603 if(eCSR_ROAM_RESULT_DISASSOC_IND == u2)
2604 {
2605 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2606 connectionStatus.reason = eCSR_REASON_DISASSOC;
2607 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002609 if(eCSR_ROAM_RESULT_DEAUTH_IND == u2)
2610 {
2611 connectionStatus.eventId = eCSR_WLAN_STATUS_DISCONNECT;
2612 connectionStatus.reason = eCSR_REASON_DEAUTH;
2613 WLAN_VOS_DIAG_EVENT_REPORT(&connectionStatus, EVENT_WLAN_STATUS);
2614 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002615#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
2616
2617 return (status);
2618}
Jeff Johnson295189b2012-06-20 16:38:30 -07002619// Returns whether handoff is currently in progress or not
2620tANI_BOOLEAN csrRoamIsHandoffInProgress(tpAniSirGlobal pMac)
2621{
2622#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
2623 return csrNeighborRoamIsHandoffInProgress(pMac);
2624#else
2625 return eANI_BOOLEAN_FALSE;
2626#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002627}
Jeff Johnson295189b2012-06-20 16:38:30 -07002628eHalStatus csrRoamIssueDisassociate( tpAniSirGlobal pMac, tANI_U32 sessionId,
2629 eCsrRoamSubState NewSubstate, tANI_BOOLEAN fMICFailure )
2630{
2631 eHalStatus status = eHAL_STATUS_SUCCESS;
2632 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2633 tANI_U16 reasonCode;
2634 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002635
2636 if(!pSession)
2637 {
2638 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2639 return eHAL_STATUS_FAILURE;
2640 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002641
2642 //Restore AC weight in case we change it
2643 if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
2644 {
Madan Mohan Koyyalamudi5695b502012-09-24 14:21:12 -07002645 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 -07002646 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
2647 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
2648 }
2649
2650 if ( fMICFailure )
2651 {
2652 reasonCode = eSIR_MAC_MIC_FAILURE_REASON;
2653 }
2654 else if (NewSubstate == eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF)
2655 {
2656 reasonCode = eSIR_MAC_DISASSOC_DUE_TO_FTHANDOFF_REASON;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002657 }
2658 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 {
2660 reasonCode = eSIR_MAC_UNSPEC_FAILURE_REASON;
2661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002662#ifdef WLAN_FEATURE_VOWIFI_11R
2663 if ( (csrRoamIsHandoffInProgress(pMac)) &&
2664 (NewSubstate != eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF))
2665 {
2666 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05302667 vos_mem_copy(&bssId,
2668 pNeighborRoamInfo->csrNeighborRoamProfile.BSSIDs.bssid,
2669 sizeof(tSirMacAddr));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002670 }
2671 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002672#endif
2673 if(pSession->pConnectBssDesc)
2674 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302675 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002676 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002677
Jeff Johnson295189b2012-06-20 16:38:30 -07002678
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05302679 smsLog(pMac, LOG2, FL("CSR Attempting to Disassociate Bssid="MAC_ADDRESS_STR
2680 " subState = %s reason=%d"),
2681 MAC_ADDR_ARRAY(bssId), macTraceGetcsrRoamSubState(NewSubstate),
2682 reasonCode);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08002683
Jeff Johnson295189b2012-06-20 16:38:30 -07002684 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2685
2686 status = csrSendMBDisassocReqMsg( pMac, sessionId, bssId, reasonCode );
2687
2688 if(HAL_STATUS_SUCCESS(status))
2689 {
2690 csrRoamLinkDown(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002691#ifndef WLAN_MDM_CODE_REDUCTION_OPT
2692 //no need to tell QoS that we are disassociating, it will be taken care off in assoc req for HO
2693 if(eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF != NewSubstate)
2694 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002695 //notify QoS module that disassoc happening
Jeff Johnson295189b2012-06-20 16:38:30 -07002696 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
2697 }
2698#endif
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002699 }
2700 else
2701 {
2702 smsLog(pMac, LOGW, FL("csrSendMBDisassocReqMsg failed with status %d"), status);
2703 }
2704
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 return (status);
2706}
Jeff Johnson295189b2012-06-20 16:38:30 -07002707
Jeff Johnson295189b2012-06-20 16:38:30 -07002708/* ---------------------------------------------------------------------------
2709 \fn csrRoamIssueDisassociateStaCmd
2710 \brief csr function that HDD calls to disassociate a associated station
2711 \param sessionId - session Id for Soft AP
2712 \param pPeerMacAddr - MAC of associated station to delete
2713 \param reason - reason code, be one of the tSirMacReasonCodes
2714 \return eHalStatus
2715 ---------------------------------------------------------------------------*/
2716eHalStatus csrRoamIssueDisassociateStaCmd( tpAniSirGlobal pMac,
2717 tANI_U32 sessionId,
2718 tANI_U8 *pPeerMacAddr,
2719 tANI_U32 reason)
2720{
2721 eHalStatus status = eHAL_STATUS_SUCCESS;
2722 tSmeCmd *pCommand;
2723
2724 do
2725 {
2726 pCommand = csrGetCommandBuffer( pMac );
2727 if ( !pCommand )
2728 {
2729 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2730 status = eHAL_STATUS_RESOURCES;
2731 break;
2732 }
2733 pCommand->command = eSmeCommandRoam;
2734 pCommand->sessionId = (tANI_U8)sessionId;
2735 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocSta;
2736 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2737 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2738 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2739 if( !HAL_STATUS_SUCCESS( status ) )
2740 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002741 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 csrReleaseCommandRoam( pMac, pCommand );
2743 }
2744 }while(0);
2745
2746 return status;
2747}
2748
2749
Jeff Johnson295189b2012-06-20 16:38:30 -07002750/* ---------------------------------------------------------------------------
2751 \fn csrRoamIssueDeauthSta
2752 \brief csr function that HDD calls to delete a associated station
2753 \param sessionId - session Id for Soft AP
2754 \param pPeerMacAddr - MAC of associated station to delete
2755 \param reason - reason code, be one of the tSirMacReasonCodes
2756 \return eHalStatus
2757 ---------------------------------------------------------------------------*/
2758eHalStatus csrRoamIssueDeauthStaCmd( tpAniSirGlobal pMac,
2759 tANI_U32 sessionId,
2760 tANI_U8 *pPeerMacAddr,
2761 tANI_U32 reason)
2762{
2763 eHalStatus status = eHAL_STATUS_SUCCESS;
2764 tSmeCmd *pCommand;
2765
2766 do
2767 {
2768 pCommand = csrGetCommandBuffer( pMac );
2769 if ( !pCommand )
2770 {
2771 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
2772 status = eHAL_STATUS_RESOURCES;
2773 break;
2774 }
2775 pCommand->command = eSmeCommandRoam;
2776 pCommand->sessionId = (tANI_U8)sessionId;
2777 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
2778 vos_mem_copy(pCommand->u.roamCmd.peerMac, pPeerMacAddr, 6);
2779 pCommand->u.roamCmd.reason = (tSirMacReasonCodes)reason;
2780 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_FALSE);
2781 if( !HAL_STATUS_SUCCESS( status ) )
2782 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002783 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07002784 csrReleaseCommandRoam( pMac, pCommand );
2785 }
2786 }while(0);
2787
2788 return status;
2789}
Jeff Johnson295189b2012-06-20 16:38:30 -07002790eHalStatus
2791csrRoamIssueTkipCounterMeasures( tpAniSirGlobal pMac, tANI_U32 sessionId,
2792 tANI_BOOLEAN bEnable )
2793{
2794 eHalStatus status = eHAL_STATUS_FAILURE;
2795 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2796 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 if (!pSession)
2798 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002799 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002800 return (status);
2801 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002802 if (pSession->pConnectBssDesc)
2803 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302804 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 }
2806 else
2807 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002808 smsLog( pMac, LOGE, "csrRoamIssueTkipCounterMeasures:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002809 return (status);
2810 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002811 smsLog( pMac, LOG2, "CSR issuing tkip counter measures for Bssid = "MAC_ADDRESS_STR", Enable = %d",
2812 MAC_ADDR_ARRAY(bssId), bEnable);
Jeff Johnson295189b2012-06-20 16:38:30 -07002813 status = csrSendMBTkipCounterMeasuresReqMsg( pMac, sessionId, bEnable, bssId );
2814 return (status);
2815}
Jeff Johnson295189b2012-06-20 16:38:30 -07002816eHalStatus
2817csrRoamGetAssociatedStas( tpAniSirGlobal pMac, tANI_U32 sessionId,
2818 VOS_MODULE_ID modId, void *pUsrContext,
2819 void *pfnSapEventCallback, v_U8_t *pAssocStasBuf )
2820{
2821 eHalStatus status = eHAL_STATUS_SUCCESS;
2822 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2823 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 if (!pSession)
2825 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002826 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002827 return (status);
2828 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002829 if(pSession->pConnectBssDesc)
2830 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302831 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 }
2833 else
2834 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002835 smsLog( pMac, LOGE, "csrRoamGetAssociatedStas:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 return (status);
2837 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002838 smsLog( pMac, LOG2, "CSR getting associated stations for Bssid = "MAC_ADDRESS_STR,
2839 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 status = csrSendMBGetAssociatedStasReqMsg( pMac, sessionId, modId, bssId, pUsrContext, pfnSapEventCallback, pAssocStasBuf );
2841 return (status);
2842}
Jeff Johnson295189b2012-06-20 16:38:30 -07002843eHalStatus
2844csrRoamGetWpsSessionOverlap( tpAniSirGlobal pMac, tANI_U32 sessionId,
2845 void *pUsrContext, void *pfnSapEventCallback, v_MACADDR_t pRemoveMac )
2846{
2847 eHalStatus status = eHAL_STATUS_SUCCESS;
2848 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2849 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2850
2851 if (!pSession)
2852 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002853 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002854 return (status);
2855 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 if(pSession->pConnectBssDesc)
2857 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302858 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 }
2860 else
2861 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002862 smsLog( pMac, LOGE, "csrRoamGetWpsSessionOverlap:Connected BSS Description in CSR Session not found");
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 return (status);
2864 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002865 smsLog( pMac, LOG2, "CSR getting WPS Session Overlap for Bssid = "MAC_ADDRESS_STR,
2866 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002867
2868 status = csrSendMBGetWPSPBCSessions( pMac, sessionId, bssId, pUsrContext, pfnSapEventCallback, pRemoveMac);
2869
2870 return (status);
2871}
Jeff Johnson295189b2012-06-20 16:38:30 -07002872eHalStatus csrRoamIssueDeauth( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
2873{
2874 eHalStatus status = eHAL_STATUS_SUCCESS;
2875 tCsrBssid bssId = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff};
2876 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07002877
2878 if (!pSession)
2879 {
2880 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2881 return eHAL_STATUS_FAILURE;
2882 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002883
2884 if(pSession->pConnectBssDesc)
2885 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302886 vos_mem_copy(&bssId, pSession->pConnectBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 }
Arif Hussain24bafea2013-11-15 15:10:03 -08002888 smsLog( pMac, LOG2, "CSR Attempting to Deauth Bssid= "MAC_ADDRESS_STR,
2889 MAC_ADDR_ARRAY(bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07002890 csrRoamSubstateChange( pMac, NewSubstate, sessionId);
2891
Madan Mohan Koyyalamudi299b4862013-01-30 19:59:23 +05302892 status = csrSendMBDeauthReqMsg( pMac, sessionId, bssId, eSIR_MAC_DEAUTH_LEAVING_BSS_REASON );
Mukul Sharma45049182014-06-17 23:34:10 +05302893 if(HAL_STATUS_SUCCESS(status))
2894 {
2895 csrRoamLinkDown(pMac, sessionId);
2896 }
2897 else
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002898 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05302899 smsLog(pMac, LOGE, FL("csrSendMBDeauthReqMsg failed with status %d Session ID: %d"
2900 MAC_ADDRESS_STR ), status, sessionId, MAC_ADDR_ARRAY(bssId));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08002901 }
2902
Jeff Johnson295189b2012-06-20 16:38:30 -07002903 return (status);
2904}
2905
Jeff Johnson295189b2012-06-20 16:38:30 -07002906eHalStatus csrRoamSaveConnectedBssDesc( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDesc )
2907{
2908 eHalStatus status = eHAL_STATUS_SUCCESS;
2909 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
2910 tANI_U32 size;
Jeff Johnson32d95a32012-09-10 13:15:23 -07002911
2912 if(!pSession)
2913 {
2914 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
2915 return eHAL_STATUS_FAILURE;
2916 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002917
2918 // If no BSS description was found in this connection (happens with start IBSS), then
2919 // nix the BSS description that we keep around for the connected BSS) and get out...
2920 if(NULL == pBssDesc)
2921 {
2922 csrFreeConnectBssDesc(pMac, sessionId);
2923 }
2924 else
2925 {
2926 size = pBssDesc->length + sizeof( pBssDesc->length );
2927 if(NULL != pSession->pConnectBssDesc)
2928 {
2929 if(((pSession->pConnectBssDesc->length) + sizeof(pSession->pConnectBssDesc->length)) < size)
2930 {
2931 //not enough room for the new BSS, pMac->roam.pConnectBssDesc is freed inside
2932 csrFreeConnectBssDesc(pMac, sessionId);
2933 }
2934 }
2935 if(NULL == pSession->pConnectBssDesc)
2936 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302937 pSession->pConnectBssDesc = vos_mem_malloc(size);
Jeff Johnson295189b2012-06-20 16:38:30 -07002938 }
Kiet Lam64c1b492013-07-12 13:56:44 +05302939 if (NULL == pSession->pConnectBssDesc)
2940 status = eHAL_STATUS_FAILURE;
2941 else
2942 vos_mem_copy(pSession->pConnectBssDesc, pBssDesc, size);
2943 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002944 return (status);
2945}
2946
Jeff Johnson295189b2012-06-20 16:38:30 -07002947eHalStatus csrRoamPrepareBssConfig(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
2948 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
2949 tDot11fBeaconIEs *pIes)
2950{
2951 eHalStatus status = eHAL_STATUS_SUCCESS;
2952 eCsrCfgDot11Mode cfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07002953 VOS_ASSERT( pIes != NULL );
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +05302954 if (pIes == NULL)
2955 return eHAL_STATUS_FAILURE;
Jeff Johnsone7245742012-09-05 17:12:55 -07002956
Jeff Johnson295189b2012-06-20 16:38:30 -07002957 do
2958 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302959 vos_mem_copy(&pBssConfig->BssCap, &pBssDesc->capabilityInfo,
2960 sizeof(tSirMacCapabilityInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -07002961 //get qos
2962 pBssConfig->qosType = csrGetQoSFromBssDesc(pMac, pBssDesc, pIes);
2963 //get SSID
2964 if(pIes->SSID.present)
2965 {
Kiet Lam64c1b492013-07-12 13:56:44 +05302966 vos_mem_copy(&pBssConfig->SSID.ssId, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07002967 pBssConfig->SSID.length = pIes->SSID.num_ssid;
2968 }
2969 else
2970 pBssConfig->SSID.length = 0;
2971 if(csrIsNULLSSID(pBssConfig->SSID.ssId, pBssConfig->SSID.length))
2972 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002973 smsLog(pMac, LOGW, " BSS desc SSID is a wildcard");
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 //Return failed if profile doesn't have an SSID either.
2975 if(pProfile->SSIDs.numOfSSIDs == 0)
2976 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002977 smsLog(pMac, LOGW, " Both BSS desc and profile doesn't have SSID");
Jeff Johnson295189b2012-06-20 16:38:30 -07002978 status = eHAL_STATUS_FAILURE;
2979 break;
2980 }
2981 }
2982 if(CSR_IS_CHANNEL_5GHZ(pBssDesc->channelId))
2983 {
2984 pBssConfig->eBand = eCSR_BAND_5G;
2985 }
2986 else
2987 {
2988 pBssConfig->eBand = eCSR_BAND_24;
2989 }
2990 //phymode
2991 if(csrIsPhyModeMatch( pMac, pProfile->phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes ))
2992 {
2993 pBssConfig->uCfgDot11Mode = cfgDot11Mode;
2994 }
2995 else
2996 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08002997 smsLog(pMac, LOGW, " Can not find match phy mode");
Jeff Johnson295189b2012-06-20 16:38:30 -07002998 //force it
2999 if(eCSR_BAND_24 == pBssConfig->eBand)
3000 {
3001 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
3002 }
3003 else
3004 {
3005 pBssConfig->uCfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
3006 }
3007 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 //Qos
3009 if ((pBssConfig->uCfgDot11Mode != eCSR_CFG_DOT11_MODE_11N) &&
3010 (pMac->roam.configParam.WMMSupportMode == eCsrRoamWmmNoQos))
3011 {
3012 //Joining BSS is not 11n capable and WMM is disabled on client.
3013 //Disable QoS and WMM
3014 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3015 }
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303016
3017 if (((pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11N) ||
Pratik Bhalgat8d461642012-11-22 16:55:42 +05303018 (pBssConfig->uCfgDot11Mode == eCSR_CFG_DOT11_MODE_11AC)) &&
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05303019 ((pBssConfig->qosType != eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP) ||
3020 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_HCF) ||
3021 (pBssConfig->qosType != eCSR_MEDIUM_ACCESS_11e_eDCF) ))
3022 {
3023 //Joining BSS is 11n capable and WMM is disabled on AP.
3024 //Assume all HT AP's are QOS AP's and enable WMM
3025 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3026 }
3027
Jeff Johnson295189b2012-06-20 16:38:30 -07003028 //auth type
3029 switch( pProfile->negotiatedAuthType )
3030 {
3031 default:
3032 case eCSR_AUTH_TYPE_WPA:
3033 case eCSR_AUTH_TYPE_WPA_PSK:
3034 case eCSR_AUTH_TYPE_WPA_NONE:
3035 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3036 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3037 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 case eCSR_AUTH_TYPE_SHARED_KEY:
3039 pBssConfig->authType = eSIR_SHARED_KEY;
3040 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003041 case eCSR_AUTH_TYPE_AUTOSWITCH:
3042 pBssConfig->authType = eSIR_AUTO_SWITCH;
3043 break;
3044 }
3045 //short slot time
3046 if( eCSR_CFG_DOT11_MODE_11B != cfgDot11Mode )
3047 {
3048 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3049 }
3050 else
3051 {
3052 pBssConfig->uShortSlotTime = 0;
3053 }
3054 if(pBssConfig->BssCap.ibss)
3055 {
3056 //We don't support 11h on IBSS
3057 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3058 }
3059 else
3060 {
3061 pBssConfig->f11hSupport = pMac->roam.configParam.Is11hSupportEnabled;
3062 }
3063 //power constraint
3064 pBssConfig->uPowerLimit = csrGet11hPowerConstraint(pMac, &pIes->PowerConstraints);
3065 //heartbeat
3066 if ( CSR_IS_11A_BSS( pBssDesc ) )
3067 {
3068 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3069 }
3070 else
3071 {
3072 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3073 }
3074 //Join timeout
3075 // if we find a BeaconInterval in the BssDescription, then set the Join Timeout to
Jeff Johnsone7245742012-09-05 17:12:55 -07003076 // be 10 x the BeaconInterval.
Jeff Johnson295189b2012-06-20 16:38:30 -07003077 if ( pBssDesc->beaconInterval )
3078 {
3079 //Make sure it is bigger than the minimal
Jeff Johnsone7245742012-09-05 17:12:55 -07003080 pBssConfig->uJoinTimeOut = CSR_ROAM_MAX(10 * pBssDesc->beaconInterval, CSR_JOIN_FAILURE_TIMEOUT_MIN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003081 }
3082 else
3083 {
3084 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
3085 }
3086 //validate CB
3087 pBssConfig->cbMode = csrGetCBModeFromIes(pMac, pBssDesc->channelId, pIes);
Sandeep Puligilla60342762014-01-30 21:05:37 +05303088
Jeff Johnson295189b2012-06-20 16:38:30 -07003089 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003090 return (status);
3091}
3092
Jeff Johnson295189b2012-06-20 16:38:30 -07003093static eHalStatus csrRoamPrepareBssConfigFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
3094 tBssConfigParam *pBssConfig, tSirBssDescription *pBssDesc)
3095{
3096 eHalStatus status = eHAL_STATUS_SUCCESS;
3097 tANI_U8 operationChannel = 0;
3098 tANI_U8 qAPisEnabled = FALSE;
3099 //SSID
3100 pBssConfig->SSID.length = 0;
3101 if(pProfile->SSIDs.numOfSSIDs)
3102 {
3103 //only use the first one
Kiet Lam64c1b492013-07-12 13:56:44 +05303104 vos_mem_copy(&pBssConfig->SSID, &pProfile->SSIDs.SSIDList[0].SSID,
3105 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 }
3107 else
3108 {
3109 //SSID must present
3110 return eHAL_STATUS_FAILURE;
3111 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003112 //Settomg up the capabilities
3113 if( csrIsBssTypeIBSS(pProfile->BSSType) )
3114 {
3115 pBssConfig->BssCap.ibss = 1;
3116 }
3117 else
3118 {
3119 pBssConfig->BssCap.ess = 1;
3120 }
3121 if( eCSR_ENCRYPT_TYPE_NONE != pProfile->EncryptionType.encryptionType[0] )
3122 {
3123 pBssConfig->BssCap.privacy = 1;
3124 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003125 pBssConfig->eBand = pMac->roam.configParam.eBand;
3126 //phymode
3127 if(pProfile->ChannelInfo.ChannelList)
3128 {
3129 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003131 pBssConfig->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, operationChannel,
3132 &pBssConfig->eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -07003133 //QOS
3134 //Is this correct to always set to this //***
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 if ( pBssConfig->BssCap.ess == 1 )
3136 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 /*For Softap case enable WMM*/
3138 if(CSR_IS_INFRA_AP(pProfile) && (eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode )){
3139 qAPisEnabled = TRUE;
3140 }
3141 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 if (csrRoamGetQosInfoFromBss(pMac, pBssDesc) == eHAL_STATUS_SUCCESS) {
3143 qAPisEnabled = TRUE;
3144 } else {
3145 qAPisEnabled = FALSE;
3146 }
3147 } else {
3148 qAPisEnabled = TRUE;
3149 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003150 if (( eCsrRoamWmmNoQos != pMac->roam.configParam.WMMSupportMode && qAPisEnabled) ||
3151 (( eCSR_CFG_DOT11_MODE_11N == pBssConfig->uCfgDot11Mode && qAPisEnabled) ||
3152 ( eCSR_CFG_DOT11_MODE_TAURUS == pBssConfig->uCfgDot11Mode ) ) //For 11n, need QoS
3153 )
3154 {
3155 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP;
3156 } else {
3157 pBssConfig->qosType = eCSR_MEDIUM_ACCESS_DCF;
3158 }
3159
3160 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08003161 switch( pProfile->AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 {
3163 default:
3164 case eCSR_AUTH_TYPE_WPA:
3165 case eCSR_AUTH_TYPE_WPA_PSK:
3166 case eCSR_AUTH_TYPE_WPA_NONE:
3167 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3168 pBssConfig->authType = eSIR_OPEN_SYSTEM;
3169 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003170 case eCSR_AUTH_TYPE_SHARED_KEY:
3171 pBssConfig->authType = eSIR_SHARED_KEY;
3172 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003173 case eCSR_AUTH_TYPE_AUTOSWITCH:
3174 pBssConfig->authType = eSIR_AUTO_SWITCH;
3175 break;
3176 }
3177 //short slot time
3178 if( WNI_CFG_PHY_MODE_11B != pBssConfig->uCfgDot11Mode )
3179 {
3180 pBssConfig->uShortSlotTime = pMac->roam.configParam.shortSlotTime;
3181 }
3182 else
3183 {
3184 pBssConfig->uShortSlotTime = 0;
3185 }
3186 //power constraint. We don't support 11h on IBSS
3187 pBssConfig->f11hSupport = eANI_BOOLEAN_FALSE;
3188 pBssConfig->uPowerLimit = 0;
3189 //heartbeat
3190 if ( eCSR_BAND_5G == pBssConfig->eBand )
3191 {
3192 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh50;
3193 }
3194 else
3195 {
3196 pBssConfig->uHeartBeatThresh = pMac->roam.configParam.HeartbeatThresh24;
3197 }
3198 //Join timeout
3199 pBssConfig->uJoinTimeOut = CSR_JOIN_FAILURE_TIMEOUT_DEFAULT;
Jeff Johnsone7245742012-09-05 17:12:55 -07003200
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 return (status);
3202}
Jeff Johnson295189b2012-06-20 16:38:30 -07003203static eHalStatus csrRoamGetQosInfoFromBss(tpAniSirGlobal pMac, tSirBssDescription *pBssDesc)
3204{
3205 eHalStatus status = eHAL_STATUS_FAILURE;
3206 tDot11fBeaconIEs *pIes = NULL;
3207
3208 do
3209 {
3210 if(!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
3211 {
3212 //err msg
3213 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003214 "csrRoamGetQosInfoFromBss() failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07003215 break;
3216 }
3217 //check if the AP is QAP & it supports APSD
3218 if( CSR_IS_QOS_BSS(pIes) )
3219 {
Kiet Lamb537cfb2013-11-07 12:56:49 +05303220 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07003221 }
3222 } while (0);
Kiet Lamb537cfb2013-11-07 12:56:49 +05303223
3224 if (NULL != pIes)
3225 {
3226 vos_mem_free(pIes);
3227 }
3228
Jeff Johnson295189b2012-06-20 16:38:30 -07003229 return status;
3230}
3231
Jeff Johnson295189b2012-06-20 16:38:30 -07003232void csrSetCfgPrivacy( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, tANI_BOOLEAN fPrivacy )
3233{
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 // !! Note: the only difference between this function and the csrSetCfgPrivacyFromProfile() is the
3235 // setting of the privacy CFG based on the advertised privacy setting from the AP for WPA associations.
3236 // See !!Note: below in this function...
3237 tANI_U32 PrivacyEnabled = 0;
3238 tANI_U32 RsnEnabled = 0;
3239 tANI_U32 WepDefaultKeyId = 0;
3240 tANI_U32 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5; /* default 40 bits */
3241 tANI_U32 Key0Length = 0;
3242 tANI_U32 Key1Length = 0;
3243 tANI_U32 Key2Length = 0;
3244 tANI_U32 Key3Length = 0;
3245
3246 // Reserve for the biggest key
3247 tANI_U8 Key0[ WNI_CFG_WEP_DEFAULT_KEY_1_LEN ];
3248 tANI_U8 Key1[ WNI_CFG_WEP_DEFAULT_KEY_2_LEN ];
3249 tANI_U8 Key2[ WNI_CFG_WEP_DEFAULT_KEY_3_LEN ];
3250 tANI_U8 Key3[ WNI_CFG_WEP_DEFAULT_KEY_4_LEN ];
3251
3252 switch ( pProfile->negotiatedUCEncryptionType )
3253 {
3254 case eCSR_ENCRYPT_TYPE_NONE:
3255
3256 // for NO encryption, turn off Privacy and Rsn.
3257 PrivacyEnabled = 0;
3258 RsnEnabled = 0;
3259
3260 // WEP key length and Wep Default Key ID don't matter in this case....
3261
3262 // clear out the WEP keys that may be hanging around.
3263 Key0Length = 0;
3264 Key1Length = 0;
3265 Key2Length = 0;
3266 Key3Length = 0;
3267
3268 break;
3269
3270 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303271 case eCSR_ENCRYPT_TYPE_WEP40:
Jeff Johnson295189b2012-06-20 16:38:30 -07003272
3273 // Privacy is ON. NO RSN for Wep40 static key.
3274 PrivacyEnabled = 1;
3275 RsnEnabled = 0;
3276
3277 // Set the Wep default key ID.
3278 WepDefaultKeyId = pProfile->Keys.defaultIndex;
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 // Wep key size if 5 bytes (40 bits).
3280 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_5;
3281
3282 // set encryption keys in the CFG database or clear those that are not present in this profile.
3283 if ( pProfile->Keys.KeyLength[0] )
3284 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303285 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[0],
3286 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 Key0Length = WNI_CFG_WEP_KEY_LENGTH_5;
3288 }
3289 else
3290 {
3291 Key0Length = 0;
3292 }
3293
3294 if ( pProfile->Keys.KeyLength[1] )
3295 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303296 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[1],
3297 WNI_CFG_WEP_KEY_LENGTH_5);
3298 Key1Length = WNI_CFG_WEP_KEY_LENGTH_5;
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 }
3300 else
3301 {
3302 Key1Length = 0;
3303 }
3304
3305 if ( pProfile->Keys.KeyLength[2] )
3306 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303307 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[2],
3308 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 Key2Length = WNI_CFG_WEP_KEY_LENGTH_5;
3310 }
3311 else
3312 {
3313 Key2Length = 0;
3314 }
3315
3316 if ( pProfile->Keys.KeyLength[3] )
3317 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303318 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[3],
3319 WNI_CFG_WEP_KEY_LENGTH_5);
Jeff Johnson295189b2012-06-20 16:38:30 -07003320 Key3Length = WNI_CFG_WEP_KEY_LENGTH_5;
3321 }
3322 else
3323 {
3324 Key3Length = 0;
3325 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003326 break;
3327
3328 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
Gopichand Nakkala29149562013-05-10 21:43:41 +05303329 case eCSR_ENCRYPT_TYPE_WEP104:
Jeff Johnson295189b2012-06-20 16:38:30 -07003330
3331 // Privacy is ON. NO RSN for Wep40 static key.
3332 PrivacyEnabled = 1;
3333 RsnEnabled = 0;
3334
3335 // Set the Wep default key ID.
3336 WepDefaultKeyId = pProfile->Keys.defaultIndex;
3337
3338 // Wep key size if 13 bytes (104 bits).
3339 WepKeyLength = WNI_CFG_WEP_KEY_LENGTH_13;
3340
3341 // set encryption keys in the CFG database or clear those that are not present in this profile.
3342 if ( pProfile->Keys.KeyLength[0] )
3343 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303344 vos_mem_copy(Key0, pProfile->Keys.KeyMaterial[ 0 ],
3345 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 Key0Length = WNI_CFG_WEP_KEY_LENGTH_13;
3347 }
3348 else
3349 {
3350 Key0Length = 0;
3351 }
3352
3353 if ( pProfile->Keys.KeyLength[1] )
3354 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303355 vos_mem_copy(Key1, pProfile->Keys.KeyMaterial[ 1 ],
3356 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 Key1Length = WNI_CFG_WEP_KEY_LENGTH_13;
3358 }
3359 else
3360 {
3361 Key1Length = 0;
3362 }
3363
3364 if ( pProfile->Keys.KeyLength[2] )
3365 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303366 vos_mem_copy(Key2, pProfile->Keys.KeyMaterial[ 2 ],
3367 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 Key2Length = WNI_CFG_WEP_KEY_LENGTH_13;
3369 }
3370 else
3371 {
3372 Key2Length = 0;
3373 }
3374
3375 if ( pProfile->Keys.KeyLength[3] )
3376 {
Kiet Lam64c1b492013-07-12 13:56:44 +05303377 vos_mem_copy(Key3, pProfile->Keys.KeyMaterial[ 3 ],
3378 WNI_CFG_WEP_KEY_LENGTH_13);
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 Key3Length = WNI_CFG_WEP_KEY_LENGTH_13;
3380 }
3381 else
3382 {
3383 Key3Length = 0;
3384 }
3385
3386 break;
3387
Jeff Johnson295189b2012-06-20 16:38:30 -07003388 case eCSR_ENCRYPT_TYPE_TKIP:
3389 case eCSR_ENCRYPT_TYPE_AES:
3390#ifdef FEATURE_WLAN_WAPI
3391 case eCSR_ENCRYPT_TYPE_WPI:
3392#endif /* FEATURE_WLAN_WAPI */
3393 // !! Note: this is the only difference between this function and the csrSetCfgPrivacyFromProfile()
3394 // (setting of the privacy CFG based on the advertised privacy setting from the AP for WPA/WAPI associations ).
3395 PrivacyEnabled = (0 != fPrivacy);
3396
3397 // turn on RSN enabled for WPA associations
3398 RsnEnabled = 1;
3399
3400 // WEP key length and Wep Default Key ID don't matter in this case....
3401
3402 // clear out the static WEP keys that may be hanging around.
3403 Key0Length = 0;
3404 Key1Length = 0;
3405 Key2Length = 0;
3406 Key3Length = 0;
3407
3408 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003409 default:
3410 PrivacyEnabled = 0;
3411 RsnEnabled = 0;
3412 break;
3413 }
3414
3415 ccmCfgSetInt(pMac, WNI_CFG_PRIVACY_ENABLED, PrivacyEnabled, NULL, eANI_BOOLEAN_FALSE);
3416 ccmCfgSetInt(pMac, WNI_CFG_RSN_ENABLED, RsnEnabled, NULL, eANI_BOOLEAN_FALSE);
3417 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_1, Key0, Key0Length, NULL, eANI_BOOLEAN_FALSE);
3418 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_2, Key1, Key1Length, NULL, eANI_BOOLEAN_FALSE);
3419 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_3, Key2, Key2Length, NULL, eANI_BOOLEAN_FALSE);
3420 ccmCfgSetStr(pMac, WNI_CFG_WEP_DEFAULT_KEY_4, Key3, Key3Length, NULL, eANI_BOOLEAN_FALSE);
3421 ccmCfgSetInt(pMac, WNI_CFG_WEP_KEY_LENGTH, WepKeyLength, NULL, eANI_BOOLEAN_FALSE);
3422 ccmCfgSetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, WepDefaultKeyId, NULL, eANI_BOOLEAN_FALSE);
3423}
3424
Jeff Johnson295189b2012-06-20 16:38:30 -07003425static void csrSetCfgSsid( tpAniSirGlobal pMac, tSirMacSSid *pSSID )
3426{
3427 tANI_U32 len = 0;
3428 if(pSSID->length <= WNI_CFG_SSID_LEN)
3429 {
3430 len = pSSID->length;
3431 }
3432 ccmCfgSetStr(pMac, WNI_CFG_SSID, (tANI_U8 *)pSSID->ssId, len, NULL, eANI_BOOLEAN_FALSE);
3433}
3434
Jeff Johnson295189b2012-06-20 16:38:30 -07003435eHalStatus csrSetQosToCfg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrMediaAccessType qosType )
3436{
3437 eHalStatus status = eHAL_STATUS_SUCCESS;
3438 tANI_U32 QoSEnabled;
3439 tANI_U32 WmeEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 // set the CFG enable/disable variables based on the qosType being configured...
3441 switch( qosType )
3442 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003443 case eCSR_MEDIUM_ACCESS_WMM_eDCF_802dot1p:
3444 QoSEnabled = FALSE;
3445 WmeEnabled = TRUE;
3446 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003447 case eCSR_MEDIUM_ACCESS_WMM_eDCF_DSCP:
3448 QoSEnabled = FALSE;
3449 WmeEnabled = TRUE;
3450 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003451 case eCSR_MEDIUM_ACCESS_WMM_eDCF_NoClassify:
3452 QoSEnabled = FALSE;
3453 WmeEnabled = TRUE;
3454 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 case eCSR_MEDIUM_ACCESS_11e_eDCF:
3456 QoSEnabled = TRUE;
3457 WmeEnabled = FALSE;
3458 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003459 case eCSR_MEDIUM_ACCESS_11e_HCF:
3460 QoSEnabled = TRUE;
3461 WmeEnabled = FALSE;
3462 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003463 default:
3464 case eCSR_MEDIUM_ACCESS_DCF:
3465 QoSEnabled = FALSE;
3466 WmeEnabled = FALSE;
3467 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 }
3469 //save the WMM setting for later use
3470 pMac->roam.roamSession[sessionId].fWMMConnection = (tANI_BOOLEAN)WmeEnabled;
Sandeep Puligillaaea98a22013-12-04 13:36:32 +05303471 pMac->roam.roamSession[sessionId].fQOSConnection = (tANI_BOOLEAN)QoSEnabled;
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 return (status);
3473}
Jeff Johnson295189b2012-06-20 16:38:30 -07003474static eHalStatus csrGetRateSet( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile, eCsrPhyMode phyMode, tSirBssDescription *pBssDesc,
3475 tDot11fBeaconIEs *pIes, tSirMacRateSet *pOpRateSet, tSirMacRateSet *pExRateSet)
3476{
3477 eHalStatus status = eHAL_STATUS_FAILURE;
3478 int i;
3479 eCsrCfgDot11Mode cfgDot11Mode;
3480 tANI_U8 *pDstRate;
Kiet Lam64c1b492013-07-12 13:56:44 +05303481 vos_mem_set(pOpRateSet, sizeof(tSirMacRateSet), 0);
3482 vos_mem_set(pExRateSet, sizeof(tSirMacRateSet), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07003483 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003484
3485 if( NULL != pIes )
3486 {
3487 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003488 // Originally, we thought that for 11a networks, the 11a rates are always
3489 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3490 // appear in the Operational Rate set. Consequently, in either case, we
3491 // would blindly put the rates we support into our Operational Rate set
3492 // (including the basic rates, which we have already verified are
3493 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003494 // However, it turns out that this is not always the case. Some AP's
3495 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3496 // too. Now, we're a little more careful:
3497 pDstRate = pOpRateSet->rate;
3498 if(pIes->SuppRates.present)
3499 {
3500 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3501 {
3502 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) )
3503 {
3504 *pDstRate++ = pIes->SuppRates.rates[ i ];
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07003505 pOpRateSet->numRates++;
Jeff Johnson295189b2012-06-20 16:38:30 -07003506 }
3507 }
3508 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3510 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3511 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3512 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3513 {
3514 // If there are Extended Rates in the beacon, we will reflect those
3515 // extended rates that we support in out Extended Operational Rate
3516 // set:
3517 pDstRate = pExRateSet->rate;
3518 if(pIes->ExtSuppRates.present)
3519 {
3520 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3521 {
3522 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) )
3523 {
3524 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3525 pExRateSet->numRates++;
3526 }
3527 }
3528 }
3529 }
3530 }//Parsing BSSDesc
3531 else
3532 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003533 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003534 }
3535 if (pOpRateSet->numRates > 0 || pExRateSet->numRates > 0) status = eHAL_STATUS_SUCCESS;
3536 return status;
3537}
3538
3539static void csrSetCfgRateSet( tpAniSirGlobal pMac, eCsrPhyMode phyMode, tCsrRoamProfile *pProfile,
3540 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3541{
3542 int i;
3543 tANI_U8 *pDstRate;
3544 eCsrCfgDot11Mode cfgDot11Mode;
3545 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3546 tANI_U32 OperationalRatesLength = 0;
3547 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3548 tANI_U32 ExtendedOperationalRatesLength = 0;
3549 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3550 tANI_U32 ProprietaryOperationalRatesLength = 0;
3551 tANI_U32 PropRatesEnable = 0;
3552 tANI_U8 MCSRateIdxSet[ SIZE_OF_SUPPORTED_MCS_SET ];
3553 tANI_U32 MCSRateLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003554 VOS_ASSERT( pIes != NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07003555 if( NULL != pIes )
3556 {
3557 csrIsPhyModeMatch( pMac, phyMode, pBssDesc, pProfile, &cfgDot11Mode, pIes );
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 // Originally, we thought that for 11a networks, the 11a rates are always
3559 // in the Operational Rate set & for 11b and 11g networks, the 11b rates
3560 // appear in the Operational Rate set. Consequently, in either case, we
3561 // would blindly put the rates we support into our Operational Rate set
3562 // (including the basic rates, which we have already verified are
3563 // supported earlier in the roaming decision).
Jeff Johnson295189b2012-06-20 16:38:30 -07003564 // However, it turns out that this is not always the case. Some AP's
3565 // (e.g. D-Link DI-784) ram 11g rates into the Operational Rate set,
3566 // too. Now, we're a little more careful:
3567 pDstRate = OperationalRates;
3568 if(pIes->SuppRates.present)
3569 {
3570 for ( i = 0; i < pIes->SuppRates.num_rates; i++ )
3571 {
3572 if ( csrRatesIsDot11RateSupported( pMac, pIes->SuppRates.rates[ i ] ) &&
3573 ( OperationalRatesLength < CSR_DOT11_SUPPORTED_RATES_MAX ))
3574 {
3575 *pDstRate++ = pIes->SuppRates.rates[ i ];
3576 OperationalRatesLength++;
3577 }
3578 }
3579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 if ( eCSR_CFG_DOT11_MODE_11G == cfgDot11Mode ||
3581 eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode ||
3582 eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode ||
3583 eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
3584 {
3585 // If there are Extended Rates in the beacon, we will reflect those
3586 // extended rates that we support in out Extended Operational Rate
3587 // set:
3588 pDstRate = ExtendedOperationalRates;
3589 if(pIes->ExtSuppRates.present)
3590 {
3591 for ( i = 0; i < pIes->ExtSuppRates.num_rates; i++ )
3592 {
3593 if ( csrRatesIsDot11RateSupported( pMac, pIes->ExtSuppRates.rates[ i ] ) &&
3594 ( ExtendedOperationalRatesLength < CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ))
3595 {
3596 *pDstRate++ = pIes->ExtSuppRates.rates[ i ];
3597 ExtendedOperationalRatesLength++;
3598 }
3599 }
3600 }
3601 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003602 // Enable proprietary MAC features if peer node is Airgo node and STA
3603 // user wants to use them
3604 if( pIes->Airgo.present && pMac->roam.configParam.ProprietaryRatesEnabled )
3605 {
3606 PropRatesEnable = 1;
3607 }
3608 else
3609 {
3610 PropRatesEnable = 0;
3611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 // For ANI network companions, we need to populate the proprietary rate
3613 // set with any proprietary rates we found in the beacon, only if user
3614 // allows them...
3615 if ( PropRatesEnable && pIes->Airgo.PropSuppRates.present &&
3616 ( pIes->Airgo.PropSuppRates.num_rates > 0 ))
3617 {
3618 ProprietaryOperationalRatesLength = pIes->Airgo.PropSuppRates.num_rates;
3619 if ( ProprietaryOperationalRatesLength > sizeof(ProprietaryOperationalRates) )
3620 {
3621 ProprietaryOperationalRatesLength = sizeof (ProprietaryOperationalRates);
3622 }
Kiet Lam64c1b492013-07-12 13:56:44 +05303623 vos_mem_copy(ProprietaryOperationalRates,
3624 pIes->Airgo.PropSuppRates.rates,
3625 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 }
3627 else {
3628 // No proprietary modes...
3629 ProprietaryOperationalRatesLength = 0;
3630 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 /* Get MCS Rate */
3632 pDstRate = MCSRateIdxSet;
3633 if ( pIes->HTCaps.present )
3634 {
3635 for ( i = 0; i < VALID_MAX_MCS_INDEX; i++ )
3636 {
3637 if ( (unsigned int)pIes->HTCaps.supportedMCSSet[0] & (1 << i) )
3638 {
3639 MCSRateLength++;
3640 *pDstRate++ = i;
3641 }
3642 }
3643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 // Set the operational rate set CFG variables...
3645 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3646 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3647 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3648 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3649 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3650 ProprietaryOperationalRates,
3651 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3652 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
3653 ccmCfgSetStr(pMac, WNI_CFG_CURRENT_MCS_SET, MCSRateIdxSet,
3654 MCSRateLength, NULL, eANI_BOOLEAN_FALSE);
3655 }//Parsing BSSDesc
3656 else
3657 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003658 smsLog(pMac, LOGE, FL("failed to parse BssDesc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 }
3660}
3661
Jeff Johnson295189b2012-06-20 16:38:30 -07003662static void csrSetCfgRateSetFromProfile( tpAniSirGlobal pMac,
3663 tCsrRoamProfile *pProfile )
3664{
3665 tSirMacRateSetIE DefaultSupportedRates11a = { SIR_MAC_RATESET_EID,
3666 { 8,
3667 { SIR_MAC_RATE_6,
3668 SIR_MAC_RATE_9,
3669 SIR_MAC_RATE_12,
3670 SIR_MAC_RATE_18,
3671 SIR_MAC_RATE_24,
3672 SIR_MAC_RATE_36,
3673 SIR_MAC_RATE_48,
3674 SIR_MAC_RATE_54 } } };
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 tSirMacRateSetIE DefaultSupportedRates11b = { SIR_MAC_RATESET_EID,
3676 { 4,
3677 { SIR_MAC_RATE_1,
3678 SIR_MAC_RATE_2,
3679 SIR_MAC_RATE_5_5,
3680 SIR_MAC_RATE_11 } } };
3681
3682
3683 tSirMacPropRateSet DefaultSupportedPropRates = { 3,
3684 { SIR_MAC_RATE_72,
3685 SIR_MAC_RATE_96,
3686 SIR_MAC_RATE_108 } };
3687 eCsrCfgDot11Mode cfgDot11Mode;
3688 eCsrBand eBand;
3689 tANI_U8 OperationalRates[ CSR_DOT11_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3690 tANI_U32 OperationalRatesLength = 0;
3691 tANI_U8 ExtendedOperationalRates[ CSR_DOT11_EXTENDED_SUPPORTED_RATES_MAX ]; // leave enough room for the max number of rates
3692 tANI_U32 ExtendedOperationalRatesLength = 0;
3693 tANI_U8 ProprietaryOperationalRates[ 4 ]; // leave enough room for the max number of proprietary rates
3694 tANI_U32 ProprietaryOperationalRatesLength = 0;
3695 tANI_U32 PropRatesEnable = 0;
3696 tANI_U8 operationChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003697 if(pProfile->ChannelInfo.ChannelList)
3698 {
3699 operationChannel = pProfile->ChannelInfo.ChannelList[0];
3700 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -07003702 // For 11a networks, the 11a rates go into the Operational Rate set. For 11b and 11g
3703 // networks, the 11b rates appear in the Operational Rate set. In either case,
3704 // we can blindly put the rates we support into our Operational Rate set
3705 // (including the basic rates, which we have already verified are supported
3706 // earlier in the roaming decision).
3707 if ( eCSR_BAND_5G == eBand )
3708 {
3709 // 11a rates into the Operational Rate Set.
3710 OperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3711 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303712 vos_mem_copy(OperationalRates,
3713 DefaultSupportedRates11a.supportedRateSet.rate,
3714 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003715
3716 // Nothing in the Extended rate set.
3717 ExtendedOperationalRatesLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003718 // populate proprietary rates if user allows them
3719 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3720 {
3721 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3722 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303723 vos_mem_copy(ProprietaryOperationalRates,
3724 DefaultSupportedPropRates.propRate,
3725 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 }
3727 else
3728 {
3729 // No proprietary modes
3730 ProprietaryOperationalRatesLength = 0;
3731 }
3732 }
3733 else if ( eCSR_CFG_DOT11_MODE_11B == cfgDot11Mode )
3734 {
3735 // 11b rates into the Operational Rate Set.
3736 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3737 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303738 vos_mem_copy(OperationalRates,
3739 DefaultSupportedRates11b.supportedRateSet.rate,
3740 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 // Nothing in the Extended rate set.
3742 ExtendedOperationalRatesLength = 0;
3743 // No proprietary modes
3744 ProprietaryOperationalRatesLength = 0;
3745 }
3746 else
3747 {
3748 // 11G
3749
3750 // 11b rates into the Operational Rate Set.
3751 OperationalRatesLength = DefaultSupportedRates11b.supportedRateSet.numRates *
3752 sizeof(*DefaultSupportedRates11b.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303753 vos_mem_copy(OperationalRates,
3754 DefaultSupportedRates11b.supportedRateSet.rate,
3755 OperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003756
3757 // 11a rates go in the Extended rate set.
3758 ExtendedOperationalRatesLength = DefaultSupportedRates11a.supportedRateSet.numRates *
3759 sizeof(*DefaultSupportedRates11a.supportedRateSet.rate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303760 vos_mem_copy(ExtendedOperationalRates,
3761 DefaultSupportedRates11a.supportedRateSet.rate,
3762 ExtendedOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003763
3764 // populate proprietary rates if user allows them
3765 if ( pMac->roam.configParam.ProprietaryRatesEnabled )
3766 {
3767 ProprietaryOperationalRatesLength = DefaultSupportedPropRates.numPropRates *
3768 sizeof(*DefaultSupportedPropRates.propRate);
Kiet Lam64c1b492013-07-12 13:56:44 +05303769 vos_mem_copy(ProprietaryOperationalRates,
3770 DefaultSupportedPropRates.propRate,
3771 ProprietaryOperationalRatesLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 }
3773 else
3774 {
3775 // No proprietary modes
3776 ProprietaryOperationalRatesLength = 0;
3777 }
3778 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003779 // set this to 1 if prop. rates need to be advertised in to the IBSS beacon and user wants to use them
3780 if ( ProprietaryOperationalRatesLength && pMac->roam.configParam.ProprietaryRatesEnabled )
3781 {
3782 PropRatesEnable = 1;
3783 }
3784 else
3785 {
3786 PropRatesEnable = 0;
3787 }
3788
3789 // Set the operational rate set CFG variables...
3790 ccmCfgSetStr(pMac, WNI_CFG_OPERATIONAL_RATE_SET, OperationalRates,
3791 OperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3792 ccmCfgSetStr(pMac, WNI_CFG_EXTENDED_OPERATIONAL_RATE_SET, ExtendedOperationalRates,
3793 ExtendedOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3794 ccmCfgSetStr(pMac, WNI_CFG_PROPRIETARY_OPERATIONAL_RATE_SET,
3795 ProprietaryOperationalRates,
3796 ProprietaryOperationalRatesLength, NULL, eANI_BOOLEAN_FALSE);
3797 ccmCfgSetInt(pMac, WNI_CFG_PROPRIETARY_ANI_FEATURES_ENABLED, PropRatesEnable, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003798}
Jeff Johnson295189b2012-06-20 16:38:30 -07003799void csrRoamCcmCfgSetCallback(tHalHandle hHal, tANI_S32 result)
3800{
3801 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
Jeff Johnsone7245742012-09-05 17:12:55 -07003802
Jeff Johnson295189b2012-06-20 16:38:30 -07003803 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
3804 tANI_U32 sessionId;
3805 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003806 if(NULL == pEntry)
3807 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08003808 smsLog(pMac, LOGW, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07003809 return;
3810 }
3811 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
3812 sessionId = pCommand->sessionId;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05303813 smsLog(pMac, LOG1, FL("CCM CFG return value is %d, "
3814 " current state : %d sub state : %d "),
3815 result, pMac->roam.curState[sessionId],
3816 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003817 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
3818 {
3819 csrRoamingStateConfigCnfProcessor(pMac, (tANI_U32)result);
3820 }
3821}
3822
Jeff Johnson295189b2012-06-20 16:38:30 -07003823//This function is very dump. It is here because PE still need WNI_CFG_PHY_MODE
3824tANI_U32 csrRoamGetPhyModeFromDot11Mode(eCsrCfgDot11Mode dot11Mode, eCsrBand band)
3825{
3826 if(eCSR_CFG_DOT11_MODE_11B == dot11Mode)
3827 {
3828 return (WNI_CFG_PHY_MODE_11B);
3829 }
3830 else
3831 {
3832 if(eCSR_BAND_24 == band)
3833 return (WNI_CFG_PHY_MODE_11G);
3834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 return (WNI_CFG_PHY_MODE_11A);
3836}
Jeff Johnson295189b2012-06-20 16:38:30 -07003837
Jeff Johnsone7245742012-09-05 17:12:55 -07003838
3839#ifdef WLAN_FEATURE_11AC
3840ePhyChanBondState csrGetHTCBStateFromVHTCBState(ePhyChanBondState aniCBMode)
3841{
3842 switch ( aniCBMode )
3843 {
3844 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_LOW:
3845 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_CENTERED:
3846 case PHY_QUADRUPLE_CHANNEL_20MHZ_HIGH_40MHZ_HIGH:
3847 return PHY_DOUBLE_CHANNEL_HIGH_PRIMARY;
3848 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_LOW:
3849 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_CENTERED:
3850 case PHY_QUADRUPLE_CHANNEL_20MHZ_LOW_40MHZ_HIGH:
3851 return PHY_DOUBLE_CHANNEL_LOW_PRIMARY;
3852 case PHY_QUADRUPLE_CHANNEL_20MHZ_CENTERED_40MHZ_CENTERED:
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003853 default :
Jeff Johnsone7245742012-09-05 17:12:55 -07003854 return PHY_SINGLE_CHANNEL_CENTERED;
3855 }
3856}
3857#endif
3858
Jeff Johnson295189b2012-06-20 16:38:30 -07003859//pIes may be NULL
3860eHalStatus csrRoamSetBssConfigCfg(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3861 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig,
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303862 tDot11fBeaconIEs *pIes, tANI_BOOLEAN resetCountry)
Jeff Johnson295189b2012-06-20 16:38:30 -07003863{
3864 eHalStatus status = eHAL_STATUS_SUCCESS;
3865 tANI_U32 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
3866 tANI_U8 channel = 0;
3867 //Make sure we have the domain info for the BSS we try to connect to.
3868 //Do we need to worry about sequence for OSs that are not Windows??
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303869 if (pBssDesc)
Jeff Johnson295189b2012-06-20 16:38:30 -07003870 {
Chandrasekaran, Manishekar90c49322014-06-24 13:26:14 +05303871 if (csrLearnCountryInformation(pMac, pBssDesc, pIes, eANI_BOOLEAN_TRUE))
Jeff Johnson295189b2012-06-20 16:38:30 -07003872 {
3873 //Make sure the 11d info from this BSSDesc can be applied
3874 pMac->scan.fAmbiguous11dInfoFound = eANI_BOOLEAN_FALSE;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05303875 if (VOS_TRUE == resetCountry)
3876 {
3877 csrApplyCountryInformation(pMac, FALSE);
3878 }
3879 else
3880 {
3881 csrApplyCountryInformation(pMac, TRUE);
3882 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003883 }
Kiran4a17ebe2013-01-31 10:43:43 -08003884 if ((csrIs11dSupported (pMac)) && pIes)
3885 {
3886 if (!pIes->Country.present)
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003887 {
Kiran4a17ebe2013-01-31 10:43:43 -08003888 csrResetCountryInformation(pMac, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE );
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003889 }
3890 else
3891 {
3892 //Let's also update the below to make sure we don't update CC while
3893 //connected to an AP which is advertising some CC
Kiet Lamf2f201e2013-11-16 21:24:16 +05303894 vos_mem_copy(pMac->scan.currentCountryBssid,
Tushnim Bhattacharyyac3c1e8e2013-10-29 17:27:43 -07003895 pBssDesc->bssId, sizeof(tSirMacAddr));
3896 }
Kiran4a17ebe2013-01-31 10:43:43 -08003897 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 //Qos
3900 csrSetQosToCfg( pMac, sessionId, pBssConfig->qosType );
3901 //SSID
3902 csrSetCfgSsid(pMac, &pBssConfig->SSID );
3903 //fragment threshold
3904 //ccmCfgSetInt(pMac, WNI_CFG_FRAGMENTATION_THRESHOLD, csrGetFragThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3905 //RTS threshold
3906 //ccmCfgSetInt(pMac, WNI_CFG_RTS_THRESHOLD, csrGetRTSThresh(pMac), NULL, eANI_BOOLEAN_FALSE);
3907
3908 //ccmCfgSetInt(pMac, WNI_CFG_DOT11_MODE, csrTranslateToWNICfgDot11Mode(pMac, pBssConfig->uCfgDot11Mode), NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003909 //Auth type
3910 ccmCfgSetInt(pMac, WNI_CFG_AUTHENTICATION_TYPE, pBssConfig->authType, NULL, eANI_BOOLEAN_FALSE);
3911 //encryption type
3912 csrSetCfgPrivacy(pMac, pProfile, (tANI_BOOLEAN)pBssConfig->BssCap.privacy );
3913 //short slot time
3914 ccmCfgSetInt(pMac, WNI_CFG_11G_SHORT_SLOT_TIME_ENABLED, pBssConfig->uShortSlotTime, NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003915 //11d
3916 ccmCfgSetInt(pMac, WNI_CFG_11D_ENABLED,
3917 ((pBssConfig->f11hSupport) ? pBssConfig->f11hSupport : pProfile->ieee80211d),
3918 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 /*//11h
3920 ccmCfgSetInt(pMac, WNI_CFG_11H_ENABLED, pMac->roam.configParam.Is11hSupportEnabled, NULL, eANI_BOOLEAN_FALSE);
3921 */
3922 ccmCfgSetInt(pMac, WNI_CFG_LOCAL_POWER_CONSTRAINT, pBssConfig->uPowerLimit, NULL, eANI_BOOLEAN_FALSE);
3923 //CB
Jeff Johnsone7245742012-09-05 17:12:55 -07003924
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003925 if(CSR_IS_INFRA_AP(pProfile) || CSR_IS_WDS_AP(pProfile) || CSR_IS_IBSS(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 {
3927 channel = pProfile->operationChannel;
3928 }
3929 else
3930 {
3931 if(pBssDesc)
3932 {
3933 channel = pBssDesc->channelId;
3934 }
3935 }
3936 if(0 != channel)
3937 {
Sandeep Puligilla60342762014-01-30 21:05:37 +05303938 if(CSR_IS_CHANNEL_24GHZ(channel) &&
3939 !pMac->roam.configParam.channelBondingMode24GHz &&
3940 !WDA_getFwWlanFeatCaps(HT40_OBSS_SCAN))
3941 {//On 2.4 Ghz, CB will be disabled if it is not configured through .ini
Jeff Johnson295189b2012-06-20 16:38:30 -07003942 cfgCb = WNI_CFG_CHANNEL_BONDING_MODE_DISABLE;
Sandeep Puligilla60342762014-01-30 21:05:37 +05303943 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
3944 " cbMode disabled cfgCb = %d channelBondingMode24GHz %d",
3945 __func__, cfgCb, pMac->roam.configParam.channelBondingMode24GHz);
Jeff Johnson295189b2012-06-20 16:38:30 -07003946 }
3947 else
3948 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003949 cfgCb = pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003950 }
3951 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003952#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudia0d88932012-11-13 10:51:26 -08003953 // cbMode = 1 in cfg.ini is mapped to PHY_DOUBLE_CHANNEL_HIGH_PRIMARY = 3
3954 // in function csrConvertCBIniValueToPhyCBState()
3955 // So, max value for cbMode in 40MHz mode is 3 (MAC\src\include\sirParams.h)
3956 if(cfgCb > PHY_DOUBLE_CHANNEL_HIGH_PRIMARY)
Jeff Johnsone7245742012-09-05 17:12:55 -07003957 {
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003958 if(!WDA_getFwWlanFeatCaps(DOT11AC)) {
Jeff Johnsone7245742012-09-05 17:12:55 -07003959 cfgCb = csrGetHTCBStateFromVHTCBState(cfgCb);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003960 }
Sandeep Puligilla60342762014-01-30 21:05:37 +05303961 else
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003962 {
Jeff Johnsone7245742012-09-05 17:12:55 -07003963 ccmCfgSetInt(pMac, WNI_CFG_VHT_CHANNEL_WIDTH, pMac->roam.configParam.nVhtChannelWidth, NULL, eANI_BOOLEAN_FALSE);
Madan Mohan Koyyalamudi2c112c52012-10-30 17:59:49 -07003964 }
Jeff Johnsone7245742012-09-05 17:12:55 -07003965 }
3966 else
3967#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003968 ccmCfgSetInt(pMac, WNI_CFG_CHANNEL_BONDING_MODE, cfgCb, NULL, eANI_BOOLEAN_FALSE);
3969 //Rate
3970 //Fixed Rate
3971 if(pBssDesc)
3972 {
3973 csrSetCfgRateSet(pMac, (eCsrPhyMode)pProfile->phyMode, pProfile, pBssDesc, pIes);
3974 }
3975 else
3976 {
3977 csrSetCfgRateSetFromProfile(pMac, pProfile);
3978 }
3979 //Make this the last CFG to set. The callback will trigger a join_req
3980 //Join time out
3981 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_CONFIG, sessionId );
3982
3983 ccmCfgSetInt(pMac, WNI_CFG_JOIN_FAILURE_TIMEOUT, pBssConfig->uJoinTimeOut, (tCcmCfgSetCallback)csrRoamCcmCfgSetCallback, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 return (status);
3985}
3986
Jeff Johnson295189b2012-06-20 16:38:30 -07003987eHalStatus csrRoamStopNetwork( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
3988 tSirBssDescription *pBssDesc, tDot11fBeaconIEs *pIes)
3989{
3990 eHalStatus status;
3991 tBssConfigParam *pBssConfig;
3992 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07003993
3994 if(!pSession)
3995 {
3996 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
3997 return eHAL_STATUS_FAILURE;
3998 }
3999
Kiet Lam64c1b492013-07-12 13:56:44 +05304000 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
4001 if ( NULL == pBssConfig )
4002 status = eHAL_STATUS_FAILURE;
4003 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304005 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, pBssConfig, pIes);
4007 if(HAL_STATUS_SUCCESS(status))
4008 {
4009 pSession->bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004010 /* This will allow to pass cbMode during join req */
4011 pSession->bssParams.cbMode= pBssConfig->cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004012 //For IBSS, we need to prepare some more information
4013 if( csrIsBssTypeIBSS(pProfile->BSSType) || CSR_IS_WDS( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 || CSR_IS_INFRA_AP(pProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 )
4016 {
Jeff Johnsone7245742012-09-05 17:12:55 -07004017 csrRoamPrepareBssParams(pMac, sessionId, pProfile, pBssDesc, pBssConfig, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004018 }
4019 // If we are in an IBSS, then stop the IBSS...
4020 ////Not worry about WDS connection for now
4021 if ( csrIsConnStateIbss( pMac, sessionId ) )
4022 {
4023 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
4024 }
4025 else
4026 {
4027 // if we are in an Infrastructure association....
4028 if ( csrIsConnStateInfra( pMac, sessionId ) )
4029 {
4030 // and the new Bss is an Ibss OR we are roaming from Infra to Infra
4031 // across SSIDs (roaming to a new SSID)... //
4032 //Not worry about WDS connection for now
4033 if ( pBssDesc && ( ( csrIsIbssBssDesc( pBssDesc ) ) ||
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304034 !csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIes ) ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 {
4036 // then we need to disassociate from the Infrastructure network...
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304037 status = csrRoamIssueDisassociate( pMac, sessionId,
4038 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304040 else
4041 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 // In an Infrastucture and going to an Infrastructure network with the same SSID. This
4043 // calls for a Reassociation sequence. So issue the CFG sets for this new AP.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304044 if ( pBssDesc )
Jeff Johnson295189b2012-06-20 16:38:30 -07004045 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304046 // Set parameters for this Bss.
4047 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4048 pBssDesc, pBssConfig,
4049 pIes, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304053 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 {
4055 // Neiher in IBSS nor in Infra. We can go ahead and set the CFG for tne new network...
4056 // Nothing to stop.
4057 if ( pBssDesc || CSR_IS_WDS_AP( pProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004058 || CSR_IS_INFRA_AP(pProfile)
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304059 )
4060 {
4061 tANI_BOOLEAN is11rRoamingFlag = eANI_BOOLEAN_FALSE;
4062 is11rRoamingFlag = csrRoamIs11rAssoc(pMac);
4063 // Set parameters for this Bss.
4064 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4065 pBssDesc, pBssConfig,
4066 pIes, is11rRoamingFlag);
4067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004068 }
4069 }
4070 }//Success getting BSS config info
Kiet Lam64c1b492013-07-12 13:56:44 +05304071 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 }//Allocate memory
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 return (status);
4074}
4075
Jeff Johnson295189b2012-06-20 16:38:30 -07004076eCsrJoinState csrRoamJoin( tpAniSirGlobal pMac, tANI_U32 sessionId,
4077 tCsrScanResultInfo *pScanResult, tCsrRoamProfile *pProfile )
4078{
4079 eCsrJoinState eRoamState = eCsrContinueRoaming;
4080 eHalStatus status;
4081 tSirBssDescription *pBssDesc = &pScanResult->BssDescriptor;
4082 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)( pScanResult->pvIes ); //This may be NULL
4083 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004084
4085 if(!pSession)
4086 {
4087 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4088 return (eCsrStopRoaming);
4089 }
4090
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 if( CSR_IS_WDS_STA( pProfile ) )
4092 {
4093 status = csrRoamStartWds( pMac, sessionId, pProfile, pBssDesc );
4094 if( !HAL_STATUS_SUCCESS( status ) )
4095 {
4096 eRoamState = eCsrStopRoaming;
4097 }
4098 }
4099 else
4100 {
4101 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
4102 {
4103 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
4104 return (eCsrStopRoaming);
4105 }
4106 if ( csrIsInfraBssDesc( pBssDesc ) )
4107 {
4108 // If we are connected in infrastructure mode and the Join Bss description is for the same BssID, then we are
4109 // attempting to join the AP we are already connected with. In that case, see if the Bss or Sta capabilities
4110 // have changed and handle the changes (without disturbing the current association).
4111
4112 if ( csrIsConnStateConnectedInfra(pMac, sessionId) &&
4113 csrIsBssIdEqual( pMac, pBssDesc, pSession->pConnectBssDesc ) &&
4114 csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc, pIesLocal )
4115 )
4116 {
4117 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
4118 // with Authenticating first. To force this, stop the current association (Disassociate) and
4119 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
4120 // a new Association.
4121 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4122 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07004123 smsLog(pMac, LOGW, FL(" detect same profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 if(csrRoamIsSameProfileKeys(pMac, &pSession->connectedProfile, pProfile))
4125 {
4126 eRoamState = eCsrReassocToSelfNoCapChange;
4127 }
4128 else
4129 {
4130 tBssConfigParam bssConfig;
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 //The key changes
Kiet Lam64c1b492013-07-12 13:56:44 +05304132 vos_mem_set(&bssConfig, sizeof(bssConfig), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004133 status = csrRoamPrepareBssConfig(pMac, pProfile, pBssDesc, &bssConfig, pIesLocal);
4134 if(HAL_STATUS_SUCCESS(status))
4135 {
4136 pSession->bssParams.uCfgDot11Mode = bssConfig.uCfgDot11Mode;
Jeff Johnsone7245742012-09-05 17:12:55 -07004137 pSession->bssParams.cbMode = bssConfig.cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 //Reapply the config including Keys so reassoc is happening.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304139 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
4140 pBssDesc, &bssConfig,
4141 pIesLocal, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004142 if(!HAL_STATUS_SUCCESS(status))
4143 {
4144 eRoamState = eCsrStopRoaming;
4145 }
4146 }
4147 else
4148 {
4149 eRoamState = eCsrStopRoaming;
4150 }
4151 }//same profile
4152 }
4153 else
4154 {
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304155 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -07004156 eCSR_ROAM_SUBSTATE_DISASSOC_REQ, FALSE )))
4157 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05304158 smsLog(pMac, LOGE, FL(" fail to issue disassociate with Session ID %d"),
4159 sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004160 eRoamState = eCsrStopRoaming;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304161 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004162 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304163 }
4164 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 {
4166 // note: we used to pre-auth here with open authentication networks but that was not working so well.
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304167 // we had a lot of join timeouts when testing at Samsung. removing this step helped associations
Jeff Johnson295189b2012-06-20 16:38:30 -07004168 // work much better.
4169 //
4170 //
4171 // stop the existing network before attempting to join the new network...
4172 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4173 {
4174 eRoamState = eCsrStopRoaming;
4175 }
4176 }
4177 }//Infra
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05304178 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004179 {
4180 if(!HAL_STATUS_SUCCESS(csrRoamStopNetwork(pMac, sessionId, pProfile, pBssDesc, pIesLocal)))
4181 {
4182 eRoamState = eCsrStopRoaming;
4183 }
4184 }
4185 if( pIesLocal && !pScanResult->pvIes )
4186 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304187 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004188 }
4189 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004190 return( eRoamState );
4191}
4192
Jeff Johnson295189b2012-06-20 16:38:30 -07004193eHalStatus csrRoamShouldRoam(tpAniSirGlobal pMac, tANI_U32 sessionId,
4194 tSirBssDescription *pBssDesc, tANI_U32 roamId)
4195{
4196 eHalStatus status = eHAL_STATUS_SUCCESS;
4197 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +05304198 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 roamInfo.pBssDesc = pBssDesc;
4200 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, roamId, eCSR_ROAM_SHOULD_ROAM, eCSR_ROAM_RESULT_NONE);
4201 return (status);
4202}
Jeff Johnson295189b2012-06-20 16:38:30 -07004203//In case no matching BSS is found, use whatever default we can find
4204static void csrRoamAssignDefaultParam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4205{
4206 //Need to get all negotiated types in place first
4207 //auth type
Jeff Johnsonfeddb2d2012-12-10 14:41:22 -08004208 switch( pCommand->u.roamCmd.roamProfile.AuthType.authType[0] ) //Take the preferred Auth type.
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 {
4210 default:
4211 case eCSR_AUTH_TYPE_WPA:
4212 case eCSR_AUTH_TYPE_WPA_PSK:
4213 case eCSR_AUTH_TYPE_WPA_NONE:
4214 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4215 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4216 break;
4217
4218 case eCSR_AUTH_TYPE_SHARED_KEY:
4219 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_SHARED_KEY;
4220 break;
4221
4222 case eCSR_AUTH_TYPE_AUTOSWITCH:
4223 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = eCSR_AUTH_TYPE_AUTOSWITCH;
4224 break;
4225 }
4226 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4227 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4228 //In this case, the multicast encryption needs to follow the uncast ones.
4229 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4230 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0];
4231}
4232
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004233
4234static void csrSetAbortRoamingCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4235{
4236 switch(pCommand->u.roamCmd.roamReason)
4237 {
4238 case eCsrLostLink1:
4239 pCommand->u.roamCmd.roamReason = eCsrLostLink1Abort;
4240 break;
4241 case eCsrLostLink2:
4242 pCommand->u.roamCmd.roamReason = eCsrLostLink2Abort;
4243 break;
4244 case eCsrLostLink3:
4245 pCommand->u.roamCmd.roamReason = eCsrLostLink3Abort;
4246 break;
4247 default:
4248 smsLog(pMac, LOGE, FL(" aborting roaming reason %d not recognized"),
4249 pCommand->u.roamCmd.roamReason);
4250 break;
4251 }
4252}
4253
Jeff Johnson295189b2012-06-20 16:38:30 -07004254static eCsrJoinState csrRoamJoinNextBss( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fUseSameBss )
4255{
4256 eHalStatus status;
4257 tCsrScanResult *pScanResult = NULL;
4258 eCsrJoinState eRoamState = eCsrStopRoaming;
4259 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
4260 tANI_BOOLEAN fDone = eANI_BOOLEAN_FALSE;
4261 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
4262#ifndef WLAN_MDM_CODE_REDUCTION_OPT
4263 v_U8_t acm_mask = 0;
4264#endif
4265 tANI_U32 sessionId = pCommand->sessionId;
4266 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4267 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
4268 tANI_U8 concurrentChannel = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004269
4270 if(!pSession)
4271 {
4272 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4273 return (eCsrStopRoaming);
4274 }
4275
Jeff Johnson295189b2012-06-20 16:38:30 -07004276 do
4277 {
4278 // Check for Cardbus eject condition, before trying to Roam to any BSS
4279 //***if( !balIsCardPresent(pAdapter) ) break;
4280
Kiet Lam64c1b492013-07-12 13:56:44 +05304281 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +05304282 vos_mem_copy (&roamInfo.bssid, &pSession->joinFailStatusCode.bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07004283 if(NULL != pBSSList)
4284 {
4285 // When handling AP's capability change, continue to associate to
4286 // same BSS and make sure pRoamBssEntry is not Null.
4287 if((eANI_BOOLEAN_FALSE == fUseSameBss) || (pCommand->u.roamCmd.pRoamBssEntry == NULL))
4288 {
4289 if(pCommand->u.roamCmd.pRoamBssEntry == NULL)
4290 {
4291 //Try the first BSS
4292 pCommand->u.roamCmd.pLastRoamBss = NULL;
4293 pCommand->u.roamCmd.pRoamBssEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
4294 }
4295 else
4296 {
4297 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4298 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4299 {
4300 //Done with all the BSSs
4301 //In this case, will tell HDD the completion
4302 break;
4303 }
4304 else
4305 {
4306 //We need to indicate to HDD that we are done with this one.
Kiet Lam64c1b492013-07-12 13:56:44 +05304307 //vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss; //this shall not be NULL
4309 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
4310 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
4311 pRoamInfo = &roamInfo;
4312 }
4313 }
4314 while(pCommand->u.roamCmd.pRoamBssEntry)
4315 {
4316 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Jeff Johnson295189b2012-06-20 16:38:30 -07004317 /*If concurrency enabled take the concurrent connected channel first. */
4318 /* Valid multichannel concurrent sessions exempted */
Agarwal Ashish5974ed32014-06-16 16:59:54 +05304319 if (vos_concurrent_open_sessions_running() &&
4320 !csrIsValidMcConcurrentSession(pMac, sessionId,
4321 &pScanResult->Result.BssDescriptor))
Jeff Johnson295189b2012-06-20 16:38:30 -07004322 {
4323 concurrentChannel =
4324 csrGetConcurrentOperationChannel(pMac);
4325 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH, "%s: "
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004326 " csr Concurrent Channel = %d", __func__, concurrentChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07004327 if ((concurrentChannel) &&
4328 (concurrentChannel ==
4329 pScanResult->Result.BssDescriptor.channelId))
4330 {
4331 //make this 0 because we do not want the
4332 //below check to pass as we don't want to
4333 //connect on other channel
4334 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
4335 FL("Concurrent channel match =%d"),
4336 concurrentChannel);
4337 concurrentChannel = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 }
4339 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004340
4341 if (!concurrentChannel)
4342 {
4343
4344 if(HAL_STATUS_SUCCESS(csrRoamShouldRoam(pMac,
4345 sessionId, &pScanResult->Result.BssDescriptor,
4346 pCommand->u.roamCmd.roamId)))
4347 {
4348 //Ok to roam this
4349 break;
4350 }
4351 }
Jeff Johnsone7245742012-09-05 17:12:55 -07004352 else
4353 {
4354 eRoamState = eCsrStopRoamingDueToConcurrency;
4355 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 pCommand->u.roamCmd.pRoamBssEntry = csrLLNext(&pBSSList->List, pCommand->u.roamCmd.pRoamBssEntry, LL_ACCESS_LOCK);
4357 if(NULL == pCommand->u.roamCmd.pRoamBssEntry)
4358 {
4359 //Done with all the BSSs
4360 fDone = eANI_BOOLEAN_TRUE;
4361 break;
4362 }
4363 }
4364 if(fDone)
4365 {
4366 break;
4367 }
4368 }
4369 }
4370 //We have something to roam, tell HDD when it is infra.
4371 //For IBSS, the indication goes back to HDD via eCSR_ROAM_IBSS_IND
4372 //For WDS, the indication is eCSR_ROAM_WDS_IND
4373 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
4374 {
4375 if(pRoamInfo)
4376 {
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004377 if(pSession->bRefAssocStartCnt)
4378 {
4379 pSession->bRefAssocStartCnt--;
4380 //Complete the last association attemp because a new one is about to be tried
4381 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4382 eCSR_ROAM_ASSOCIATION_COMPLETION,
Jeff Johnson295189b2012-06-20 16:38:30 -07004383 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07004384 }
4385 }
4386 /* If the roaming has stopped, not to continue the roaming command*/
4387 if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
4388 {
4389 //No need to complete roaming here as it already completes
4390 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed"),
4391 pCommand->u.roamCmd.roamReason);
4392 eRoamState = eCsrStopRoaming;
4393 csrSetAbortRoamingCommand(pMac, pCommand);
4394 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004395 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304396 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004397 if(pScanResult)
4398 {
4399 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Jeff Johnson295189b2012-06-20 16:38:30 -07004400 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, &pScanResult->Result.BssDescriptor, &pIesLocal))) )
4401 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004402 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 fDone = eANI_BOOLEAN_TRUE;
4404 eRoamState = eCsrStopRoaming;
4405 break;
4406 }
4407 roamInfo.pBssDesc = &pScanResult->Result.BssDescriptor;
4408 pCommand->u.roamCmd.pLastRoamBss = roamInfo.pBssDesc;
4409 //No need to put uapsd_mask in if the BSS doesn't support uAPSD
4410 if( pCommand->u.roamCmd.roamProfile.uapsd_mask &&
4411 CSR_IS_QOS_BSS(pIesLocal) &&
4412 CSR_IS_UAPSD_BSS(pIesLocal) )
4413 {
4414#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Jeff Johnson295189b2012-06-20 16:38:30 -07004415 acm_mask = sme_QosGetACMMask(pMac, &pScanResult->Result.BssDescriptor,
4416 pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004417#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Jeff Johnson295189b2012-06-20 16:38:30 -07004418 }
4419 else
4420 {
4421 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4422 }
4423 if( pIesLocal && !pScanResult->Result.pvIes)
4424 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304425 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07004426 }
4427 }
4428 else
4429 {
4430 pCommand->u.roamCmd.roamProfile.uapsd_mask = 0;
4431 }
4432 roamInfo.pProfile = pProfile;
4433 pSession->bRefAssocStartCnt++;
4434 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4435 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004437 if ( NULL == pCommand->u.roamCmd.pRoamBssEntry )
4438 {
4439 // If this is a start IBSS profile, then we need to start the IBSS.
4440 if ( CSR_IS_START_IBSS(pProfile) )
4441 {
4442 tANI_BOOLEAN fSameIbss = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 // Attempt to start this IBSS...
4444 csrRoamAssignDefaultParam( pMac, pCommand );
4445 status = csrRoamStartIbss( pMac, sessionId, pProfile, &fSameIbss );
4446 if(HAL_STATUS_SUCCESS(status))
4447 {
4448 if ( fSameIbss )
4449 {
4450 eRoamState = eCsrStartIbssSameIbss;
4451 }
4452 else
4453 {
4454 eRoamState = eCsrContinueRoaming;
4455 }
4456 }
4457 else
4458 {
4459 //it somehow fail need to stop
4460 eRoamState = eCsrStopRoaming;
4461 }
4462 break;
4463 }
4464 else if ( (CSR_IS_WDS_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004465 || (CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 )
4467 {
4468 // Attempt to start this WDS...
4469 csrRoamAssignDefaultParam( pMac, pCommand );
4470 /* For AP WDS, we dont have any BSSDescription */
4471 status = csrRoamStartWds( pMac, sessionId, pProfile, NULL );
4472 if(HAL_STATUS_SUCCESS(status))
4473 {
4474 eRoamState = eCsrContinueRoaming;
4475 }
4476 else
4477 {
4478 //it somehow fail need to stop
4479 eRoamState = eCsrStopRoaming;
4480 }
4481 }
4482 else
4483 {
4484 //Nothing we can do
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004485 smsLog(pMac, LOGW, FL("cannot continue without BSS list"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004486 eRoamState = eCsrStopRoaming;
4487 break;
4488 }
4489 }
4490 else //We have BSS
4491 {
4492 //Need to assign these value because they are used in csrIsSameProfile
4493 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
Leela Venkata Kiran Kumar Reddy Chirala909b8812014-05-16 22:09:05 -07004494 /* The OSEN IE doesn't provide the cipher suite.
4495 * Therefore set to constant value of AES */
4496 if(pCommand->u.roamCmd.roamProfile.bOSENAssociation)
4497 {
4498 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4499 eCSR_ENCRYPT_TYPE_AES;
4500 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4501 eCSR_ENCRYPT_TYPE_AES;
4502 }
4503 else
4504 {
4505 pCommand->u.roamCmd.roamProfile.negotiatedUCEncryptionType =
4506 pScanResult->ucEncryptionType; //Negotiated while building scan result.
4507 pCommand->u.roamCmd.roamProfile.negotiatedMCEncryptionType =
4508 pScanResult->mcEncryptionType;
4509 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 pCommand->u.roamCmd.roamProfile.negotiatedAuthType = pScanResult->authType;
4511 if ( CSR_IS_START_IBSS(&pCommand->u.roamCmd.roamProfile) )
4512 {
4513 if(csrIsSameProfile(pMac, &pSession->connectedProfile, pProfile))
4514 {
4515 eRoamState = eCsrStartIbssSameIbss;
4516 break;
4517 }
4518 }
4519 if( pCommand->u.roamCmd.fReassocToSelfNoCapChange )
4520 {
4521 //trying to connect to the one already connected
4522 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_FALSE;
4523 eRoamState = eCsrReassocToSelfNoCapChange;
4524 break;
4525 }
4526 // Attempt to Join this Bss...
4527 eRoamState = csrRoamJoin( pMac, sessionId, &pScanResult->Result, pProfile );
4528 break;
4529 }
4530
4531 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07004532 if( (eCsrStopRoaming == eRoamState) && (CSR_IS_INFRASTRUCTURE( pProfile )) )
4533 {
4534 //Need to indicate association_completion if association_start has been done
4535 if(pSession->bRefAssocStartCnt > 0)
4536 {
4537 pSession->bRefAssocStartCnt--;
4538 //Complete the last association attemp because a new one is about to be tried
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07004539 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 csrRoamCallCallback(pMac, sessionId, pRoamInfo, pCommand->u.roamCmd.roamId,
4541 eCSR_ROAM_ASSOCIATION_COMPLETION,
4542 eCSR_ROAM_RESULT_NOT_ASSOCIATED);
4543 }
4544 }
4545
4546 return( eRoamState );
4547}
4548
Jeff Johnson295189b2012-06-20 16:38:30 -07004549static eHalStatus csrRoam( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4550{
4551 eHalStatus status = eHAL_STATUS_SUCCESS;
4552 eCsrJoinState RoamState;
4553 tANI_U32 sessionId = pCommand->sessionId;
4554
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 //***if( hddIsRadioStateOn( pAdapter ) )
4556 {
4557 // Attept to join a Bss...
4558 RoamState = csrRoamJoinNextBss( pMac, pCommand, eANI_BOOLEAN_FALSE );
Jeff Johnsone7245742012-09-05 17:12:55 -07004559
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 // if nothing to join..
Jeff Johnsone7245742012-09-05 17:12:55 -07004561 if (( eCsrStopRoaming == RoamState ) || ( eCsrStopRoamingDueToConcurrency == RoamState))
Jeff Johnson295189b2012-06-20 16:38:30 -07004562 {
4563 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 // and if connected in Infrastructure mode...
4565 if ( csrIsConnStateInfra(pMac, sessionId) )
4566 {
4567 //... then we need to issue a disassociation
4568 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISASSOC_NOTHING_TO_JOIN, FALSE );
4569 if(!HAL_STATUS_SUCCESS(status))
4570 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004571 smsLog(pMac, LOGW, FL(" failed to issue disassociate, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004572 //roam command is completed by caller in the failed case
4573 fComplete = eANI_BOOLEAN_TRUE;
4574 }
4575 }
4576 else if( csrIsConnStateIbss(pMac, sessionId) )
4577 {
4578 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4579 if(!HAL_STATUS_SUCCESS(status))
4580 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004581 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004582 //roam command is completed by caller in the failed case
4583 fComplete = eANI_BOOLEAN_TRUE;
4584 }
4585 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004586 else if (csrIsConnStateConnectedInfraAp(pMac, sessionId))
4587 {
4588 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4589 if(!HAL_STATUS_SUCCESS(status))
4590 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004591 smsLog(pMac, LOGW, FL(" failed to issue stop bss, status = %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07004592 //roam command is completed by caller in the failed case
4593 fComplete = eANI_BOOLEAN_TRUE;
4594 }
4595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004596 else
4597 {
4598 fComplete = eANI_BOOLEAN_TRUE;
4599 }
4600 if(fComplete)
4601 {
4602 // ... otherwise, we can complete the Roam command here.
Jeff Johnsone7245742012-09-05 17:12:55 -07004603 if(eCsrStopRoamingDueToConcurrency == RoamState)
4604 {
4605 csrRoamComplete( pMac, eCsrJoinFailureDueToConcurrency, NULL );
4606 }
4607 else
4608 {
4609 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
4610 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 }
4612 }
4613 else if ( eCsrReassocToSelfNoCapChange == RoamState )
4614 {
4615 csrRoamComplete( pMac, eCsrSilentlyStopRoamingSaveState, NULL );
4616 }
4617 else if ( eCsrStartIbssSameIbss == RoamState )
4618 {
4619 csrRoamComplete( pMac, eCsrSilentlyStopRoaming, NULL );
4620 }
4621 }//hddIsRadioStateOn
4622
4623 return status;
4624}
Jeff Johnson295189b2012-06-20 16:38:30 -07004625eHalStatus csrProcessFTReassocRoamCommand ( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4626{
4627 tANI_U32 sessionId;
4628 tCsrRoamSession *pSession;
4629 tCsrScanResult *pScanResult = NULL;
4630 tSirBssDescription *pBssDesc = NULL;
4631 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07004632 sessionId = pCommand->sessionId;
4633 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004634
4635 if(!pSession)
4636 {
4637 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4638 return eHAL_STATUS_FAILURE;
4639 }
4640
Jeff Johnson295189b2012-06-20 16:38:30 -07004641 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
4642 {
4643 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004644 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4646 return eHAL_STATUS_FAILURE;
4647 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004648 if (pCommand->u.roamCmd.pRoamBssEntry)
4649 {
4650 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
4651 pBssDesc = &pScanResult->Result.BssDescriptor;
4652 }
4653 else
4654 {
4655 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004656 smsLog(pMac, LOG1, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004657 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
4658 return eHAL_STATUS_FAILURE;
4659 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004660 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
4661 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
4662 return status;
4663}
4664
Jeff Johnson295189b2012-06-20 16:38:30 -07004665eHalStatus csrRoamProcessCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
4666{
4667 eHalStatus status = eHAL_STATUS_SUCCESS;
4668 tCsrRoamInfo roamInfo;
4669 tANI_U32 sessionId = pCommand->sessionId;
4670 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004671
4672 if(!pSession)
4673 {
4674 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4675 return eHAL_STATUS_FAILURE;
4676 }
Abhishek Singhf4669da2014-05-26 15:07:49 +05304677
Jeff Johnson295189b2012-06-20 16:38:30 -07004678 switch ( pCommand->u.roamCmd.roamReason )
4679 {
4680 case eCsrForcedDisassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07004681 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004682 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004684 case eCsrSmeIssuedDisassocForHandoff:
4685 //Not to free pMac->roam.pCurRoamProfile (via csrFreeRoamProfile) because it is needed after disconnect
4686#if 0 // TODO : Confirm this change
4687 status = csrRoamProcessDisassociate( pMac, pCommand, FALSE );
4688#else
4689 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, FALSE );
4690#endif
4691
4692 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004693 case eCsrForcedDisassocMICFailure:
Jeff Johnson295189b2012-06-20 16:38:30 -07004694 status = csrRoamProcessDisassocDeauth( pMac, pCommand, TRUE, TRUE );
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 eCsrForcedDeauth:
Jeff Johnson295189b2012-06-20 16:38:30 -07004698 status = csrRoamProcessDisassocDeauth( pMac, pCommand, FALSE, FALSE );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07004699 csrFreeRoamProfile(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07004700 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004701 case eCsrHddIssuedReassocToSameAP:
4702 case eCsrSmeIssuedReassocToSameAP:
4703 {
4704 tDot11fBeaconIEs *pIes = NULL;
4705
Jeff Johnson295189b2012-06-20 16:38:30 -07004706 if( pSession->pConnectBssDesc )
4707 {
4708 status = csrGetParsedBssDescriptionIEs(pMac, pSession->pConnectBssDesc, &pIes);
4709 if(!HAL_STATUS_SUCCESS(status) )
4710 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004711 smsLog(pMac, LOGE, FL(" fail to parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 }
4713 else
4714 {
4715 roamInfo.reasonCode = eCsrRoamReasonStaCapabilityChanged;
4716 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
4717 pSession->roamingReason = eCsrReassocRoaming;
Jeff Johnson295189b2012-06-20 16:38:30 -07004718 roamInfo.pBssDesc = pSession->pConnectBssDesc;
4719 roamInfo.pProfile = &pCommand->u.roamCmd.roamProfile;
4720 pSession->bRefAssocStartCnt++;
4721 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
4722 eCSR_ROAM_ASSOCIATION_START, eCSR_ROAM_RESULT_NONE );
4723
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004724 smsLog(pMac, LOG1, FL(" calling csrRoamIssueReassociate"));
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004725 status = csrRoamIssueReassociate( pMac, sessionId, pSession->pConnectBssDesc, pIes,
4726 &pCommand->u.roamCmd.roamProfile );
4727 if(!HAL_STATUS_SUCCESS(status))
4728 {
4729 smsLog(pMac, LOGE, FL("csrRoamIssueReassociate failed with status %d"), status);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08004730 csrReleaseCommandRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004731 }
4732
Kiet Lam64c1b492013-07-12 13:56:44 +05304733 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07004734 pIes = NULL;
4735 }
4736 }
Padma, Santhosh Kumar3d8d5762014-07-22 14:52:23 +05304737 else
4738 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004739 break;
4740 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004741 case eCsrCapsChange:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004742 smsLog(pMac, LOGE, FL("received eCsrCapsChange "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004743 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4744 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE);
4745 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004746 case eCsrSmeIssuedFTReassoc:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004747 smsLog(pMac, LOG1, FL("received FT Reassoc Req "));
Jeff Johnson295189b2012-06-20 16:38:30 -07004748 status = csrProcessFTReassocRoamCommand(pMac, pCommand);
4749 break;
Jeff Johnsone7245742012-09-05 17:12:55 -07004750
Jeff Johnson295189b2012-06-20 16:38:30 -07004751 case eCsrStopBss:
4752 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4753 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
4754 break;
4755
4756 case eCsrForcedDisassocSta:
4757 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4758 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DISASSOC_REQ, sessionId);
4759 status = csrSendMBDisassocReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4760 pCommand->u.roamCmd.reason);
4761 break;
4762
4763 case eCsrForcedDeauthSta:
4764 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
4765 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_DEAUTH_REQ, sessionId);
4766 status = csrSendMBDeauthReqMsg( pMac, sessionId, pCommand->u.roamCmd.peerMac,
4767 pCommand->u.roamCmd.reason);
4768 break;
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004769
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004770 case eCsrPerformPreauth:
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08004771 smsLog(pMac, LOG1, FL("Attempting FT PreAuth Req"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004772 status = csrRoamIssueFTPreauthReq(pMac, sessionId,
4773 pCommand->u.roamCmd.pLastRoamBss);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004774 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004775
4776 default:
4777 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
4778
4779 if( pCommand->u.roamCmd.fUpdateCurRoamProfile )
4780 {
4781 //Remember the roaming profile
4782 csrFreeRoamProfile(pMac, sessionId);
Kiet Lam64c1b492013-07-12 13:56:44 +05304783 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
4784 if ( NULL != pSession->pCurRoamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07004785 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304786 vos_mem_set(pSession->pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004787 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, &pCommand->u.roamCmd.roamProfile);
4788 }
4789 }
4790
4791 //At this point, original uapsd_mask is saved in pCurRoamProfile
4792 //uapsd_mask in the pCommand may change from this point on.
4793
4794 // Attempt to roam with the new scan results (if we need to..)
4795 status = csrRoam( pMac, pCommand );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004796 if(!HAL_STATUS_SUCCESS(status))
4797 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004798 smsLog(pMac, LOGW, FL("csrRoam() failed with status = 0x%08X"), status);
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004799 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004800 break;
4801 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004802 return (status);
4803}
4804
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004805void csrReinitPreauthCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4806{
4807 pCommand->u.roamCmd.pLastRoamBss = NULL;
4808 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4809 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304810 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07004811}
4812
Jeff Johnson295189b2012-06-20 16:38:30 -07004813void csrReinitRoamCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4814{
4815 if(pCommand->u.roamCmd.fReleaseBssList)
4816 {
4817 csrScanResultPurge(pMac, pCommand->u.roamCmd.hBSSList);
4818 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
4819 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
4820 }
4821 if(pCommand->u.roamCmd.fReleaseProfile)
4822 {
4823 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
4824 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
4825 }
4826 pCommand->u.roamCmd.pRoamBssEntry = NULL;
4827 //Because u.roamCmd is union and share with scanCmd and StatusChange
Kiet Lam64c1b492013-07-12 13:56:44 +05304828 vos_mem_set(&pCommand->u.roamCmd, sizeof(tRoamCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004829}
4830
Jeff Johnson295189b2012-06-20 16:38:30 -07004831void csrReinitWmStatusChangeCmd(tpAniSirGlobal pMac, tSmeCmd *pCommand)
4832{
Kiet Lam64c1b492013-07-12 13:56:44 +05304833 vos_mem_set(&pCommand->u.wmStatusChangeCmd, sizeof(tWmStatusChangeCmd), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004834}
Jeff Johnson295189b2012-06-20 16:38:30 -07004835void csrRoamComplete( tpAniSirGlobal pMac, eCsrRoamCompleteResult Result, void *Context )
4836{
4837 tListElem *pEntry;
4838 tSmeCmd *pCommand;
4839 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004840 smsLog( pMac, LOG2, "Roam Completion ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004841 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
4842 if ( pEntry )
4843 {
4844 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 // If the head of the queue is Active and it is a ROAM command, remove
4846 // and put this on the Free queue.
4847 if ( eSmeCommandRoam == pCommand->command )
4848 {
4849 //we need to process the result first before removing it from active list because state changes
4850 //still happening insides roamQProcessRoamResults so no other roam command should be issued
4851 fReleaseCommand = csrRoamProcessResults( pMac, pCommand, Result, Context );
4852 if( fReleaseCommand )
4853 {
4854 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
4855 {
4856 csrReleaseCommandRoam( pMac, pCommand );
4857 }
4858 else
4859 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004860 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004861 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004862 }
4863 }
4864 else
4865 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004866 smsLog( pMac, LOGE, " **********csrRoamComplete fail to release command reason %d",
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08004867 pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07004868 }
4869 }
4870 else
4871 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004872 smsLog( pMac, LOGW, "CSR: Roam Completion called but ROAM command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004873 }
4874 }
4875 else
4876 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004877 smsLog( pMac, LOGW, "CSR: Roam Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -07004878 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004879 if( fReleaseCommand )
4880 {
4881 smeProcessPendingQueue( pMac );
4882 }
4883}
4884
Jeff Johnson295189b2012-06-20 16:38:30 -07004885void csrResetPMKIDCandidateList( tpAniSirGlobal pMac, tANI_U32 sessionId )
4886{
4887 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07004888 if(!pSession)
4889 {
4890 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4891 return;
4892 }
Kiet Lam64c1b492013-07-12 13:56:44 +05304893 vos_mem_set(&(pSession->PmkidCandidateInfo[0]),
4894 sizeof(tPmkidCandidateInfo) * CSR_MAX_PMKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004895 pSession->NumPmkidCandidate = 0;
4896}
Jeff Johnson295189b2012-06-20 16:38:30 -07004897#ifdef FEATURE_WLAN_WAPI
4898void csrResetBKIDCandidateList( 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->BkidCandidateInfo[0]),
4907 sizeof(tBkidCandidateInfo) * CSR_MAX_BKID_ALLOWED, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004908 pSession->NumBkidCandidate = 0;
4909}
4910#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004911extern tANI_U8 csrWpaOui[][ CSR_WPA_OUI_SIZE ];
4912
Jeff Johnson295189b2012-06-20 16:38:30 -07004913static eHalStatus csrRoamSaveSecurityRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrAuthType authType,
4914 tSirBssDescription *pSirBssDesc,
4915 tDot11fBeaconIEs *pIes)
4916{
4917 eHalStatus status = eHAL_STATUS_SUCCESS;
4918 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
4919 tDot11fBeaconIEs *pIesLocal = pIes;
Jeff Johnson32d95a32012-09-10 13:15:23 -07004920
4921 if(!pSession)
4922 {
4923 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
4924 return eHAL_STATUS_FAILURE;
4925 }
4926
Jeff Johnson295189b2012-06-20 16:38:30 -07004927 if((eCSR_AUTH_TYPE_WPA == authType) ||
4928 (eCSR_AUTH_TYPE_WPA_PSK == authType) ||
4929 (eCSR_AUTH_TYPE_RSN == authType) ||
4930 (eCSR_AUTH_TYPE_RSN_PSK == authType)
4931#if defined WLAN_FEATURE_VOWIFI_11R
4932 ||
4933 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4934 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType)
4935#endif /* FEATURE_WLAN_WAPI */
4936#ifdef FEATURE_WLAN_WAPI
4937 ||
4938 (eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
4939 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType)
4940#endif /* FEATURE_WLAN_WAPI */
Chet Lanctot186b5732013-03-18 10:26:30 -07004941#ifdef WLAN_FEATURE_11W
4942 ||
Abhishek Singhae408032014-09-25 17:22:04 +05304943 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
4944 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType)
Chet Lanctot186b5732013-03-18 10:26:30 -07004945#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07004946 )
4947 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004948 if( !pIesLocal && (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesLocal))) )
4949 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08004950 smsLog(pMac, LOGE, FL(" cannot parse IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004951 }
4952 if( pIesLocal )
4953 {
4954 tANI_U32 nIeLen;
4955 tANI_U8 *pIeBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07004956 if((eCSR_AUTH_TYPE_RSN == authType) ||
4957#if defined WLAN_FEATURE_VOWIFI_11R
4958 (eCSR_AUTH_TYPE_FT_RSN == authType) ||
4959 (eCSR_AUTH_TYPE_FT_RSN_PSK == authType) ||
4960#endif /* WLAN_FEATURE_VOWIFI_11R */
Chet Lanctot186b5732013-03-18 10:26:30 -07004961#if defined WLAN_FEATURE_11W
4962 (eCSR_AUTH_TYPE_RSN_PSK_SHA256 == authType) ||
Abhishek Singhae408032014-09-25 17:22:04 +05304963 (eCSR_AUTH_TYPE_RSN_8021X_SHA256 == authType) ||
Chet Lanctot186b5732013-03-18 10:26:30 -07004964#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004965 (eCSR_AUTH_TYPE_RSN_PSK == authType))
4966 {
4967 if(pIesLocal->RSN.present)
4968 {
4969 //Calculate the actual length
4970 nIeLen = 8 //version + gp_cipher_suite + pwise_cipher_suite_count
4971 + pIesLocal->RSN.pwise_cipher_suite_count * 4 //pwise_cipher_suites
4972 + 2 //akm_suite_count
4973 + pIesLocal->RSN.akm_suite_count * 4 //akm_suites
4974 + 2; //reserved
4975 if( pIesLocal->RSN.pmkid_count )
4976 {
4977 nIeLen += 2 + pIesLocal->RSN.pmkid_count * 4; //pmkid
4978 }
4979 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05304980 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
4981 if (NULL == pSession->pWpaRsnRspIE)
4982 status = eHAL_STATUS_FAILURE;
4983 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004984 {
Kiet Lam64c1b492013-07-12 13:56:44 +05304985 vos_mem_set(pSession->pWpaRsnRspIE, nIeLen + 2, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07004986 pSession->pWpaRsnRspIE[0] = DOT11F_EID_RSN;
4987 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
4988 //copy upto akm_suites
4989 pIeBuf = pSession->pWpaRsnRspIE + 2;
Kiet Lam64c1b492013-07-12 13:56:44 +05304990 vos_mem_copy(pIeBuf, &pIesLocal->RSN.version,
4991 sizeof(pIesLocal->RSN.version));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004992 pIeBuf += sizeof(pIesLocal->RSN.version);
Kiet Lam64c1b492013-07-12 13:56:44 +05304993 vos_mem_copy(pIeBuf, &pIesLocal->RSN.gp_cipher_suite,
4994 sizeof(pIesLocal->RSN.gp_cipher_suite));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004995 pIeBuf += sizeof(pIesLocal->RSN.gp_cipher_suite);
Kiet Lam64c1b492013-07-12 13:56:44 +05304996 vos_mem_copy(pIeBuf, &pIesLocal->RSN.pwise_cipher_suite_count,
4997 sizeof(pIesLocal->RSN.pwise_cipher_suite_count));
Gopichand Nakkala114718f2013-03-25 19:19:46 -07004998 pIeBuf += sizeof(pIesLocal->RSN.pwise_cipher_suite_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004999 if( pIesLocal->RSN.pwise_cipher_suite_count )
5000 {
5001 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305002 vos_mem_copy(pIeBuf,
5003 pIesLocal->RSN.pwise_cipher_suites,
5004 pIesLocal->RSN.pwise_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005005 pIeBuf += pIesLocal->RSN.pwise_cipher_suite_count * 4;
5006 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305007 vos_mem_copy(pIeBuf, &pIesLocal->RSN.akm_suite_count, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005008 pIeBuf += 2;
5009 if( pIesLocal->RSN.akm_suite_count )
5010 {
5011 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305012 vos_mem_copy(pIeBuf,
5013 pIesLocal->RSN.akm_suites,
5014 pIesLocal->RSN.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005015 pIeBuf += pIesLocal->RSN.akm_suite_count * 4;
5016 }
5017 //copy the rest
Kiet Lam64c1b492013-07-12 13:56:44 +05305018 vos_mem_copy(pIeBuf,
5019 pIesLocal->RSN.akm_suites + pIesLocal->RSN.akm_suite_count * 4,
5020 2 + pIesLocal->RSN.pmkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005021 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5022 }
5023 }
5024 }
5025 else if((eCSR_AUTH_TYPE_WPA == authType) ||
5026 (eCSR_AUTH_TYPE_WPA_PSK == authType))
5027 {
5028 if(pIesLocal->WPA.present)
5029 {
5030 //Calculate the actual length
5031 nIeLen = 12 //OUI + version + multicast_cipher + unicast_cipher_count
5032 + pIesLocal->WPA.unicast_cipher_count * 4 //unicast_ciphers
5033 + 2 //auth_suite_count
5034 + pIesLocal->WPA.auth_suite_count * 4; //auth_suites
5035 // The WPA capabilities follows the Auth Suite (two octects)--
5036 // this field is optional, and we always "send" zero, so just
5037 // remove it. This is consistent with our assumptions in the
5038 // frames compiler; c.f. bug 15234:
5039 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305040
5041 pSession->pWpaRsnRspIE = vos_mem_malloc(nIeLen + 2);
5042 if ( NULL == pSession->pWpaRsnRspIE )
5043 status = eHAL_STATUS_FAILURE;
5044 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005045 {
5046 pSession->pWpaRsnRspIE[0] = DOT11F_EID_WPA;
5047 pSession->pWpaRsnRspIE[1] = (tANI_U8)nIeLen;
5048 pIeBuf = pSession->pWpaRsnRspIE + 2;
5049 //Copy WPA OUI
Kiet Lam64c1b492013-07-12 13:56:44 +05305050 vos_mem_copy(pIeBuf, &csrWpaOui[1], 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005051 pIeBuf += 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305052 vos_mem_copy(pIeBuf, &pIesLocal->WPA.version,
5053 8 + pIesLocal->WPA.unicast_cipher_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005054 pIeBuf += 8 + pIesLocal->WPA.unicast_cipher_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305055 vos_mem_copy(pIeBuf, &pIesLocal->WPA.auth_suite_count,
5056 2 + pIesLocal->WPA.auth_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005057 pIeBuf += pIesLocal->WPA.auth_suite_count * 4;
5058 pSession->nWpaRsnRspIeLength = nIeLen + 2;
5059 }
5060 }
5061 }
5062#ifdef FEATURE_WLAN_WAPI
5063 else if((eCSR_AUTH_TYPE_WAPI_WAI_PSK == authType) ||
5064 (eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE == authType))
5065 {
5066 if(pIesLocal->WAPI.present)
5067 {
5068 //Calculate the actual length
5069 nIeLen = 4 //version + akm_suite_count
5070 + pIesLocal->WAPI.akm_suite_count * 4 // akm_suites
5071 + 2 //pwise_cipher_suite_count
5072 + pIesLocal->WAPI.unicast_cipher_suite_count * 4 //pwise_cipher_suites
5073 + 6; //gp_cipher_suite + preauth + reserved
5074 if( pIesLocal->WAPI.bkid_count )
5075 {
5076 nIeLen += 2 + pIesLocal->WAPI.bkid_count * 4; //bkid
5077 }
5078
5079 //nIeLen doesn't count EID and length fields
Kiet Lam64c1b492013-07-12 13:56:44 +05305080 pSession->pWapiRspIE = vos_mem_malloc(nIeLen + 2);
5081 if ( NULL == pSession->pWapiRspIE )
5082 status = eHAL_STATUS_FAILURE;
5083 else
Jeff Johnson295189b2012-06-20 16:38:30 -07005084 {
5085 pSession->pWapiRspIE[0] = DOT11F_EID_WAPI;
5086 pSession->pWapiRspIE[1] = (tANI_U8)nIeLen;
5087 pIeBuf = pSession->pWapiRspIE + 2;
5088 //copy upto akm_suite_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305089 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.version, 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005090 pIeBuf += 4;
5091 if( pIesLocal->WAPI.akm_suite_count )
5092 {
5093 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305094 vos_mem_copy(pIeBuf, pIesLocal->WAPI.akm_suites,
5095 pIesLocal->WAPI.akm_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005096 pIeBuf += pIesLocal->WAPI.akm_suite_count * 4;
Kiet Lam64c1b492013-07-12 13:56:44 +05305097 }
5098 vos_mem_copy(pIeBuf,
5099 &pIesLocal->WAPI.unicast_cipher_suite_count,
5100 2);
Jeff Johnson295189b2012-06-20 16:38:30 -07005101 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005102 if( pIesLocal->WAPI.unicast_cipher_suite_count )
5103 {
5104 //copy pwise_cipher_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305105 vos_mem_copy( pIeBuf,
5106 pIesLocal->WAPI.unicast_cipher_suites,
5107 pIesLocal->WAPI.unicast_cipher_suite_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005108 pIeBuf += pIesLocal->WAPI.unicast_cipher_suite_count * 4;
5109 }
lukez3c809222013-05-03 10:23:02 -07005110 //gp_cipher_suite
Kiet Lam64c1b492013-07-12 13:56:44 +05305111 vos_mem_copy(pIeBuf,
5112 pIesLocal->WAPI.multicast_cipher_suite,
5113 4);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005114 pIeBuf += 4;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305115 //preauth + reserved
Kiet Lam64c1b492013-07-12 13:56:44 +05305116 vos_mem_copy(pIeBuf,
5117 pIesLocal->WAPI.multicast_cipher_suite + 4,
5118 2);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005119 pIeBuf += 2;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305120 //bkid_count
Kiet Lam64c1b492013-07-12 13:56:44 +05305121 vos_mem_copy(pIeBuf, &pIesLocal->WAPI.bkid_count, 2);
5122
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -07005123 pIeBuf += 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005124 if( pIesLocal->WAPI.bkid_count )
5125 {
5126 //copy akm_suites
Kiet Lam64c1b492013-07-12 13:56:44 +05305127 vos_mem_copy(pIeBuf, pIesLocal->WAPI.bkid,
5128 pIesLocal->WAPI.bkid_count * 4);
Jeff Johnson295189b2012-06-20 16:38:30 -07005129 pIeBuf += pIesLocal->WAPI.bkid_count * 4;
5130 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +05305131 pSession->nWapiRspIeLength = nIeLen + 2;
Jeff Johnson295189b2012-06-20 16:38:30 -07005132 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005133 }
5134 }
5135#endif /* FEATURE_WLAN_WAPI */
5136 if( !pIes )
5137 {
5138 //locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05305139 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07005140 }
5141 }
5142 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005143 return (status);
5144}
5145
Jeff Johnson295189b2012-06-20 16:38:30 -07005146static void csrCheckAndUpdateACWeight( tpAniSirGlobal pMac, tDot11fBeaconIEs *pIEs )
5147{
5148 v_U8_t bACWeights[WLANTL_MAX_AC];
5149 v_U8_t paramBk, paramBe, paramVi, paramVo;
5150 v_BOOL_t fWeightChange = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005151 //Compare two ACs' EDCA parameters, from low to high (BK, BE, VI, VO)
5152 //The "formula" is, if lower AC's AIFSN+CWMin is bigger than a fixed amount
5153 //of the higher AC one, make the higher AC has the same weight as the lower AC.
5154 //This doesn't address the case where the lower AC needs a real higher weight
5155 if( pIEs->WMMParams.present )
5156 {
5157 //no change to the lowest ones
5158 bACWeights[WLANTL_AC_BK] = pMac->roam.ucACWeights[WLANTL_AC_BK];
5159 bACWeights[WLANTL_AC_BE] = pMac->roam.ucACWeights[WLANTL_AC_BE];
5160 bACWeights[WLANTL_AC_VI] = pMac->roam.ucACWeights[WLANTL_AC_VI];
5161 bACWeights[WLANTL_AC_VO] = pMac->roam.ucACWeights[WLANTL_AC_VO];
5162 paramBk = pIEs->WMMParams.acbk_aifsn + pIEs->WMMParams.acbk_acwmin;
5163 paramBe = pIEs->WMMParams.acbe_aifsn + pIEs->WMMParams.acbe_acwmin;
5164 paramVi = pIEs->WMMParams.acvi_aifsn + pIEs->WMMParams.acvi_acwmin;
5165 paramVo = pIEs->WMMParams.acvo_aifsn + pIEs->WMMParams.acvo_acwmin;
5166 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramBe) )
5167 {
5168 bACWeights[WLANTL_AC_BE] = bACWeights[WLANTL_AC_BK];
5169 fWeightChange = VOS_TRUE;
5170 }
5171 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVi) )
5172 {
5173 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BK];
5174 fWeightChange = VOS_TRUE;
5175 }
5176 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVi) )
5177 {
5178 bACWeights[WLANTL_AC_VI] = bACWeights[WLANTL_AC_BE];
5179 fWeightChange = VOS_TRUE;
5180 }
5181 if( SME_DETECT_AC_WEIGHT_DIFF(paramBk, paramVo) )
5182 {
5183 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BK];
5184 fWeightChange = VOS_TRUE;
5185 }
5186 else if( SME_DETECT_AC_WEIGHT_DIFF(paramBe, paramVo) )
5187 {
5188 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_BE];
5189 fWeightChange = VOS_TRUE;
5190 }
5191 else if( SME_DETECT_AC_WEIGHT_DIFF(paramVi, paramVo) )
5192 {
5193 bACWeights[WLANTL_AC_VO] = bACWeights[WLANTL_AC_VI];
5194 fWeightChange = VOS_TRUE;
5195 }
5196 if(fWeightChange)
5197 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005198 smsLog(pMac, LOGE, FL(" change AC weights (%d-%d-%d-%d)"), bACWeights[0], bACWeights[1],
Jeff Johnson295189b2012-06-20 16:38:30 -07005199 bACWeights[2], bACWeights[3]);
5200 WLANTL_SetACWeights(pMac->roam.gVosContext, bACWeights);
5201 }
5202 }
5203}
Jeff Johnson295189b2012-06-20 16:38:30 -07005204#ifdef WLAN_FEATURE_VOWIFI_11R
5205//Returns whether the current association is a 11r assoc or not
5206tANI_BOOLEAN csrRoamIs11rAssoc(tpAniSirGlobal pMac)
5207{
5208#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5209 return csrNeighborRoamIs11rAssoc(pMac);
5210#else
5211 return eANI_BOOLEAN_FALSE;
5212#endif
5213}
5214#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005215#ifdef FEATURE_WLAN_ESE
5216//Returns whether the current association is a ESE assoc or not
5217tANI_BOOLEAN csrRoamIsESEAssoc(tpAniSirGlobal pMac)
Jeff Johnson295189b2012-06-20 16:38:30 -07005218{
5219#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005220 return csrNeighborRoamIsESEAssoc(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -07005221#else
5222 return eANI_BOOLEAN_FALSE;
5223#endif
5224}
5225#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005226#ifdef FEATURE_WLAN_LFR
5227//Returns whether "Legacy Fast Roaming" is currently enabled...or not
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305228tANI_BOOLEAN csrRoamIsFastRoamEnabled(tpAniSirGlobal pMac, tANI_U32 sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005229{
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05305230 tCsrRoamSession *pSession = NULL;
5231
5232 if (CSR_IS_SESSION_VALID( pMac, sessionId ) )
5233 {
5234 pSession = CSR_GET_SESSION( pMac, sessionId );
5235 if (NULL != pSession->pCurRoamProfile)
5236 {
5237 if (pSession->pCurRoamProfile->csrPersona != VOS_STA_MODE)
5238 {
5239 return eANI_BOOLEAN_FALSE;
5240 }
5241 }
5242 }
5243
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005244#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5245 if (eANI_BOOLEAN_TRUE == CSR_IS_FASTROAM_IN_CONCURRENCY_INI_FEATURE_ENABLED(pMac))
5246 {
5247 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled);
5248 }
5249 else
5250#endif
5251 {
5252 return (pMac->roam.configParam.isFastRoamIniFeatureEnabled &&
Madan Mohan Koyyalamudi393a4342012-10-15 16:07:09 -07005253 (!csrIsConcurrentSessionRunning(pMac)));
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005254 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005255}
Srinivas Girigowda830bbd02013-06-13 19:44:16 -07005256
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005257#ifdef FEATURE_WLAN_ESE
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005258/* ---------------------------------------------------------------------------
5259
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005260 \fn csrNeighborRoamIsESEAssoc
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005261
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005262 \brief This function returns whether the current association is a ESE assoc or not
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005263
5264 \param pMac - The handle returned by macOpen.
5265
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005266 \return eANI_BOOLEAN_TRUE if current assoc is ESE, eANI_BOOLEAN_FALSE otherwise
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005267
5268---------------------------------------------------------------------------*/
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005269tANI_BOOLEAN csrNeighborRoamIsESEAssoc(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005270{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005271 return pMac->roam.neighborRoamInfo.isESEAssoc;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005272}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005273#endif /* FEATURE_WLAN_ESE */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005274
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -07005275#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
5276//Returns whether "FW based BG scan" is currently enabled...or not
5277tANI_BOOLEAN csrRoamIsRoamOffloadScanEnabled(tpAniSirGlobal pMac)
5278{
5279 return (pMac->roam.configParam.isRoamOffloadScanEnabled);
5280}
5281#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07005282#endif
5283
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005284#if defined(FEATURE_WLAN_ESE)
5285tANI_BOOLEAN csrRoamIsEseIniFeatureEnabled(tpAniSirGlobal pMac)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005286{
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005287 return pMac->roam.configParam.isEseIniFeatureEnabled;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005288}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005289#endif /*FEATURE_WLAN_ESE*/
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005290
Jeff Johnson295189b2012-06-20 16:38:30 -07005291//Return true means the command can be release, else not
5292static tANI_BOOLEAN csrRoamProcessResults( tpAniSirGlobal pMac, tSmeCmd *pCommand,
5293 eCsrRoamCompleteResult Result, void *Context )
5294{
5295 tANI_BOOLEAN fReleaseCommand = eANI_BOOLEAN_TRUE;
5296 tSirBssDescription *pSirBssDesc = NULL;
5297 tSirMacAddr BroadcastMac = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };
5298 tCsrScanResult *pScanResult = NULL;
5299 tCsrRoamInfo roamInfo;
5300 sme_QosAssocInfo assocInfo;
5301 sme_QosCsrEventIndType ind_qos;//indication for QoS module in SME
5302 tANI_U8 acm_mask = 0; //HDD needs the ACM mask in the assoc rsp callback
5303 tDot11fBeaconIEs *pIes = NULL;
5304 tANI_U32 sessionId = pCommand->sessionId;
5305 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
5306 tCsrRoamProfile *pProfile = &pCommand->u.roamCmd.roamProfile;
5307 eRoamCmdStatus roamStatus;
5308 eCsrRoamResult roamResult;
5309 eHalStatus status;
5310 tANI_U32 key_timeout_interval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07005311 tSirSmeStartBssRsp *pSmeStartBssRsp = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07005312
Jeff Johnson32d95a32012-09-10 13:15:23 -07005313 if(!pSession)
5314 {
5315 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
5316 return eANI_BOOLEAN_FALSE;
5317 }
5318
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005319 smsLog( pMac, LOG1, FL("Processing ROAM results..."));
Jeff Johnson295189b2012-06-20 16:38:30 -07005320 switch( Result )
5321 {
5322 case eCsrJoinSuccess:
5323 // reset the IDLE timer
5324 // !!
5325 // !! fall through to the next CASE statement here is intentional !!
5326 // !!
5327 case eCsrReassocSuccess:
5328 if(eCsrReassocSuccess == Result)
5329 {
5330 ind_qos = SME_QOS_CSR_REASSOC_COMPLETE;
5331 }
5332 else
5333 {
5334 ind_qos = SME_QOS_CSR_ASSOC_COMPLETE;
5335 }
5336 // Success Join Response from LIM. Tell NDIS we are connected and save the
5337 // Connected state...
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005338 smsLog(pMac, LOGW, FL("receives association indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305339 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005340 //always free the memory here
5341 if(pSession->pWpaRsnRspIE)
5342 {
5343 pSession->nWpaRsnRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305344 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 pSession->pWpaRsnRspIE = NULL;
5346 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005347#ifdef FEATURE_WLAN_WAPI
5348 if(pSession->pWapiRspIE)
5349 {
5350 pSession->nWapiRspIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +05305351 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005352 pSession->pWapiRspIE = NULL;
5353 }
5354#endif /* FEATURE_WLAN_WAPI */
5355#ifdef FEATURE_WLAN_BTAMP_UT_RF
5356 //Reset counter so no join retry is needed.
5357 pSession->maxRetryCount = 0;
5358 csrRoamStopJoinRetryTimer(pMac, sessionId);
5359#endif
5360 /* This creates problem since we have not saved the connected profile.
5361 So moving this after saving the profile
5362 */
5363 //csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED );
Abhishek Singh36abbcb2014-03-20 13:04:09 +05305364
5365 /* Reset remainInPowerActiveTillDHCP as it might have been set
5366 * by last failed secured connection.
5367 * It should be set only for secured connection.
5368 */
5369 pMac->pmc.remainInPowerActiveTillDHCP = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005370 if( CSR_IS_INFRASTRUCTURE( pProfile ) )
5371 {
5372 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_ASSOCIATED;
5373 }
5374 else
5375 {
5376 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;
5377 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005378 //Use the last connected bssdesc for reassoc-ing to the same AP.
5379 //NOTE: What to do when reassoc to a different AP???
5380 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5381 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5382 {
5383 pSirBssDesc = pSession->pConnectBssDesc;
5384 if(pSirBssDesc)
5385 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305386 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5387 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005388 }
5389 }
5390 else
5391 {
5392
5393 if(pCommand->u.roamCmd.pRoamBssEntry)
5394 {
5395 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
5396 if(pScanResult != NULL)
5397 {
5398 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5399 //this can be NULL
5400 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
Kiet Lam64c1b492013-07-12 13:56:44 +05305401 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5402 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005403 }
5404 }
5405 }
5406 if( pSirBssDesc )
5407 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005408 roamInfo.staId = HAL_STA_INVALID_IDX;
Jeff Johnson295189b2012-06-20 16:38:30 -07005409 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
5410 //Save WPA/RSN IE
5411 csrRoamSaveSecurityRspIE(pMac, sessionId, pProfile->negotiatedAuthType, pSirBssDesc, pIes);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005412#ifdef FEATURE_WLAN_ESE
5413 roamInfo.isESEAssoc = pSession->connectedProfile.isESEAssoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005414#endif
5415
5416 // csrRoamStateChange also affects sub-state. Hence, csrRoamStateChange happens first and then
5417 // substate change.
5418 // Moving even save profile above so that below mentioned conditon is also met.
5419 // JEZ100225: Moved to after saving the profile. Fix needed in main/latest
5420 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005421 // Make sure the Set Context is issued before link indication to NDIS. After link indication is
5422 // made to NDIS, frames could start flowing. If we have not set context with LIM, the frames
5423 // will be dropped for the security context may not be set properly.
5424 //
5425 // this was causing issues in the 2c_wlan_wep WHQL test when the SetContext was issued after the link
5426 // indication. (Link Indication happens in the profFSMSetConnectedInfra call).
5427 //
5428 // this reordering was done on titan_prod_usb branch and is being replicated here.
5429 //
5430
5431 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) &&
5432 !pProfile->bWPSAssociation)
5433 {
5434 // Issue the set Context request to LIM to establish the Unicast STA context
5435 if( !HAL_STATUS_SUCCESS( csrRoamIssueSetContextReq( pMac, sessionId,
5436 pProfile->negotiatedUCEncryptionType,
5437 pSirBssDesc, &(pSirBssDesc->bssId),
5438 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ) ) ) // NO keys... these key parameters don't matter.
5439 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005440 smsLog( pMac, LOGE, FL(" Set context for unicast fail") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005441 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
5442 }
5443 // Issue the set Context request to LIM to establish the Broadcast STA context
5444 csrRoamIssueSetContextReq( pMac, sessionId, pProfile->negotiatedMCEncryptionType,
5445 pSirBssDesc, &BroadcastMac,
5446 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5447 }
5448 else
5449 {
5450 //Need to wait for supplicant authtication
5451 roamInfo.fAuthRequired = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005452 //Set the subestate to WaitForKey in case authentiation is needed
5453 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_WAIT_FOR_KEY, sessionId );
5454
Jeff Johnson295189b2012-06-20 16:38:30 -07005455 if(pProfile->bWPSAssociation)
5456 {
5457 key_timeout_interval = CSR_WAIT_FOR_WPS_KEY_TIMEOUT_PERIOD;
5458 }
5459 else
5460 {
5461 key_timeout_interval = CSR_WAIT_FOR_KEY_TIMEOUT_PERIOD;
5462 }
5463
5464 //Save sessionId in case of timeout
5465 pMac->roam.WaitForKeyTimerInfo.sessionId = (tANI_U8)sessionId;
5466 //This time should be long enough for the rest of the process plus setting key
5467 if(!HAL_STATUS_SUCCESS( csrRoamStartWaitForKeyTimer( pMac, key_timeout_interval ) ) )
5468 {
5469 //Reset our state so nothting is blocked.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005470 smsLog( pMac, LOGE, FL(" Failed to start pre-auth timer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07005471 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
5472 }
5473 }
5474
5475 assocInfo.pBssDesc = pSirBssDesc; //could be NULL
5476 assocInfo.pProfile = pProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005477 if(Context)
5478 {
5479 tSirSmeJoinRsp *pJoinRsp = (tSirSmeJoinRsp *)Context;
5480 tANI_U32 len;
Jeff Johnson295189b2012-06-20 16:38:30 -07005481 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5482 len = pJoinRsp->assocReqLength + pJoinRsp->assocRspLength + pJoinRsp->beaconLength;
5483#ifdef WLAN_FEATURE_VOWIFI_11R
5484 len += pJoinRsp->parsedRicRspLen;
5485#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005486#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005487 len += pJoinRsp->tspecIeLen;
5488#endif
5489 if(len)
5490 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305491 pSession->connectedInfo.pbFrames = vos_mem_malloc(len);
5492 if ( pSession->connectedInfo.pbFrames != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07005493 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305494 vos_mem_copy(pSession->connectedInfo.pbFrames,
5495 pJoinRsp->frames, len);
5496 pSession->connectedInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5497 pSession->connectedInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5498 pSession->connectedInfo.nBeaconLength = pJoinRsp->beaconLength;
Jeff Johnson295189b2012-06-20 16:38:30 -07005499#ifdef WLAN_FEATURE_VOWIFI_11R
Kiet Lam64c1b492013-07-12 13:56:44 +05305500 pSession->connectedInfo.nRICRspLength = pJoinRsp->parsedRicRspLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005501#endif /* WLAN_FEATURE_VOWIFI_11R */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005502#ifdef FEATURE_WLAN_ESE
Kiet Lam64c1b492013-07-12 13:56:44 +05305503 pSession->connectedInfo.nTspecIeLength = pJoinRsp->tspecIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07005504#endif
Kiet Lam64c1b492013-07-12 13:56:44 +05305505 roamInfo.nAssocReqLength = pJoinRsp->assocReqLength;
5506 roamInfo.nAssocRspLength = pJoinRsp->assocRspLength;
5507 roamInfo.nBeaconLength = pJoinRsp->beaconLength;
5508 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
Jeff Johnson295189b2012-06-20 16:38:30 -07005509 }
5510 }
5511 if(pCommand->u.roamCmd.fReassoc)
5512 {
5513 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5514 }
5515 pSession->connectedInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5516 roamInfo.staId = ( tANI_U8 )pJoinRsp->staId;
5517 roamInfo.ucastSig = ( tANI_U8 )pJoinRsp->ucastSig;
5518 roamInfo.bcastSig = ( tANI_U8 )pJoinRsp->bcastSig;
c_hpothu44ff4e02014-05-08 00:13:57 +05305519 roamInfo.maxRateFlags = pJoinRsp->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07005520 }
5521 else
5522 {
5523 if(pCommand->u.roamCmd.fReassoc)
5524 {
5525 roamInfo.fReassocReq = roamInfo.fReassocRsp = eANI_BOOLEAN_TRUE;
5526 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5527 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5528 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5529 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5530 }
5531 }
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05305532 /* Update the staId from the previous connected profile info
5533 as the reassociation is triggred at SME/HDD */
5534 if( (eCsrHddIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) ||
5535 (eCsrSmeIssuedReassocToSameAP == pCommand->u.roamCmd.roamReason) )
5536 {
5537 roamInfo.staId = pSession->connectedInfo.staId;
5538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005539#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5540 // Indicate SME-QOS with reassoc success event, only after
5541 // copying the frames
5542 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, ind_qos, &assocInfo);
5543#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005544 roamInfo.pBssDesc = pSirBssDesc;
5545 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5546 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5547#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5548 acm_mask = sme_QosGetACMMask(pMac, pSirBssDesc, NULL);
5549#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
5550 pSession->connectedProfile.acm_mask = acm_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07005551 //start UAPSD if uapsd_mask is not 0 because HDD will configure for trigger frame
5552 //It may be better to let QoS do this????
5553 if( pSession->connectedProfile.modifyProfileFields.uapsd_mask )
5554 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005555 smsLog(pMac, LOGE, " uapsd_mask (0x%X) set, request UAPSD now",
Jeff Johnson295189b2012-06-20 16:38:30 -07005556 pSession->connectedProfile.modifyProfileFields.uapsd_mask);
5557 pmcStartUapsd( pMac, NULL, NULL );
5558 }
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +05305559 pSession->connectedProfile.dot11Mode = pSession->bssParams.uCfgDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005560 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
5561 if( pSession->bRefAssocStartCnt > 0 )
5562 {
5563 pSession->bRefAssocStartCnt--;
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005564 //Remove this code once SLM_Sessionization is supported
5565 //BMPS_WORKAROUND_NOT_NEEDED
5566 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) && ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005567 {
5568 pMac->roam.configParam.doBMPSWorkaround = 1;
5569 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005570 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5571 }
5572
5573 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_NONE, eANI_BOOLEAN_TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005574 // reset the PMKID candidate list
5575 csrResetPMKIDCandidateList( pMac, sessionId );
5576 //Update TL's AC weight base on the current EDCA parameters
5577 //These parameters may change in the course of the connection, that sictuation
5578 //is not taken care here. This change is mainly to address a WIFI WMM test where
5579 //BE has a equal or higher TX priority than VI.
5580 //We only do this for infra link
5581 if( csrIsConnStateConnectedInfra(pMac, sessionId ) && pIes )
5582 {
5583 csrCheckAndUpdateACWeight(pMac, pIes);
5584 }
5585#ifdef FEATURE_WLAN_WAPI
5586 // reset the BKID candidate list
5587 csrResetBKIDCandidateList( pMac, sessionId );
5588#endif /* FEATURE_WLAN_WAPI */
5589 }
5590 else
5591 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005592 smsLog(pMac, LOGW, " Roam command doesn't have a BSS desc");
Jeff Johnson295189b2012-06-20 16:38:30 -07005593 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005594 csrScanCancelIdleScan(pMac);
5595 //Not to signal link up because keys are yet to be set.
5596 //The linkup function will overwrite the sub-state that we need to keep at this point.
5597 if( !CSR_IS_WAIT_FOR_KEY(pMac, sessionId) )
5598 {
5599 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
5600 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005601 //Check if BMPS is required and start the BMPS retry timer. Timer period is large
5602 //enough to let security and DHCP handshake succeed before entry into BMPS
5603 if (pmcShouldBmpsTimerRun(pMac))
5604 {
Abhishek Singh65d939e2014-04-25 13:33:07 +05305605 /* Set remainInPowerActiveTillDHCP to make sure we wait for
5606 * until keys are set before going into BMPS.
5607 */
5608 if(eANI_BOOLEAN_TRUE == roamInfo.fAuthRequired)
5609 {
5610 pMac->pmc.remainInPowerActiveTillDHCP = TRUE;
5611 smsLog(pMac, LOG1, FL("Set remainInPowerActiveTillDHCP "
5612 "to make sure we wait until keys are set before"
5613 " going to BMPS"));
5614 }
5615
Jeff Johnson295189b2012-06-20 16:38:30 -07005616 if (pmcStartTrafficTimer(pMac, BMPS_TRAFFIC_TIMER_ALLOW_SECURITY_DHCP)
5617 != eHAL_STATUS_SUCCESS)
5618 {
5619 smsLog(pMac, LOGP, FL("Cannot start BMPS Retry timer"));
5620 }
5621 smsLog(pMac, LOG2, FL("BMPS Retry Timer already running or started"));
5622 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005623 break;
5624
Jeff Johnson295189b2012-06-20 16:38:30 -07005625 case eCsrStartBssSuccess:
5626 // on the StartBss Response, LIM is returning the Bss Description that we
5627 // are beaconing. Add this Bss Description to our scan results and
5628 // chain the Profile to this Bss Description. On a Start BSS, there was no
5629 // detected Bss description (no partner) so we issued the Start Bss to
5630 // start the Ibss without any Bss description. Lim was kind enough to return
5631 // the Bss Description that we start beaconing for the newly started Ibss.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005632 smsLog(pMac, LOG2, FL("receives start BSS ok indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005633 status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005634 pSmeStartBssRsp = (tSirSmeStartBssRsp *)Context;
Kiet Lam64c1b492013-07-12 13:56:44 +05305635 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005636 if( CSR_IS_IBSS( pProfile ) )
5637 {
5638 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
5639 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005640 else if (CSR_IS_INFRA_AP(pProfile))
5641 {
5642 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
5643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005644 else
5645 {
5646 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
5647 }
5648 if( !CSR_IS_WDS_STA( pProfile ) )
5649 {
5650 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07005651 pSirBssDesc = &pSmeStartBssRsp->bssDescription;
Jeff Johnson295189b2012-06-20 16:38:30 -07005652 if( !HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs( pMac, pSirBssDesc, &pIes )) )
5653 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05305654 smsLog(pMac, LOGW, FL("cannot parse IBSS IEs"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005655 roamInfo.pBssDesc = pSirBssDesc;
5656 //We need to associate_complete it first, becasue Associate_start already indicated.
5657 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5658 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_START_FAILED );
5659 break;
5660 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005661 if (!CSR_IS_INFRA_AP(pProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07005662 {
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -07005663 pScanResult = csrScanAppendBssDescription( pMac, pSirBssDesc, pIes, FALSE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005664 }
5665 csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
5666 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5667 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5668 if(pSirBssDesc)
5669 {
5670 csrRoamSaveConnectedInfomation(pMac, sessionId, pProfile, pSirBssDesc, pIes);
Kiet Lam64c1b492013-07-12 13:56:44 +05305671 vos_mem_copy(&roamInfo.bssid, &pSirBssDesc->bssId,
5672 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005673 }
5674 //We are doen with the IEs so free it
Kiet Lam64c1b492013-07-12 13:56:44 +05305675 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -07005676#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5677 {
5678 vos_log_ibss_pkt_type *pIbssLog;
5679 tANI_U32 bi;
5680
5681 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5682 if(pIbssLog)
5683 {
5684 if(CSR_INVALID_SCANRESULT_HANDLE == pCommand->u.roamCmd.hBSSList)
5685 {
5686 //We start the IBSS (didn't find any matched IBSS out there)
5687 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_RSP;
5688 }
5689 else
5690 {
5691 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_RSP;
5692 }
5693 if(pSirBssDesc)
5694 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305695 vos_mem_copy(pIbssLog->bssid, pSirBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07005696 pIbssLog->operatingChannel = pSirBssDesc->channelId;
5697 }
5698 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
5699 {
5700 //***U8 is not enough for beacon interval
5701 pIbssLog->beaconInterval = (v_U8_t)bi;
5702 }
5703 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5704 }
5705 }
5706#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5707 //Only set context for non-WDS_STA. We don't even need it for WDS_AP. But since the encryption
5708 //is WPA2-PSK so it won't matter.
Jeff Johnson295189b2012-06-20 16:38:30 -07005709 if( CSR_IS_ENC_TYPE_STATIC( pProfile->negotiatedUCEncryptionType ) && !CSR_IS_INFRA_AP( pSession->pCurRoamProfile ))
5710 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005711 // Issue the set Context request to LIM to establish the Broadcast STA context for the Ibss.
5712 csrRoamIssueSetContextReq( pMac, sessionId,
5713 pProfile->negotiatedMCEncryptionType,
5714 pSirBssDesc, &BroadcastMac,
5715 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
5716 }
5717 }
5718 else
5719 {
5720 //Keep the state to eCSR_ROAMING_STATE_JOINING
5721 //Need to send join_req.
5722 if(pCommand->u.roamCmd.pRoamBssEntry)
5723 {
5724 if((pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link)))
5725 {
5726 pSirBssDesc = &pScanResult->Result.BssDescriptor;
5727 pIes = (tDot11fBeaconIEs *)( pScanResult->Result.pvIes );
5728 // Set the roaming substate to 'join attempt'...
5729 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08005730 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 }
5732 }
5733 else
5734 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005735 smsLog( pMac, LOGE, " StartBSS for WDS station with no BssDesc" );
Jeff Johnson295189b2012-06-20 16:38:30 -07005736 VOS_ASSERT( 0 );
5737 }
5738 }
5739 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5740 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5741 //trigger the connection start indication in Vista
5742 if( !CSR_IS_JOIN_TO_IBSS( pProfile ) )
5743 {
5744 roamStatus = eCSR_ROAM_IBSS_IND;
5745 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5746 if( CSR_IS_WDS( pProfile ) )
5747 {
5748 roamStatus = eCSR_ROAM_WDS_IND;
5749 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005751 if( CSR_IS_INFRA_AP( pProfile ) )
5752 {
5753 roamStatus = eCSR_ROAM_INFRA_IND;
5754 roamResult = eCSR_ROAM_RESULT_INFRA_STARTED;
5755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005756
5757 //Only tell upper layer is we start the BSS because Vista doesn't like multiple connection
5758 //indications. If we don't start the BSS ourself, handler of eSIR_SME_JOINED_NEW_BSS will
5759 //trigger the connection start indication in Vista
Kiet Lam64c1b492013-07-12 13:56:44 +05305760 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005761 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5762 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
krunal soni3fc26642013-10-08 22:41:42 -07005763 //We start the IBSS (didn't find any matched IBSS out there)
5764 roamInfo.pBssDesc = pSirBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07005765 roamInfo.staId = (tANI_U8)pSmeStartBssRsp->staId;
Kiet Lam64c1b492013-07-12 13:56:44 +05305766 vos_mem_copy(roamInfo.bssid, pSirBssDesc->bssId,
5767 sizeof(tCsrBssid));
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -07005768 //Remove this code once SLM_Sessionization is supported
5769 //BMPS_WORKAROUND_NOT_NEEDED
5770 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -07005771 ( csrIsConcurrentSessionRunning( pMac )))
Jeff Johnsone7245742012-09-05 17:12:55 -07005772 {
5773 pMac->roam.configParam.doBMPSWorkaround = 1;
5774 }
Mohit Khanna349bc392012-09-11 17:24:52 -07005775
Jeff Johnson295189b2012-06-20 16:38:30 -07005776 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5777 }
5778
5779 csrScanCancelIdleScan(pMac);
Ravi Joshi414b14c2013-10-04 16:33:26 -07005780
5781 if( CSR_IS_WDS_STA( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005782 {
5783 //need to send stop BSS because we fail to send join_req
5784 csrRoamIssueDisassociateCmd( pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
5785 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5786 eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_STOPPED );
5787 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005788 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005789 case eCsrStartBssFailure:
5790#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
5791 {
5792 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07005793 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
5794 if(pIbssLog)
5795 {
5796 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
5797 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
5798 }
5799 }
5800#endif //#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07005801 roamStatus = eCSR_ROAM_IBSS_IND;
5802 roamResult = eCSR_ROAM_RESULT_IBSS_STARTED;
5803 if( CSR_IS_WDS( pProfile ) )
5804 {
5805 roamStatus = eCSR_ROAM_WDS_IND;
5806 roamResult = eCSR_ROAM_RESULT_WDS_STARTED;
5807 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005808 if( CSR_IS_INFRA_AP( pProfile ) )
5809 {
5810 roamStatus = eCSR_ROAM_INFRA_IND;
5811 roamResult = eCSR_ROAM_RESULT_INFRA_START_FAILED;
5812 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005813 if(Context)
5814 {
5815 pSirBssDesc = (tSirBssDescription *)Context;
5816 }
5817 else
5818 {
5819 pSirBssDesc = NULL;
5820 }
Kiet Lam64c1b492013-07-12 13:56:44 +05305821 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005822 roamInfo.pBssDesc = pSirBssDesc;
5823 //We need to associate_complete it first, becasue Associate_start already indicated.
5824 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId, roamStatus, roamResult );
5825 csrSetDefaultDot11Mode( pMac );
5826 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005827 case eCsrSilentlyStopRoaming:
5828 // We are here because we try to start the same IBSS
5829 //No message to PE
5830 // return the roaming state to Joined.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005831 smsLog(pMac, LOGW, FL("receives silently roaming indication"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005832 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId );
5833 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305834 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005835 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5836 if( roamInfo.pBssDesc )
5837 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305838 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5839 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005840 }
5841 //Since there is no change in the current state, simply pass back no result otherwise
5842 //HDD may be mistakenly mark to disconnected state.
5843 csrRoamCallCallback( pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5844 eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_NONE );
Jeff Johnson295189b2012-06-20 16:38:30 -07005845 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005846 case eCsrSilentlyStopRoamingSaveState:
5847 //We are here because we try to connect to the same AP
5848 //No message to PE
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005849 smsLog(pMac, LOGW, FL("receives silently stop roaming indication"));
Kiet Lam64c1b492013-07-12 13:56:44 +05305850 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005851
5852 //to aviod resetting the substate to NONE
5853 pMac->roam.curState[sessionId] = eCSR_ROAMING_STATE_JOINED;
5854 //No need to change substate to wai_for_key because there is no state change
5855 roamInfo.pBssDesc = pSession->pConnectBssDesc;
5856 if( roamInfo.pBssDesc )
5857 {
Kiet Lam64c1b492013-07-12 13:56:44 +05305858 vos_mem_copy(&roamInfo.bssid, &roamInfo.pBssDesc->bssId,
5859 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07005860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005861 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5862 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5863 roamInfo.nBeaconLength = pSession->connectedInfo.nBeaconLength;
5864 roamInfo.nAssocReqLength = pSession->connectedInfo.nAssocReqLength;
5865 roamInfo.nAssocRspLength = pSession->connectedInfo.nAssocRspLength;
5866 roamInfo.pbFrames = pSession->connectedInfo.pbFrames;
5867 roamInfo.staId = pSession->connectedInfo.staId;
5868 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005869 VOS_ASSERT( roamInfo.staId != 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07005870 pSession->bRefAssocStartCnt--;
5871 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5872 eCSR_ROAM_ASSOCIATION_COMPLETION, eCSR_ROAM_RESULT_ASSOCIATED);
5873 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_ASSOCIATED, eANI_BOOLEAN_TRUE);
5874 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005875 case eCsrReassocFailure:
5876#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5877 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_REASSOC_FAILURE, NULL);
5878#endif
5879 case eCsrJoinWdsFailure:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005880 smsLog(pMac, LOGW, FL("failed to join WDS"));
Jeff Johnson295189b2012-06-20 16:38:30 -07005881 csrFreeConnectBssDesc(pMac, sessionId);
5882 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5883 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
Kiet Lam64c1b492013-07-12 13:56:44 +05305884 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005885 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5886 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5887 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
5888 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5889 eCSR_ROAM_WDS_IND,
5890 eCSR_ROAM_RESULT_WDS_NOT_ASSOCIATED);
5891 //Need to issue stop_bss
5892 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005893 case eCsrJoinFailure:
5894 case eCsrNothingToJoin:
Jeff Johnsone7245742012-09-05 17:12:55 -07005895 case eCsrJoinFailureDueToConcurrency:
Jeff Johnson295189b2012-06-20 16:38:30 -07005896 default:
5897 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005898 smsLog(pMac, LOGW, FL("receives no association indication"));
5899 smsLog(pMac, LOG1, FL("Assoc ref count %d"),
Madan Mohan Koyyalamudi85d140a2012-10-18 20:23:01 -07005900 pSession->bRefAssocStartCnt);
Jeff Johnson295189b2012-06-20 16:38:30 -07005901 if( CSR_IS_INFRASTRUCTURE( &pSession->connectedProfile ) ||
5902 CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, sessionId ) )
5903 {
5904 //do not free for the other profiles as we need to send down stop BSS later
5905 csrFreeConnectBssDesc(pMac, sessionId);
5906 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
5907 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
5908 csrSetDefaultDot11Mode( pMac );
5909 }
5910
5911 switch( pCommand->u.roamCmd.roamReason )
5912 {
5913 // If this transition is because of an 802.11 OID, then we transition
5914 // back to INIT state so we sit waiting for more OIDs to be issued and
5915 // we don't start the IDLE timer.
Jeff Johnsone7245742012-09-05 17:12:55 -07005916 case eCsrSmeIssuedFTReassoc:
Jeff Johnson295189b2012-06-20 16:38:30 -07005917 case eCsrSmeIssuedAssocToSimilarAP:
5918 case eCsrHddIssued:
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08005919 case eCsrSmeIssuedDisassocForHandoff:
Jeff Johnson295189b2012-06-20 16:38:30 -07005920 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +05305921 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07005922 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
5923 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
5924 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Kiet Lam64c1b492013-07-12 13:56:44 +05305925 vos_mem_copy(&roamInfo.bssid,
5926 &pSession->joinFailStatusCode.bssId,
5927 sizeof(tCsrBssid));
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005928
Jeff Johnson295189b2012-06-20 16:38:30 -07005929 /* Defeaturize this later if needed */
5930#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
5931 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
5932 if (csrRoamIsHandoffInProgress(pMac))
5933 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005934 /* Should indicate neighbor roam algorithm about the connect failure here */
5935 csrNeighborRoamIndicateConnect(pMac, (tANI_U8)sessionId, VOS_STATUS_E_FAILURE);
5936 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005937#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07005938 if(pSession->bRefAssocStartCnt > 0)
5939 {
5940 pSession->bRefAssocStartCnt--;
Jeff Johnsone7245742012-09-05 17:12:55 -07005941 if(eCsrJoinFailureDueToConcurrency == Result)
5942 {
5943 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
5944 eCSR_ROAM_ASSOCIATION_COMPLETION,
5945 eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL);
5946 }
5947 else
5948 {
5949 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07005950 eCSR_ROAM_ASSOCIATION_COMPLETION,
5951 eCSR_ROAM_RESULT_FAILURE);
Jeff Johnsone7245742012-09-05 17:12:55 -07005952 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005953 }
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005954 else
5955 {
5956 /* bRefAssocStartCnt is not incremented when
5957 * eRoamState == eCsrStopRoamingDueToConcurrency
5958 * in csrRoamJoinNextBss API. so handle this in
5959 * else case by sending assoc failure
5960 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07005961 csrRoamCallCallback(pMac, sessionId, &roamInfo,
Gopichand Nakkala4261ea52012-12-31 16:43:00 -08005962 pCommand->u.scanCmd.roamId,
5963 eCSR_ROAM_ASSOCIATION_FAILURE,
5964 eCSR_ROAM_RESULT_FAILURE);
5965 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08005966 smsLog(pMac, LOG1, FL(" roam(reason %d) failed"), pCommand->u.roamCmd.roamReason);
Jeff Johnson295189b2012-06-20 16:38:30 -07005967#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Mukul Sharma5960ac82014-01-09 20:31:35 +05305968 sme_QosUpdateHandOff((tANI_U8)sessionId, VOS_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07005969 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5970#endif
5971 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5972 csrScanStartIdleScan(pMac);
5973#ifdef FEATURE_WLAN_BTAMP_UT_RF
5974 //For WDS STA. To fix the issue where the WDS AP side may be too busy by
5975 //BT activity and not able to recevie WLAN traffic. Retry the join
5976 if( CSR_IS_WDS_STA(pProfile) )
5977 {
5978 csrRoamStartJoinRetryTimer(pMac, sessionId, CSR_JOIN_RETRY_TIMEOUT_PERIOD);
5979 }
5980#endif
5981 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07005982 case eCsrHddIssuedReassocToSameAP:
5983 case eCsrSmeIssuedReassocToSameAP:
5984 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5985
5986 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
5987#ifndef WLAN_MDM_CODE_REDUCTION_OPT
5988 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
5989#endif
5990 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
5991 csrScanStartIdleScan(pMac);
5992 break;
5993 case eCsrForcedDisassoc:
5994 case eCsrForcedDeauth:
5995 case eCsrSmeIssuedIbssJoinFailure:
5996 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId);
5997
5998 if(eCsrSmeIssuedIbssJoinFailure == pCommand->u.roamCmd.roamReason)
5999 {
6000 // Notify HDD that IBSS join failed
6001 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_IBSS_IND, eCSR_ROAM_RESULT_IBSS_JOIN_FAILED);
6002 }
6003 else
6004 {
6005 csrRoamCallCallback(pMac, sessionId, NULL,
6006 pCommand->u.roamCmd.roamId,
6007 eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
6008 }
6009#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6010 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
6011#endif
6012 csrRoamLinkDown(pMac, sessionId);
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08006013 /*
6014 *DelSta not done FW still in conneced state so dont
6015 *issue IMPS req
6016 */
6017 if (pMac->roam.deauthRspStatus == eSIR_SME_DEAUTH_STATUS)
6018 {
6019 smsLog(pMac, LOGW, FL("FW still in connected state "));
6020 break;
6021 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006022 csrScanStartIdleScan(pMac);
6023 break;
6024 case eCsrForcedIbssLeave:
6025 csrRoamCallCallback(pMac, sessionId, NULL,
6026 pCommand->u.roamCmd.roamId,
6027 eCSR_ROAM_IBSS_LEAVE,
6028 eCSR_ROAM_RESULT_IBSS_STOP);
6029 break;
6030 case eCsrForcedDisassocMICFailure:
6031 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6032
6033 csrRoamCallCallback(pMac, sessionId, NULL, pCommand->u.roamCmd.roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_MIC_FAILURE);
6034#ifndef WLAN_MDM_CODE_REDUCTION_OPT
6035 sme_QosCsrEventInd(pMac, (tANI_U8)sessionId, SME_QOS_CSR_DISCONNECT_REQ, NULL);
6036#endif
6037 csrScanStartIdleScan(pMac);
6038 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006039 case eCsrStopBss:
6040 csrRoamCallCallback(pMac, sessionId, NULL,
6041 pCommand->u.roamCmd.roamId,
6042 eCSR_ROAM_INFRA_IND,
6043 eCSR_ROAM_RESULT_INFRA_STOPPED);
6044 break;
6045 case eCsrForcedDisassocSta:
6046 case eCsrForcedDeauthSta:
6047 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINED, sessionId);
6048 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
6049 {
6050 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006051
6052 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
6053 {
6054 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05306055 vos_mem_copy(roamInfo.peerMac,
6056 pCommand->u.roamCmd.peerMac,
6057 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07006058 roamInfo.reasonCode = eCSR_ROAM_RESULT_FORCED;
6059 roamInfo.statusCode = eSIR_SME_SUCCESS;
6060 status = csrRoamCallCallback(pMac, sessionId,
6061 &roamInfo, pCommand->u.roamCmd.roamId,
6062 eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
6063 }
6064 }
6065 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07006066 case eCsrLostLink1:
6067 // if lost link roam1 failed, then issue lost link Scan2 ...
6068 csrScanRequestLostLink2(pMac, sessionId);
6069 break;
6070 case eCsrLostLink2:
6071 // if lost link roam2 failed, then issue lost link scan3 ...
6072 csrScanRequestLostLink3(pMac, sessionId);
6073 break;
6074 case eCsrLostLink3:
6075 default:
6076 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_IDLE, sessionId );
6077
6078 //We are done with one round of lostlink roaming here
6079 csrScanHandleFailedLostlink3(pMac, sessionId);
6080 break;
6081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006082 break;
6083 }
6084 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006085 return ( fReleaseCommand );
6086}
6087
Jeff Johnson295189b2012-06-20 16:38:30 -07006088eHalStatus csrRoamRegisterCallback(tpAniSirGlobal pMac, csrRoamCompleteCallback callback, void *pContext)
6089{
6090 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006091 return (status);
6092}
6093
Jeff Johnson295189b2012-06-20 16:38:30 -07006094eHalStatus csrRoamCopyProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pDstProfile, tCsrRoamProfile *pSrcProfile)
6095{
6096 eHalStatus status = eHAL_STATUS_SUCCESS;
6097 tANI_U32 size = 0;
6098
6099 do
6100 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306101 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006102 if(pSrcProfile->BSSIDs.numOfBSSIDs)
6103 {
6104 size = sizeof(tCsrBssid) * pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306105 pDstProfile->BSSIDs.bssid = vos_mem_malloc(size);
6106 if ( NULL == pDstProfile->BSSIDs.bssid )
6107 status = eHAL_STATUS_FAILURE;
6108 else
6109 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006110 if(!HAL_STATUS_SUCCESS(status))
6111 {
6112 break;
6113 }
6114 pDstProfile->BSSIDs.numOfBSSIDs = pSrcProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306115 vos_mem_copy(pDstProfile->BSSIDs.bssid,
6116 pSrcProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006117 }
6118 if(pSrcProfile->SSIDs.numOfSSIDs)
6119 {
6120 size = sizeof(tCsrSSIDInfo) * pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306121 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(size);
6122 if ( NULL == pDstProfile->SSIDs.SSIDList )
6123 status = eHAL_STATUS_FAILURE;
6124 else
6125 status = eHAL_STATUS_SUCCESS;
6126 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006127 {
6128 break;
6129 }
6130 pDstProfile->SSIDs.numOfSSIDs = pSrcProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05306131 vos_mem_copy(pDstProfile->SSIDs.SSIDList,
6132 pSrcProfile->SSIDs.SSIDList, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07006133 }
6134 if(pSrcProfile->nWPAReqIELength)
6135 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306136 pDstProfile->pWPAReqIE = vos_mem_malloc(pSrcProfile->nWPAReqIELength);
6137 if ( NULL == pDstProfile->pWPAReqIE )
6138 status = eHAL_STATUS_FAILURE;
6139 else
6140 status = eHAL_STATUS_SUCCESS;
6141
6142 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006143 {
6144 break;
6145 }
6146 pDstProfile->nWPAReqIELength = pSrcProfile->nWPAReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306147 vos_mem_copy(pDstProfile->pWPAReqIE, pSrcProfile->pWPAReqIE,
6148 pSrcProfile->nWPAReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006149 }
6150 if(pSrcProfile->nRSNReqIELength)
6151 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306152 pDstProfile->pRSNReqIE = vos_mem_malloc(pSrcProfile->nRSNReqIELength);
6153 if ( NULL == pDstProfile->pRSNReqIE )
6154 status = eHAL_STATUS_FAILURE;
6155 else
6156 status = eHAL_STATUS_SUCCESS;
6157
6158 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006159 {
6160 break;
6161 }
6162 pDstProfile->nRSNReqIELength = pSrcProfile->nRSNReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306163 vos_mem_copy(pDstProfile->pRSNReqIE, pSrcProfile->pRSNReqIE,
6164 pSrcProfile->nRSNReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006165 }
6166#ifdef FEATURE_WLAN_WAPI
6167 if(pSrcProfile->nWAPIReqIELength)
6168 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306169 pDstProfile->pWAPIReqIE = vos_mem_malloc(pSrcProfile->nWAPIReqIELength);
6170 if ( NULL == pDstProfile->pWAPIReqIE )
6171 status = eHAL_STATUS_FAILURE;
6172 else
6173 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006174 if(!HAL_STATUS_SUCCESS(status))
6175 {
6176 break;
6177 }
6178 pDstProfile->nWAPIReqIELength = pSrcProfile->nWAPIReqIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306179 vos_mem_copy(pDstProfile->pWAPIReqIE, pSrcProfile->pWAPIReqIE,
6180 pSrcProfile->nWAPIReqIELength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006181 }
6182#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07006183 if(pSrcProfile->nAddIEScanLength)
6184 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306185 memset(pDstProfile->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
6186 if ( SIR_MAC_MAX_IE_LENGTH >= pSrcProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -07006187 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05306188 vos_mem_copy(pDstProfile->addIEScan, pSrcProfile->addIEScan,
Kiet Lam64c1b492013-07-12 13:56:44 +05306189 pSrcProfile->nAddIEScanLength);
Agarwal Ashish4f616132013-12-30 23:32:50 +05306190 pDstProfile->nAddIEScanLength = pSrcProfile->nAddIEScanLength;
6191 }
6192 else
6193 {
6194 VOS_TRACE( VOS_MODULE_ID_VOSS, VOS_TRACE_LEVEL_ERROR,
6195 FL(" AddIEScanLength is not valid %u"),
6196 pSrcProfile->nAddIEScanLength);
6197 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006198 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006199 if(pSrcProfile->nAddIEAssocLength)
6200 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306201 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6202 if ( NULL == pDstProfile->pAddIEAssoc )
6203 status = eHAL_STATUS_FAILURE;
6204 else
6205 status = eHAL_STATUS_SUCCESS;
6206
Jeff Johnson295189b2012-06-20 16:38:30 -07006207 if(!HAL_STATUS_SUCCESS(status))
6208 {
6209 break;
6210 }
6211 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306212 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6213 pSrcProfile->nAddIEAssocLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07006214 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006215 if(pSrcProfile->ChannelInfo.ChannelList)
6216 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306217 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(
6218 pSrcProfile->ChannelInfo.numOfChannels);
6219 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6220 status = eHAL_STATUS_FAILURE;
6221 else
6222 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006223 if(!HAL_STATUS_SUCCESS(status))
6224 {
6225 break;
6226 }
6227 pDstProfile->ChannelInfo.numOfChannels = pSrcProfile->ChannelInfo.numOfChannels;
Kiet Lam64c1b492013-07-12 13:56:44 +05306228 vos_mem_copy(pDstProfile->ChannelInfo.ChannelList,
6229 pSrcProfile->ChannelInfo.ChannelList,
6230 pSrcProfile->ChannelInfo.numOfChannels);
Jeff Johnson295189b2012-06-20 16:38:30 -07006231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006232 pDstProfile->AuthType = pSrcProfile->AuthType;
6233 pDstProfile->EncryptionType = pSrcProfile->EncryptionType;
6234 pDstProfile->mcEncryptionType = pSrcProfile->mcEncryptionType;
6235 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->negotiatedUCEncryptionType;
6236 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->negotiatedMCEncryptionType;
6237 pDstProfile->negotiatedAuthType = pSrcProfile->negotiatedAuthType;
Chet Lanctot186b5732013-03-18 10:26:30 -07006238#ifdef WLAN_FEATURE_11W
6239 pDstProfile->MFPEnabled = pSrcProfile->MFPEnabled;
6240 pDstProfile->MFPRequired = pSrcProfile->MFPRequired;
6241 pDstProfile->MFPCapable = pSrcProfile->MFPCapable;
6242#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006243 pDstProfile->BSSType = pSrcProfile->BSSType;
6244 pDstProfile->phyMode = pSrcProfile->phyMode;
6245 pDstProfile->csrPersona = pSrcProfile->csrPersona;
6246
6247#ifdef FEATURE_WLAN_WAPI
6248 if(csrIsProfileWapi(pSrcProfile))
6249 {
6250 if(pDstProfile->phyMode & eCSR_DOT11_MODE_11n)
6251 {
6252 pDstProfile->phyMode &= ~eCSR_DOT11_MODE_11n;
6253 }
6254 }
6255#endif /* FEATURE_WLAN_WAPI */
6256 pDstProfile->CBMode = pSrcProfile->CBMode;
6257 /*Save the WPS info*/
6258 pDstProfile->bWPSAssociation = pSrcProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006259 pDstProfile->bOSENAssociation = pSrcProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006260 pDstProfile->uapsd_mask = pSrcProfile->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006261 pDstProfile->beaconInterval = pSrcProfile->beaconInterval;
Jeff Johnson295189b2012-06-20 16:38:30 -07006262 pDstProfile->privacy = pSrcProfile->privacy;
6263 pDstProfile->fwdWPSPBCProbeReq = pSrcProfile->fwdWPSPBCProbeReq;
6264 pDstProfile->csr80211AuthType = pSrcProfile->csr80211AuthType;
6265 pDstProfile->dtimPeriod = pSrcProfile->dtimPeriod;
6266 pDstProfile->ApUapsdEnable = pSrcProfile->ApUapsdEnable;
6267 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->SSIDs.SSIDList[0].ssidHidden;
6268 pDstProfile->protEnabled = pSrcProfile->protEnabled;
6269 pDstProfile->obssProtEnabled = pSrcProfile->obssProtEnabled;
6270 pDstProfile->cfg_protection = pSrcProfile->cfg_protection;
6271 pDstProfile->wps_state = pSrcProfile->wps_state;
6272 pDstProfile->ieee80211d = pSrcProfile->ieee80211d;
Kiet Lam64c1b492013-07-12 13:56:44 +05306273 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6274 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006275#ifdef WLAN_FEATURE_VOWIFI_11R
6276 if (pSrcProfile->MDID.mdiePresent)
6277 {
6278 pDstProfile->MDID.mdiePresent = 1;
6279 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6280 }
6281#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07006282 }while(0);
6283
6284 if(!HAL_STATUS_SUCCESS(status))
6285 {
6286 csrReleaseProfile(pMac, pDstProfile);
6287 pDstProfile = NULL;
6288 }
6289
6290 return (status);
6291}
Jeff Johnson295189b2012-06-20 16:38:30 -07006292eHalStatus csrRoamCopyConnectedProfile(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pDstProfile )
6293{
6294 eHalStatus status = eHAL_STATUS_SUCCESS;
6295 tCsrRoamConnectedProfile *pSrcProfile = &pMac->roam.roamSession[sessionId].connectedProfile;
6296 do
6297 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306298 vos_mem_set(pDstProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006299 if(pSrcProfile->bssid)
6300 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306301 pDstProfile->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
6302 if ( NULL == pDstProfile->BSSIDs.bssid )
6303 status = eHAL_STATUS_FAILURE;
6304 else
6305 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006306 if(!HAL_STATUS_SUCCESS(status))
6307 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306308 smsLog( pMac, LOGE,
6309 FL("failed to allocate memory for BSSID"
6310 "%02x:%02x:%02x:%02x:%02x:%02x"),
6311 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6312 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006313 break;
6314 }
6315 pDstProfile->BSSIDs.numOfBSSIDs = 1;
Kiet Lam64c1b492013-07-12 13:56:44 +05306316 vos_mem_copy(pDstProfile->BSSIDs.bssid, pSrcProfile->bssid,
6317 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006318 }
6319 if(pSrcProfile->SSID.ssId)
6320 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306321 pDstProfile->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
6322 if ( NULL == pDstProfile->SSIDs.SSIDList )
6323 status = eHAL_STATUS_FAILURE;
6324 else
6325 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006326 if(!HAL_STATUS_SUCCESS(status))
6327 {
Kiet Lam1cc95392013-11-22 15:59:36 +05306328 smsLog( pMac, LOGE,
6329 FL("failed to allocate memory for SSIDList"
6330 "%02x:%02x:%02x:%02x:%02x:%02x"),
6331 pSrcProfile->bssid[0], pSrcProfile->bssid[1], pSrcProfile->bssid[2],
6332 pSrcProfile->bssid[3], pSrcProfile->bssid[4], pSrcProfile->bssid[5]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006333 break;
6334 }
6335 pDstProfile->SSIDs.numOfSSIDs = 1;
6336 pDstProfile->SSIDs.SSIDList[0].handoffPermitted = pSrcProfile->handoffPermitted;
6337 pDstProfile->SSIDs.SSIDList[0].ssidHidden = pSrcProfile->ssidHidden;
Kiet Lam64c1b492013-07-12 13:56:44 +05306338 vos_mem_copy(&pDstProfile->SSIDs.SSIDList[0].SSID,
6339 &pSrcProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -07006340 }
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006341 if(pSrcProfile->nAddIEAssocLength)
6342 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306343 pDstProfile->pAddIEAssoc = vos_mem_malloc(pSrcProfile->nAddIEAssocLength);
6344 if ( NULL == pDstProfile->pAddIEAssoc)
6345 status = eHAL_STATUS_FAILURE;
6346 else
6347 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006348 if(!HAL_STATUS_SUCCESS(status))
6349 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006350 smsLog( pMac, LOGE, FL(" failed to allocate memory for additional IEs ") );
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006351 break;
6352 }
6353 pDstProfile->nAddIEAssocLength = pSrcProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05306354 vos_mem_copy(pDstProfile->pAddIEAssoc, pSrcProfile->pAddIEAssoc,
6355 pSrcProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07006356 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306357 pDstProfile->ChannelInfo.ChannelList = vos_mem_malloc(1);
6358 if ( NULL == pDstProfile->ChannelInfo.ChannelList )
6359 status = eHAL_STATUS_FAILURE;
6360 else
6361 status = eHAL_STATUS_SUCCESS;
6362
Jeff Johnson295189b2012-06-20 16:38:30 -07006363 if(!HAL_STATUS_SUCCESS(status))
6364 {
6365 break;
6366 }
6367 pDstProfile->ChannelInfo.numOfChannels = 1;
6368 pDstProfile->ChannelInfo.ChannelList[0] = pSrcProfile->operationChannel;
Jeff Johnson295189b2012-06-20 16:38:30 -07006369 pDstProfile->AuthType.numEntries = 1;
6370 pDstProfile->AuthType.authType[0] = pSrcProfile->AuthType;
6371 pDstProfile->negotiatedAuthType = pSrcProfile->AuthType;
6372 pDstProfile->EncryptionType.numEntries = 1;
6373 pDstProfile->EncryptionType.encryptionType[0] = pSrcProfile->EncryptionType;
6374 pDstProfile->negotiatedUCEncryptionType = pSrcProfile->EncryptionType;
6375 pDstProfile->mcEncryptionType.numEntries = 1;
6376 pDstProfile->mcEncryptionType.encryptionType[0] = pSrcProfile->mcEncryptionType;
6377 pDstProfile->negotiatedMCEncryptionType = pSrcProfile->mcEncryptionType;
6378 pDstProfile->BSSType = pSrcProfile->BSSType;
6379 pDstProfile->CBMode = pSrcProfile->CBMode;
Kiet Lam64c1b492013-07-12 13:56:44 +05306380 vos_mem_copy(&pDstProfile->Keys, &pSrcProfile->Keys,
6381 sizeof(pDstProfile->Keys));
Jeff Johnson295189b2012-06-20 16:38:30 -07006382#ifdef WLAN_FEATURE_VOWIFI_11R
6383 if (pSrcProfile->MDID.mdiePresent)
6384 {
6385 pDstProfile->MDID.mdiePresent = 1;
6386 pDstProfile->MDID.mobilityDomain = pSrcProfile->MDID.mobilityDomain;
6387 }
6388#endif
6389
6390 }while(0);
6391
6392 if(!HAL_STATUS_SUCCESS(status))
6393 {
6394 csrReleaseProfile(pMac, pDstProfile);
6395 pDstProfile = NULL;
6396 }
6397
6398 return (status);
6399}
6400
Jeff Johnson295189b2012-06-20 16:38:30 -07006401eHalStatus csrRoamIssueConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6402 tScanResultHandle hBSSList,
6403 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate,
6404 tANI_BOOLEAN fClearScan)
6405{
6406 eHalStatus status = eHAL_STATUS_SUCCESS;
6407 tSmeCmd *pCommand;
6408
6409 pCommand = csrGetCommandBuffer(pMac);
6410 if(NULL == pCommand)
6411 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006412 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006413 status = eHAL_STATUS_RESOURCES;
6414 }
6415 else
6416 {
6417 if( fClearScan )
6418 {
6419 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306420 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006421 }
6422 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6423 if(NULL == pProfile)
6424 {
6425 //We can roam now
6426 //Since pProfile is NULL, we need to build our own profile, set everything to default
6427 //We can only support open and no encryption
6428 pCommand->u.roamCmd.roamProfile.AuthType.numEntries = 1;
6429 pCommand->u.roamCmd.roamProfile.AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM;
6430 pCommand->u.roamCmd.roamProfile.EncryptionType.numEntries = 1;
6431 pCommand->u.roamCmd.roamProfile.EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6432 pCommand->u.roamCmd.roamProfile.csrPersona = VOS_STA_MODE;
6433 }
6434 else
6435 {
6436 //make a copy of the profile
6437 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6438 if(HAL_STATUS_SUCCESS(status))
6439 {
6440 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6441 }
6442 }
6443 pCommand->command = eSmeCommandRoam;
6444 pCommand->sessionId = (tANI_U8)sessionId;
6445 pCommand->u.roamCmd.hBSSList = hBSSList;
6446 pCommand->u.roamCmd.roamId = roamId;
6447 pCommand->u.roamCmd.roamReason = reason;
6448 //We need to free the BssList when the command is done
6449 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_TRUE;
6450 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006451 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
6452 FL("CSR PERSONA=%d"),
6453 pCommand->u.roamCmd.roamProfile.csrPersona);
Jeff Johnson295189b2012-06-20 16:38:30 -07006454 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6455 if( !HAL_STATUS_SUCCESS( status ) )
6456 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006457 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006458 csrReleaseCommandRoam( pMac, pCommand );
6459 }
6460 }
6461
6462 return (status);
6463}
Jeff Johnson295189b2012-06-20 16:38:30 -07006464eHalStatus csrRoamIssueReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6465 tCsrRoamModifyProfileFields *pMmodProfileFields,
6466 eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
6467{
6468 eHalStatus status = eHAL_STATUS_SUCCESS;
6469 tSmeCmd *pCommand;
6470
6471 pCommand = csrGetCommandBuffer(pMac);
6472 if(NULL == pCommand)
6473 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006474 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07006475 status = eHAL_STATUS_RESOURCES;
6476 }
6477 else
6478 {
6479 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306480 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006481 if(pProfile)
6482 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006483 //This is likely trying to reassoc to different profile
6484 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
6485 //make a copy of the profile
6486 status = csrRoamCopyProfile(pMac, &pCommand->u.roamCmd.roamProfile, pProfile);
6487 pCommand->u.roamCmd.fUpdateCurRoamProfile = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006488 }
6489 else
6490 {
6491 status = csrRoamCopyConnectedProfile(pMac, sessionId, &pCommand->u.roamCmd.roamProfile);
6492 //how to update WPA/WPA2 info in roamProfile??
6493 pCommand->u.roamCmd.roamProfile.uapsd_mask = pMmodProfileFields->uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -07006494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006495 if(HAL_STATUS_SUCCESS(status))
6496 {
6497 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_TRUE;
6498 }
6499 pCommand->command = eSmeCommandRoam;
6500 pCommand->sessionId = (tANI_U8)sessionId;
6501 pCommand->u.roamCmd.roamId = roamId;
6502 pCommand->u.roamCmd.roamReason = reason;
6503 //We need to free the BssList when the command is done
6504 //For reassoc there is no BSS list, so the boolean set to false
6505 pCommand->u.roamCmd.hBSSList = CSR_INVALID_SCANRESULT_HANDLE;
6506 pCommand->u.roamCmd.fReleaseBssList = eANI_BOOLEAN_FALSE;
6507 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006508 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
6509 if( !HAL_STATUS_SUCCESS( status ) )
6510 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006511 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07006512 csrRoamCompletion(pMac, sessionId, NULL, pCommand, eCSR_ROAM_RESULT_FAILURE, eANI_BOOLEAN_FALSE);
6513 csrReleaseCommandRoam( pMac, pCommand );
6514 }
6515 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006516 return (status);
6517}
6518
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006519eHalStatus csrRoamEnqueuePreauth(tpAniSirGlobal pMac, tANI_U32 sessionId, tpSirBssDescription pBssDescription,
6520 eCsrRoamReason reason, tANI_BOOLEAN fImmediate)
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +05306521// , eCsrRoamReason reason, tANI_U32 roamId, tANI_BOOLEAN fImediate)
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006522{
6523 eHalStatus status = eHAL_STATUS_SUCCESS;
6524 tSmeCmd *pCommand;
6525
6526 pCommand = csrGetCommandBuffer(pMac);
6527 if(NULL == pCommand)
6528 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006529 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006530 status = eHAL_STATUS_RESOURCES;
6531 }
6532 else
6533 {
6534 if(pBssDescription)
6535 {
6536 //copy over the parameters we need later
6537 pCommand->command = eSmeCommandRoam;
6538 pCommand->sessionId = (tANI_U8)sessionId;
6539 pCommand->u.roamCmd.roamReason = reason;
6540 //this is the important parameter
6541 //in this case we are using this field for the "next" BSS
6542 pCommand->u.roamCmd.pLastRoamBss = pBssDescription;
6543 status = csrQueueSmeCommand(pMac, pCommand, fImmediate);
6544 if( !HAL_STATUS_SUCCESS( status ) )
6545 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006546 smsLog( pMac, LOGE, FL(" fail to enqueue preauth command, status = %d"), status );
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006547 csrReleaseCommandPreauth( pMac, pCommand );
6548 }
6549 }
6550 else
6551 {
6552 //Return failure
6553 status = eHAL_STATUS_RESOURCES;
6554 }
6555 }
6556 return (status);
6557}
6558
6559eHalStatus csrRoamDequeuePreauth(tpAniSirGlobal pMac)
6560{
6561 tListElem *pEntry;
6562 tSmeCmd *pCommand;
6563 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
6564 if ( pEntry )
6565 {
6566 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
6567 if ( (eSmeCommandRoam == pCommand->command) &&
6568 (eCsrPerformPreauth == pCommand->u.roamCmd.roamReason))
6569 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08006570 smsLog( pMac, LOG1, FL("DQ-Command = %d, Reason = %d"),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006571 pCommand->command, pCommand->u.roamCmd.roamReason);
6572 if (csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK )) {
6573 csrReleaseCommandPreauth( pMac, pCommand );
6574 }
6575 } else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006576 smsLog( pMac, LOGE, FL("Command = %d, Reason = %d "),
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006577 pCommand->command, pCommand->u.roamCmd.roamReason);
6578 }
6579 }
6580 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006581 smsLog( pMac, LOGE, FL("pEntry NULL for eWNI_SME_FT_PRE_AUTH_RSP"));
Madan Mohan Koyyalamudi286b60e2012-10-11 12:59:07 -07006582 }
6583 smeProcessPendingQueue( pMac );
6584 return eHAL_STATUS_SUCCESS;
6585}
6586
Jeff Johnson295189b2012-06-20 16:38:30 -07006587eHalStatus csrRoamConnectWithBSSList(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6588 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6589{
6590 eHalStatus status = eHAL_STATUS_FAILURE;
6591 tScanResultHandle hBSSList;
6592 tANI_U32 roamId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006593 status = csrScanCopyResultList(pMac, hBssListIn, &hBSSList);
6594 if(HAL_STATUS_SUCCESS(status))
6595 {
6596 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6597 if(pRoamId)
6598 {
6599 *pRoamId = roamId;
6600 }
6601 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6602 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6603 if(!HAL_STATUS_SUCCESS(status))
6604 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006605 smsLog(pMac, LOGE, FL("failed to start a join process"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006606 csrScanResultPurge(pMac, hBSSList);
6607 }
6608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006609 return (status);
6610}
6611
Jeff Johnson295189b2012-06-20 16:38:30 -07006612eHalStatus csrRoamConnect(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6613 tScanResultHandle hBssListIn, tANI_U32 *pRoamId)
6614{
6615 eHalStatus status = eHAL_STATUS_SUCCESS;
6616 tScanResultHandle hBSSList;
6617 tCsrScanResultFilter *pScanFilter;
6618 tANI_U32 roamId = 0;
6619 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_FALSE;
6620 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006621 if (NULL == pProfile)
6622 {
6623 smsLog(pMac, LOGP, FL("No profile specified"));
6624 return eHAL_STATUS_FAILURE;
6625 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306626 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6627 "encryType = %d"),
6628 lim_BssTypetoString(pProfile->BSSType),
6629 pProfile->BSSType,
6630 pProfile->AuthType.authType[0],
6631 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006632 if( CSR_IS_WDS( pProfile ) &&
6633 !HAL_STATUS_SUCCESS( status = csrIsBTAMPAllowed( pMac, pProfile->operationChannel ) ) )
6634 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006635 smsLog(pMac, LOGE, FL("Request for BT AMP connection failed, channel requested is different than infra = %d"),
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006636 pProfile->operationChannel);
Jeff Johnson295189b2012-06-20 16:38:30 -07006637 return status;
6638 }
6639 csrRoamCancelRoaming(pMac, sessionId);
6640 csrScanRemoveFreshScanCommand(pMac, sessionId);
6641 csrScanCancelIdleScan(pMac);
6642 //Only abort the scan if it is not used for other roam/connect purpose
Srinivas, Dasari138af4f2014-02-07 11:13:45 +05306643 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306644
6645 if (!vos_concurrent_open_sessions_running() &&
6646 (VOS_STA_SAP_MODE == pProfile->csrPersona))
Jeff Johnson295189b2012-06-20 16:38:30 -07006647 {
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306648 /* In case of AP mode we do not want idle mode scan */
Jeff Johnson295189b2012-06-20 16:38:30 -07006649 csrScanDisable(pMac);
6650 }
Agarwal Ashish5974ed32014-06-16 16:59:54 +05306651
Jeff Johnson295189b2012-06-20 16:38:30 -07006652 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6653 //Check whether ssid changes
6654 if(csrIsConnStateConnected(pMac, sessionId))
6655 {
6656 if(pProfile->SSIDs.numOfSSIDs && !csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6657 {
6658 csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6659 }
6660 }
6661#ifdef FEATURE_WLAN_BTAMP_UT_RF
6662 pSession->maxRetryCount = CSR_JOIN_MAX_RETRY_COUNT;
6663#endif
6664 if(CSR_INVALID_SCANRESULT_HANDLE != hBssListIn)
6665 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006666 smsLog(pMac, LOG1, FL("is called with BSSList"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006667 status = csrRoamConnectWithBSSList(pMac, sessionId, pProfile, hBssListIn, pRoamId);
6668 if(pRoamId)
6669 {
6670 roamId = *pRoamId;
6671 }
6672 if(!HAL_STATUS_SUCCESS(status))
6673 {
6674 fCallCallback = eANI_BOOLEAN_TRUE;
6675 }
6676 }
6677 else
6678 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306679 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6680 if ( NULL == pScanFilter )
6681 status = eHAL_STATUS_FAILURE;
6682 else
6683 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006684 if(HAL_STATUS_SUCCESS(status))
6685 {
Kiet Lam64c1b492013-07-12 13:56:44 +05306686 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006687 //Try to connect to any BSS
6688 if(NULL == pProfile)
6689 {
6690 //No encryption
6691 pScanFilter->EncryptionType.numEntries = 1;
6692 pScanFilter->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_NONE;
6693 }//we don't have a profile
6694 else
6695 {
6696 //Here is the profile we need to connect to
6697 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6698 }//We have a profile
6699 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6700 if(pRoamId)
6701 {
6702 *pRoamId = roamId;
6703 }
6704
6705 if(HAL_STATUS_SUCCESS(status))
6706 {
6707 /*Save the WPS info*/
6708 if(NULL != pProfile)
6709 {
6710 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006711 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07006712 }
6713 else
6714 {
6715 pScanFilter->bWPSAssociation = 0;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -07006716 pScanFilter->bOSENAssociation = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07006717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006718 do
6719 {
6720 if( (pProfile && CSR_IS_WDS_AP( pProfile ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07006721 || (pProfile && CSR_IS_INFRA_AP ( pProfile ))
Jeff Johnson295189b2012-06-20 16:38:30 -07006722 )
6723 {
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006724 //This can be started right away
Jeff Johnson295189b2012-06-20 16:38:30 -07006725 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6726 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6727 if(!HAL_STATUS_SUCCESS(status))
6728 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006729 smsLog(pMac, LOGE, FL(" CSR failed to issue start BSS command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006730 fCallCallback = eANI_BOOLEAN_TRUE;
6731 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006732 else
6733 {
6734 smsLog(pMac, LOG1, FL("Connect request to proceed for AMP/SoftAP mode"));
6735 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006736 break;
6737 }
6738 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006739 smsLog(pMac, LOG1, "************ csrScanGetResult Status ********* %d", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006740 if(HAL_STATUS_SUCCESS(status))
6741 {
Jeff Johnson295189b2012-06-20 16:38:30 -07006742 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6743 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6744 if(!HAL_STATUS_SUCCESS(status))
6745 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006746 smsLog(pMac, LOGE, FL(" CSR failed to issue connect command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006747 csrScanResultPurge(pMac, hBSSList);
6748 fCallCallback = eANI_BOOLEAN_TRUE;
6749 }
6750 }//Have scan result
6751 else if(NULL != pProfile)
6752 {
6753 //Check whether it is for start ibss
6754 if(CSR_IS_START_IBSS(pProfile))
6755 {
6756 status = csrRoamIssueConnect(pMac, sessionId, pProfile, NULL, eCsrHddIssued,
6757 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6758 if(!HAL_STATUS_SUCCESS(status))
6759 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006760 smsLog(pMac, LOGE, " CSR failed to issue startIBSS command with status = 0x%08X", status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006761 fCallCallback = eANI_BOOLEAN_TRUE;
6762 }
6763 }
6764 else
6765 {
6766 //scan for this SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006767 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006768 if(!HAL_STATUS_SUCCESS(status))
6769 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006770 smsLog(pMac, LOGE, FL(" CSR failed to issue SSID scan command with status = 0x%08X"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -07006771 fCallCallback = eANI_BOOLEAN_TRUE;
6772 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08006773 else
6774 {
6775 smsLog(pMac, LOG1, FL("SSID scan requested for Infra connect req"));
6776 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006777 }
6778 }
6779 else
6780 {
6781 fCallCallback = eANI_BOOLEAN_TRUE;
6782 }
6783 } while (0);
6784 if(NULL != pProfile)
6785 {
6786 //we need to free memory for filter if profile exists
6787 csrFreeScanFilter(pMac, pScanFilter);
6788 }
6789 }//Got the scan filter from profile
6790
Kiet Lam64c1b492013-07-12 13:56:44 +05306791 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006792 }//allocated memory for pScanFilter
6793 }//No Bsslist coming in
6794 //tell the caller if we fail to trigger a join request
6795 if( fCallCallback )
6796 {
6797 csrRoamCallCallback(pMac, sessionId, NULL, roamId, eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6798 }
6799
6800 return (status);
6801}
Jeff Johnson295189b2012-06-20 16:38:30 -07006802eHalStatus csrRoamReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
6803 tCsrRoamModifyProfileFields modProfileFields,
6804 tANI_U32 *pRoamId)
6805{
6806 eHalStatus status = eHAL_STATUS_SUCCESS;
6807 tANI_BOOLEAN fCallCallback = eANI_BOOLEAN_TRUE;
6808 tANI_U32 roamId = 0;
6809 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07006810 if (NULL == pProfile)
6811 {
6812 smsLog(pMac, LOGP, FL("No profile specified"));
6813 return eHAL_STATUS_FAILURE;
6814 }
Sushant Kaushike0d2cce2014-04-10 14:36:07 +05306815 smsLog(pMac, LOG1, FL("called BSSType = %s (%d) authtype = %d "
6816 "encryType = %d"),
6817 lim_BssTypetoString(pProfile->BSSType),
6818 pProfile->BSSType,
6819 pProfile->AuthType.authType[0],
6820 pProfile->EncryptionType.encryptionType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07006821 csrRoamCancelRoaming(pMac, sessionId);
6822 csrScanRemoveFreshScanCommand(pMac, sessionId);
6823 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306824 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006825 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssuedReassocToSameAP);
Jeff Johnson295189b2012-06-20 16:38:30 -07006826 if(csrIsConnStateConnected(pMac, sessionId))
6827 {
6828 if(pProfile)
6829 {
6830 if(pProfile->SSIDs.numOfSSIDs &&
6831 csrIsSsidInList(pMac, &pSession->connectedProfile.SSID, &pProfile->SSIDs))
6832 {
6833 fCallCallback = eANI_BOOLEAN_FALSE;
6834 }
6835 else
6836 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006837 smsLog(pMac, LOG1, FL("Not connected to the same SSID asked in the profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006838 }
6839 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306840 else if (!vos_mem_compare(&modProfileFields,
6841 &pSession->connectedProfile.modifyProfileFields,
6842 sizeof(tCsrRoamModifyProfileFields)))
Jeff Johnson295189b2012-06-20 16:38:30 -07006843 {
6844 fCallCallback = eANI_BOOLEAN_FALSE;
6845 }
6846 else
6847 {
6848 smsLog(pMac, LOG1, FL("Either the profile is NULL or none of the fields "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006849 "in tCsrRoamModifyProfileFields got modified"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006850 }
6851 }
6852 else
6853 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006854 smsLog(pMac, LOG1, FL("Not connected! No need to reassoc"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006855 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006856 if(!fCallCallback)
6857 {
6858 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6859 if(pRoamId)
6860 {
6861 *pRoamId = roamId;
6862 }
6863
Jeff Johnson295189b2012-06-20 16:38:30 -07006864 status = csrRoamIssueReassoc(pMac, sessionId, pProfile, &modProfileFields,
6865 eCsrHddIssuedReassocToSameAP, roamId, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006866 }
6867 else
6868 {
6869 status = csrRoamCallCallback(pMac, sessionId, NULL, roamId,
6870 eCSR_ROAM_FAILED, eCSR_ROAM_RESULT_FAILURE);
6871 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006872 return status;
6873}
Jeff Johnson295189b2012-06-20 16:38:30 -07006874eHalStatus csrRoamJoinLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6875{
6876 eHalStatus status = eHAL_STATUS_FAILURE;
6877 tScanResultHandle hBSSList = NULL;
6878 tCsrScanResultFilter *pScanFilter = NULL;
6879 tANI_U32 roamId;
6880 tCsrRoamProfile *pProfile = NULL;
6881 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07006882
6883 if(!pSession)
6884 {
6885 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
6886 return eHAL_STATUS_FAILURE;
6887 }
6888
Jeff Johnson295189b2012-06-20 16:38:30 -07006889 do
6890 {
6891 if(pSession->pCurRoamProfile)
6892 {
6893 csrScanCancelIdleScan(pMac);
Madan Mohan Koyyalamudiff3a7152013-06-13 14:47:55 +05306894 csrScanAbortMacScanNotForConnect(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07006895 //We have to make a copy of pCurRoamProfile because it will be free inside csrRoamIssueConnect
Kiet Lam64c1b492013-07-12 13:56:44 +05306896 pProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
6897 if ( NULL == pProfile )
6898 status = eHAL_STATUS_FAILURE;
6899 else
6900 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07006901 if(!HAL_STATUS_SUCCESS(status))
6902 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306903 vos_mem_set(pProfile, sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006904 status = csrRoamCopyProfile(pMac, pProfile, pSession->pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306905 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07006906 break;
Kiet Lam64c1b492013-07-12 13:56:44 +05306907 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
6908 if ( NULL == pScanFilter )
6909 status = eHAL_STATUS_FAILURE;
6910 else
6911 status = eHAL_STATUS_SUCCESS;
6912
Jeff Johnson295189b2012-06-20 16:38:30 -07006913 if(!HAL_STATUS_SUCCESS(status))
6914 {
6915 break;
6916 }
Kiet Lam64c1b492013-07-12 13:56:44 +05306917 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07006918 status = csrRoamPrepareFilterFromProfile(pMac, pProfile, pScanFilter);
6919 if(!HAL_STATUS_SUCCESS(status))
6920 {
6921 break;
6922 }
6923 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
6924 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
6925 if(HAL_STATUS_SUCCESS(status))
6926 {
6927 //we want to put the last connected BSS to the very beginning, if possible
6928 csrMoveBssToHeadFromBSSID(pMac, &pSession->connectedProfile.bssid, hBSSList);
6929 status = csrRoamIssueConnect(pMac, sessionId, pProfile, hBSSList, eCsrHddIssued,
6930 roamId, eANI_BOOLEAN_FALSE, eANI_BOOLEAN_FALSE);
6931 if(!HAL_STATUS_SUCCESS(status))
6932 {
6933 csrScanResultPurge(pMac, hBSSList);
6934 break;
6935 }
6936 }
6937 else
6938 {
6939 //Do a scan on this profile
6940 //scan for this SSID only in case the AP suppresses SSID
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -07006941 status = csrScanForSSID(pMac, sessionId, pProfile, roamId, TRUE);
Jeff Johnson295189b2012-06-20 16:38:30 -07006942 if(!HAL_STATUS_SUCCESS(status))
6943 {
6944 break;
6945 }
6946 }
6947 }//We have a profile
6948 else
6949 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006950 smsLog(pMac, LOGW, FL("cannot find a roaming profile"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006951 break;
6952 }
6953 }while(0);
6954 if(pScanFilter)
6955 {
6956 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05306957 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -07006958 }
6959 if(NULL != pProfile)
6960 {
6961 csrReleaseProfile(pMac, pProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05306962 vos_mem_free(pProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07006963 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006964 return (status);
6965}
Jeff Johnson295189b2012-06-20 16:38:30 -07006966eHalStatus csrRoamReconnect(tpAniSirGlobal pMac, tANI_U32 sessionId)
6967{
6968 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07006969 if(csrIsConnStateConnected(pMac, sessionId))
6970 {
6971 status = csrRoamIssueDisassociateCmd(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
6972 if(HAL_STATUS_SUCCESS(status))
6973 {
6974 status = csrRoamJoinLastProfile(pMac, sessionId);
6975 }
6976 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006977 return (status);
6978}
6979
Jeff Johnson295189b2012-06-20 16:38:30 -07006980eHalStatus csrRoamConnectToLastProfile(tpAniSirGlobal pMac, tANI_U32 sessionId)
6981{
6982 eHalStatus status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08006983 smsLog(pMac, LOGW, FL("is called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07006984 csrRoamCancelRoaming(pMac, sessionId);
6985 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrHddIssued);
6986 if(csrIsConnStateDisconnected(pMac, sessionId))
6987 {
6988 status = csrRoamJoinLastProfile(pMac, sessionId);
6989 }
Jeff Johnson295189b2012-06-20 16:38:30 -07006990 return (status);
6991}
6992
Jeff Johnson295189b2012-06-20 16:38:30 -07006993eHalStatus csrRoamProcessDisassocDeauth( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fDisassoc, tANI_BOOLEAN fMICFailure )
6994{
6995 eHalStatus status = eHAL_STATUS_SUCCESS;
6996 tANI_BOOLEAN fComplete = eANI_BOOLEAN_FALSE;
6997 eCsrRoamSubState NewSubstate;
6998 tANI_U32 sessionId = pCommand->sessionId;
Abhishek Singhf4669da2014-05-26 15:07:49 +05306999
7000 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7001 {
7002 smsLog(pMac, LOG1, FL(" Stop Wait for key timer and change substate to"
7003 " eCSR_ROAM_SUBSTATE_NONE"));
7004 csrRoamStopWaitForKeyTimer( pMac );
7005 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7006 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007007 // change state to 'Roaming'...
7008 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId );
7009
7010 if ( csrIsConnStateIbss( pMac, sessionId ) )
7011 {
7012 // If we are in an IBSS, then stop the IBSS...
7013 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7014 fComplete = (!HAL_STATUS_SUCCESS(status));
7015 }
7016 else if ( csrIsConnStateInfra( pMac, sessionId ) )
7017 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007018 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 -07007019 pMac->roam.ucACWeights[2], pMac->roam.ucACWeights[3]);
7020 //Restore AC weight in case we change it
7021 WLANTL_SetACWeights(pMac->roam.gVosContext, pMac->roam.ucACWeights);
7022 // in Infrasturcture, we need to disassociate from the Infrastructure network...
7023 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_FORCED;
7024 if(eCsrSmeIssuedDisassocForHandoff == pCommand->u.roamCmd.roamReason)
7025 {
7026 NewSubstate = eCSR_ROAM_SUBSTATE_DISASSOC_HANDOFF;
7027 }
Abhishek Singhcf4590b2014-04-16 18:58:08 +05307028 else
7029 {
7030 // If we are in neighbor preauth done state then on receiving
7031 // disassoc or deauth we dont roam instead we just disassoc
7032 // from current ap and then go to disconnected state
7033 // This happens for ESE and 11r FT connections ONLY.
7034#ifdef WLAN_FEATURE_VOWIFI_11R
7035 if (csrRoamIs11rAssoc(pMac) &&
7036 (csrNeighborRoamStatePreauthDone(pMac)))
7037 {
7038 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7039 }
7040#endif
7041#ifdef FEATURE_WLAN_ESE
7042 if (csrRoamIsESEAssoc(pMac) &&
7043 (csrNeighborRoamStatePreauthDone(pMac)))
7044 {
7045 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7046 }
7047#endif
7048#ifdef FEATURE_WLAN_LFR
7049 if (csrRoamIsFastRoamEnabled(pMac, sessionId) &&
7050 (csrNeighborRoamStatePreauthDone(pMac)))
7051 {
7052 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
7053 }
7054#endif
7055 }
7056
Jeff Johnson295189b2012-06-20 16:38:30 -07007057 if( fDisassoc )
7058 {
7059 status = csrRoamIssueDisassociate( pMac, sessionId, NewSubstate, fMICFailure );
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05307060#ifdef DEBUG_ROAM_DELAY
7061 vos_record_roam_event(e_SME_DISASSOC_ISSUE, NULL, 0);
7062#endif /* DEBUG_ROAM_DELAY */
Jeff Johnson295189b2012-06-20 16:38:30 -07007063 }
7064 else
7065 {
7066 status = csrRoamIssueDeauth( pMac, sessionId, eCSR_ROAM_SUBSTATE_DEAUTH_REQ );
7067 }
7068 fComplete = (!HAL_STATUS_SUCCESS(status));
7069 }
7070 else if ( csrIsConnStateWds( pMac, sessionId ) )
7071 {
7072 if( CSR_IS_WDS_AP( &pMac->roam.roamSession[sessionId].connectedProfile ) )
7073 {
7074 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
7075 fComplete = (!HAL_STATUS_SUCCESS(status));
7076 }
7077 //This has to be WDS station
7078 else if( csrIsConnStateConnectedWds( pMac, sessionId ) ) //This has to be WDS station
7079 {
7080
7081 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7082 if( fDisassoc )
7083 {
7084 status = csrRoamIssueDisassociate( pMac, sessionId,
7085 eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, fMICFailure );
7086 fComplete = (!HAL_STATUS_SUCCESS(status));
7087 }
7088 }
7089 } else {
7090 // we got a dis-assoc request while not connected to any peer
7091 // just complete the command
7092 fComplete = eANI_BOOLEAN_TRUE;
7093 status = eHAL_STATUS_FAILURE;
7094 }
7095 if(fComplete)
7096 {
7097 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7098 }
7099
7100 if(HAL_STATUS_SUCCESS(status))
7101 {
7102 if ( csrIsConnStateInfra( pMac, sessionId ) )
7103 {
7104 //Set the state to disconnect here
7105 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
7106 }
7107 }
Gopichand Nakkala9b89a732012-12-31 16:31:46 -08007108 else
7109 {
7110 smsLog(pMac, LOGW, FL(" failed with status %d"), status);
7111 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007112 return (status);
7113}
7114
Jeff Johnson295189b2012-06-20 16:38:30 -07007115/* This is been removed from latest code base */
7116/*
7117static eHalStatus csrRoamProcessStopBss( tpAniSirGlobal pMac, tSmeCmd *pCommand )
7118{
7119 eHalStatus status;
7120 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07007121 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING );
7122 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007123 return ( status );
7124}
7125*/
7126
Jeff Johnson295189b2012-06-20 16:38:30 -07007127eHalStatus csrRoamIssueDisassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason )
7128{
7129 eHalStatus status = eHAL_STATUS_SUCCESS;
7130 tSmeCmd *pCommand;
7131 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007132 do
7133 {
Varun Reddy Yeturuf68abd62013-02-11 14:05:06 -08007134 smsLog( pMac, LOG1, FL(" reason = %d"), reason );
Jeff Johnson295189b2012-06-20 16:38:30 -07007135 pCommand = csrGetCommandBuffer( pMac );
7136 if ( !pCommand )
7137 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007138 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007139 status = eHAL_STATUS_RESOURCES;
7140 break;
7141 }
7142 //Change the substate in case it is wait-for-key
7143 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7144 {
7145 csrRoamStopWaitForKeyTimer( pMac );
7146 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7147 }
7148 pCommand->command = eSmeCommandRoam;
7149 pCommand->sessionId = (tANI_U8)sessionId;
7150 switch ( reason )
7151 {
7152 case eCSR_DISCONNECT_REASON_MIC_ERROR:
7153 pCommand->u.roamCmd.roamReason = eCsrForcedDisassocMICFailure;
7154 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007155 case eCSR_DISCONNECT_REASON_DEAUTH:
7156 pCommand->u.roamCmd.roamReason = eCsrForcedDeauth;
7157 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007158 case eCSR_DISCONNECT_REASON_HANDOFF:
7159 fHighPriority = eANI_BOOLEAN_TRUE;
7160 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedDisassocForHandoff;
7161 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007162 case eCSR_DISCONNECT_REASON_UNSPECIFIED:
7163 case eCSR_DISCONNECT_REASON_DISASSOC:
7164 pCommand->u.roamCmd.roamReason = eCsrForcedDisassoc;
7165 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007166 case eCSR_DISCONNECT_REASON_IBSS_JOIN_FAILURE:
7167 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedIbssJoinFailure;
7168 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007169 case eCSR_DISCONNECT_REASON_IBSS_LEAVE:
7170 pCommand->u.roamCmd.roamReason = eCsrForcedIbssLeave;
7171 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07007172 default:
7173 break;
7174 }
7175 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7176 if( !HAL_STATUS_SUCCESS( status ) )
7177 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007178 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007179 csrReleaseCommandRoam( pMac, pCommand );
7180 }
7181 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07007182 return( status );
7183}
7184
Jeff Johnson295189b2012-06-20 16:38:30 -07007185eHalStatus csrRoamIssueStopBssCmd( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN fHighPriority )
7186{
7187 eHalStatus status = eHAL_STATUS_SUCCESS;
7188 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007189 pCommand = csrGetCommandBuffer( pMac );
7190 if ( NULL != pCommand )
7191 {
7192 //Change the substate in case it is wait-for-key
7193 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
7194 {
7195 csrRoamStopWaitForKeyTimer( pMac );
7196 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
7197 }
7198 pCommand->command = eSmeCommandRoam;
7199 pCommand->sessionId = (tANI_U8)sessionId;
7200 pCommand->u.roamCmd.roamReason = eCsrStopBss;
7201 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7202 if( !HAL_STATUS_SUCCESS( status ) )
7203 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007204 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007205 csrReleaseCommandRoam( pMac, pCommand );
7206 }
7207 }
7208 else
7209 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007210 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007211 status = eHAL_STATUS_RESOURCES;
7212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007213 return ( status );
7214}
7215
Jeff Johnson295189b2012-06-20 16:38:30 -07007216eHalStatus csrRoamDisconnectInternal(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7217{
7218 eHalStatus status = eHAL_STATUS_SUCCESS;
7219 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007220
7221 if(!pSession)
7222 {
7223 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7224 return eHAL_STATUS_FAILURE;
7225 }
7226
Jeff Johnson295189b2012-06-20 16:38:30 -07007227#ifdef FEATURE_WLAN_BTAMP_UT_RF
7228 //Stop te retry
7229 pSession->maxRetryCount = 0;
7230 csrRoamStopJoinRetryTimer(pMac, sessionId);
7231#endif
7232 //Not to call cancel roaming here
7233 //Only issue disconnect when necessary
7234 if(csrIsConnStateConnected(pMac, sessionId) || csrIsBssTypeIBSS(pSession->connectedProfile.BSSType)
7235 || csrIsBssTypeWDS(pSession->connectedProfile.BSSType)
7236 || csrIsRoamCommandWaitingForSession(pMac, sessionId) )
7237
7238 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007239 smsLog(pMac, LOG2, FL("called"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007240 status = csrRoamIssueDisassociateCmd(pMac, sessionId, reason);
7241 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307242 else
7243 {
Abhishek Singhdc2bfd42014-06-19 17:59:05 +05307244 csrScanAbortScanForSSID(pMac, sessionId);
7245 status = eHAL_STATUS_CMD_NOT_QUEUED;
7246 smsLog( pMac, LOG1, FL(" Disconnect cmd not queued, Roam command is not present"
7247 " return with status %d"), status);
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307248 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007249 return (status);
7250}
7251
Jeff Johnson295189b2012-06-20 16:38:30 -07007252eHalStatus csrRoamDisconnect(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamDisconnectReason reason)
7253{
7254 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007255
7256 if(!pSession)
7257 {
7258 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7259 return eHAL_STATUS_FAILURE;
7260 }
7261
Jeff Johnson295189b2012-06-20 16:38:30 -07007262 csrRoamCancelRoaming(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007263 csrRoamRemoveDuplicateCommand(pMac, sessionId, NULL, eCsrForcedDisassoc);
7264
7265 return (csrRoamDisconnectInternal(pMac, sessionId, reason));
7266}
7267
Jeff Johnson295189b2012-06-20 16:38:30 -07007268eHalStatus csrRoamSaveConnectedInfomation(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
7269 tSirBssDescription *pSirBssDesc, tDot11fBeaconIEs *pIes)
7270{
7271 eHalStatus status = eHAL_STATUS_SUCCESS;
7272 tDot11fBeaconIEs *pIesTemp = pIes;
7273 tANI_U8 index;
7274 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
7275 tCsrRoamConnectedProfile *pConnectProfile = &pSession->connectedProfile;
Jeff Johnson32d95a32012-09-10 13:15:23 -07007276
7277 if(!pSession)
7278 {
7279 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7280 return eHAL_STATUS_FAILURE;
7281 }
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007282 if(pConnectProfile->pAddIEAssoc)
7283 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307284 vos_mem_free(pConnectProfile->pAddIEAssoc);
Madan Mohan Koyyalamudid02b5942013-07-19 18:35:59 +08007285 pConnectProfile->pAddIEAssoc = NULL;
7286 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307287 vos_mem_set(&pSession->connectedProfile, sizeof(tCsrRoamConnectedProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007288 pConnectProfile->AuthType = pProfile->negotiatedAuthType;
7289 pConnectProfile->AuthInfo = pProfile->AuthType;
7290 pConnectProfile->CBMode = pProfile->CBMode; //*** this may not be valid
7291 pConnectProfile->EncryptionType = pProfile->negotiatedUCEncryptionType;
7292 pConnectProfile->EncryptionInfo = pProfile->EncryptionType;
7293 pConnectProfile->mcEncryptionType = pProfile->negotiatedMCEncryptionType;
7294 pConnectProfile->mcEncryptionInfo = pProfile->mcEncryptionType;
7295 pConnectProfile->BSSType = pProfile->BSSType;
7296 pConnectProfile->modifyProfileFields.uapsd_mask = pProfile->uapsd_mask;
7297 pConnectProfile->operationChannel = pSirBssDesc->channelId;
Jeff Johnsone7245742012-09-05 17:12:55 -07007298 pConnectProfile->beaconInterval = pSirBssDesc->beaconInterval;
AnjaneeDevi Kapparapu4b043912014-02-18 13:22:35 +05307299 if (!pConnectProfile->beaconInterval)
7300 {
7301 smsLog(pMac, LOGW, FL("ERROR: Beacon interval is ZERO"));
7302 }
Kiet Lam64c1b492013-07-12 13:56:44 +05307303 vos_mem_copy(&pConnectProfile->Keys, &pProfile->Keys, sizeof(tCsrKeys));
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007304 /* saving the addional IE`s like Hot spot indication element and extended capabilities */
7305 if(pProfile->nAddIEAssocLength)
7306 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307307 pConnectProfile->pAddIEAssoc = vos_mem_malloc(pProfile->nAddIEAssocLength);
7308 if ( NULL == pConnectProfile->pAddIEAssoc )
7309 status = eHAL_STATUS_FAILURE;
7310 else
7311 status = eHAL_STATUS_SUCCESS;
7312 if (!HAL_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007313 {
7314 smsLog(pMac, LOGE, FL("Failed to allocate memory for additional IEs")) ;
7315 return eHAL_STATUS_FAILURE;
7316 }
7317 pConnectProfile->nAddIEAssocLength = pProfile->nAddIEAssocLength;
Kiet Lam64c1b492013-07-12 13:56:44 +05307318 vos_mem_copy(pConnectProfile->pAddIEAssoc, pProfile->pAddIEAssoc,
7319 pProfile->nAddIEAssocLength);
Madan Mohan Koyyalamudiea22cdc2012-10-18 21:02:23 -07007320 }
7321
Jeff Johnson295189b2012-06-20 16:38:30 -07007322 //Save bssid
7323 csrGetBssIdBssDesc(pMac, pSirBssDesc, &pConnectProfile->bssid);
7324#ifdef WLAN_FEATURE_VOWIFI_11R
7325 if (pSirBssDesc->mdiePresent)
7326 {
7327 pConnectProfile->MDID.mdiePresent = 1;
7328 pConnectProfile->MDID.mobilityDomain = (pSirBssDesc->mdie[1] << 8) | (pSirBssDesc->mdie[0]);
7329 }
7330#endif
Leela Venkata Kiran Kumar Reddy Chiralad48e3272013-04-12 14:21:07 -07007331 if( NULL == pIesTemp )
7332 {
7333 status = csrGetParsedBssDescriptionIEs(pMac, pSirBssDesc, &pIesTemp);
7334 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007335#ifdef FEATURE_WLAN_ESE
7336 if ((csrIsProfileESE(pProfile) ||
7337 ((pIesTemp->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +05307338 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
7339 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
7340 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
7341 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
7342#ifdef WLAN_FEATURE_11W
7343 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
7344#endif
7345 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007346 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -07007347 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007348 pConnectProfile->isESEAssoc = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07007349 }
7350#endif
7351 //save ssid
Jeff Johnson295189b2012-06-20 16:38:30 -07007352 if(HAL_STATUS_SUCCESS(status))
7353 {
7354 if(pIesTemp->SSID.present)
7355 {
7356 pConnectProfile->SSID.length = pIesTemp->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +05307357 vos_mem_copy(pConnectProfile->SSID.ssId, pIesTemp->SSID.ssid,
7358 pIesTemp->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -07007359 }
7360
7361 //Save the bss desc
7362 status = csrRoamSaveConnectedBssDesc(pMac, sessionId, pSirBssDesc);
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307363
7364 if( CSR_IS_QOS_BSS(pIesTemp) || pIesTemp->HTCaps.present)
Jeff Johnson295189b2012-06-20 16:38:30 -07007365 {
Pratik Bhalgatb5b19b02012-11-22 16:28:19 +05307366 //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 -07007367 pConnectProfile->qap = TRUE;
7368 }
7369 else
7370 {
7371 pConnectProfile->qap = FALSE;
7372 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007373 if ( NULL == pIes )
7374 {
7375 //Free memory if it allocated locally
Kiet Lam64c1b492013-07-12 13:56:44 +05307376 vos_mem_free(pIesTemp);
Jeff Johnson295189b2012-06-20 16:38:30 -07007377 }
7378 }
7379 //Save Qos connection
7380 pConnectProfile->qosConnection = pMac->roam.roamSession[sessionId].fWMMConnection;
7381
7382 if(!HAL_STATUS_SUCCESS(status))
7383 {
7384 csrFreeConnectBssDesc(pMac, sessionId);
7385 }
7386 for(index = 0; index < pProfile->SSIDs.numOfSSIDs; index++)
7387 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307388 if ((pProfile->SSIDs.SSIDList[index].SSID.length == pConnectProfile->SSID.length) &&
7389 vos_mem_compare(pProfile->SSIDs.SSIDList[index].SSID.ssId,
7390 pConnectProfile->SSID.ssId,
7391 pConnectProfile->SSID.length))
Jeff Johnson295189b2012-06-20 16:38:30 -07007392 {
7393 pConnectProfile->handoffPermitted = pProfile->SSIDs.SSIDList[index].handoffPermitted;
7394 break;
7395 }
7396 pConnectProfile->handoffPermitted = FALSE;
7397 }
7398
7399 return (status);
7400}
7401
Jeff Johnson295189b2012-06-20 16:38:30 -07007402static void csrRoamJoinRspProcessor( tpAniSirGlobal pMac, tSirSmeJoinRsp *pSmeJoinRsp )
7403{
7404 tListElem *pEntry = NULL;
7405 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007406 //The head of the active list is the request we sent
7407 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7408 if(pEntry)
7409 {
7410 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7411 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007412 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7413 {
7414 if(pCommand && eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason)
7415 {
7416#ifndef WLAN_MDM_CODE_REDUCTION_OPT
7417 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7418#endif
7419 }
7420 csrRoamComplete( pMac, eCsrJoinSuccess, (void *)pSmeJoinRsp );
7421 }
7422 else
7423 {
7424 tANI_U32 roamId = 0;
7425 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pSmeJoinRsp->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007426 if(!pSession)
7427 {
7428 smsLog(pMac, LOGE, FL(" session %d not found "), pSmeJoinRsp->sessionId);
7429 return;
7430 }
7431
Jeff Johnson295189b2012-06-20 16:38:30 -07007432
7433 //The head of the active list is the request we sent
7434 //Try to get back the same profile and roam again
7435 if(pCommand)
7436 {
7437 roamId = pCommand->u.roamCmd.roamId;
7438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007439 pSession->joinFailStatusCode.statusCode = pSmeJoinRsp->statusCode;
7440 pSession->joinFailStatusCode.reasonCode = pSmeJoinRsp->protStatusCode;
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007441 smsLog( pMac, LOGW, "SmeJoinReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007442#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
7443 /* If Join fails while Handoff is in progress, indicate disassociated event to supplicant to reconnect */
7444 if (csrRoamIsHandoffInProgress(pMac))
7445 {
7446 csrRoamCallCallback(pMac, pSmeJoinRsp->sessionId, NULL, roamId, eCSR_ROAM_DISASSOCIATED, eCSR_ROAM_RESULT_FORCED);
7447 /* Should indicate neighbor roam algorithm about the connect failure here */
7448 csrNeighborRoamIndicateConnect(pMac, pSmeJoinRsp->sessionId, VOS_STATUS_E_FAILURE);
7449 }
7450#endif
7451 if (pCommand)
7452 {
7453 if(CSR_IS_WDS_STA( &pCommand->u.roamCmd.roamProfile ))
7454 {
7455 pCommand->u.roamCmd.fStopWds = eANI_BOOLEAN_TRUE;
7456 pSession->connectedProfile.BSSType = eCSR_BSS_TYPE_WDS_STA;
7457 csrRoamReissueRoamCommand(pMac);
7458 }
7459 else if( CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile ) )
7460 {
7461 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7462 }
7463 else
7464 {
7465 csrRoam(pMac, pCommand);
7466 }
7467 }
7468 else
7469 {
7470 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7471 }
7472 } /*else: ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode ) */
7473}
7474
Jeff Johnson295189b2012-06-20 16:38:30 -07007475eHalStatus csrRoamIssueJoin( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7476 tDot11fBeaconIEs *pIes,
7477 tCsrRoamProfile *pProfile, tANI_U32 roamId )
7478{
7479 eHalStatus status;
Arif Hussain24bafea2013-11-15 15:10:03 -08007480 smsLog( pMac, LOG1, "Attempting to Join Bssid= "MAC_ADDRESS_STR,
7481 MAC_ADDR_ARRAY(pSirBssDesc->bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07007482
7483 // Set the roaming substate to 'join attempt'...
7484 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_JOIN_REQ, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007485 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007486 status = csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_JOIN_REQ );
Jeff Johnson295189b2012-06-20 16:38:30 -07007487 return (status);
7488}
7489
Jeff Johnson295189b2012-06-20 16:38:30 -07007490static eHalStatus csrRoamIssueReassociate( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pSirBssDesc,
7491 tDot11fBeaconIEs *pIes, tCsrRoamProfile *pProfile)
7492{
7493 csrRoamStateChange( pMac, eCSR_ROAMING_STATE_JOINING, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07007494 // Set the roaming substate to 'join attempt'...
7495 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_REASSOC_REQ, sessionId );
7496
Kaushik, Sushant8489f472014-01-27 11:41:22 +05307497 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
7498 FL(" calling csrSendJoinReqMsg (eWNI_SME_REASSOC_REQ)"));
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05307499#ifdef DEBUG_ROAM_DELAY
7500 //HACK usign buff len as Auth type
7501 vos_record_roam_event(e_SME_ISSUE_REASSOC_REQ, NULL, pProfile->negotiatedAuthType);
7502 vos_record_roam_event(e_CACHE_ROAM_PEER_MAC, (void *)pSirBssDesc->bssId, 6);
7503#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007504 // attempt to Join this BSS...
Srinivas Girigowdac16730e2013-01-16 13:39:39 -08007505 return csrSendJoinReqMsg( pMac, sessionId, pSirBssDesc, pProfile, pIes, eWNI_SME_REASSOC_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -07007506}
7507
Jeff Johnson295189b2012-06-20 16:38:30 -07007508void csrRoamReissueRoamCommand(tpAniSirGlobal pMac)
7509{
7510 tListElem *pEntry;
7511 tSmeCmd *pCommand;
7512 tCsrRoamInfo roamInfo;
7513 tANI_U32 sessionId;
7514 tCsrRoamSession *pSession;
7515
7516 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7517 if(pEntry)
7518 {
7519 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7520 if ( eSmeCommandRoam == pCommand->command )
7521 {
7522 sessionId = pCommand->sessionId;
7523 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007524
7525 if(!pSession)
7526 {
7527 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7528 return;
7529 }
Abhishek Singhaf15f152013-11-30 16:08:55 +05307530 /* While switching between two AP, csr will reissue roam command again
7531 to the nextbss if it was interrupted by the dissconnect req for the
7532 previous bss.During this csr is incrementing bRefAssocStartCnt twice.
7533 so reset the bRefAssocStartCnt.
7534 */
7535 if(pSession->bRefAssocStartCnt > 0)
7536 {
7537 pSession->bRefAssocStartCnt--;
7538 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007539 if( pCommand->u.roamCmd.fStopWds )
7540 {
Kiet Lam64c1b492013-07-12 13:56:44 +05307541 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07007542 roamInfo.pBssDesc = pCommand->u.roamCmd.pLastRoamBss;
7543 roamInfo.statusCode = pSession->joinFailStatusCode.statusCode;
7544 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07007545 if (CSR_IS_WDS(&pSession->connectedProfile)){
Jeff Johnson295189b2012-06-20 16:38:30 -07007546 pSession->connectState = eCSR_ASSOC_STATE_TYPE_WDS_DISCONNECTED;
7547 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7548 eCSR_ROAM_WDS_IND,
7549 eCSR_ROAM_RESULT_WDS_DISASSOCIATED);
Jeff Johnson295189b2012-06-20 16:38:30 -07007550 }else if (CSR_IS_INFRA_AP(&pSession->connectedProfile)){
7551 pSession->connectState = eCSR_ASSOC_STATE_TYPE_INFRA_DISCONNECTED;
7552 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.roamCmd.roamId,
7553 eCSR_ROAM_INFRA_IND,
7554 eCSR_ROAM_RESULT_INFRA_DISASSOCIATED);
7555 }
7556
Jeff Johnson295189b2012-06-20 16:38:30 -07007557
Jeff Johnson295189b2012-06-20 16:38:30 -07007558 if( !HAL_STATUS_SUCCESS( csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_STOP_BSS_REQ ) ) )
7559 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007560 smsLog(pMac, LOGE, " Failed to reissue stop_bss command for WDS after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007561 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7562 }
7563 }
7564 else if(eCsrStopRoaming == csrRoamJoinNextBss(pMac, pCommand, eANI_BOOLEAN_TRUE))
7565 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007566 smsLog(pMac, LOGW, " Failed to reissue join command after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007567 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7568 }
7569 }
7570 else
7571 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007572 smsLog(pMac, LOGW, " Command is not roaming after disassociated");
Jeff Johnson295189b2012-06-20 16:38:30 -07007573 }
7574 }
7575 else
7576 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007577 smsLog(pMac, LOGE, " Disassoc rsp cannot continue because no command is available");
Jeff Johnson295189b2012-06-20 16:38:30 -07007578 }
7579}
7580
Jeff Johnson295189b2012-06-20 16:38:30 -07007581tANI_BOOLEAN csrIsRoamCommandWaitingForSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
7582{
7583 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7584 tListElem *pEntry;
7585 tSmeCmd *pCommand = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07007586 //alwasy lock active list before locking pending list
7587 csrLLLock( &pMac->sme.smeCmdActiveList );
7588 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7589 if(pEntry)
7590 {
7591 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7592 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7593 {
7594 fRet = eANI_BOOLEAN_TRUE;
7595 }
7596 }
7597 if(eANI_BOOLEAN_FALSE == fRet)
7598 {
7599 csrLLLock(&pMac->sme.smeCmdPendingList);
7600 pEntry = csrLLPeekHead(&pMac->sme.smeCmdPendingList, LL_ACCESS_NOLOCK);
7601 while(pEntry)
7602 {
7603 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7604 if( ( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7605 {
7606 fRet = eANI_BOOLEAN_TRUE;
7607 break;
7608 }
7609 pEntry = csrLLNext(&pMac->sme.smeCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7610 }
7611 csrLLUnlock(&pMac->sme.smeCmdPendingList);
7612 }
Agarwal Ashish8514a4f2014-02-10 15:57:06 +05307613 if (eANI_BOOLEAN_FALSE == fRet)
7614 {
7615 csrLLLock(&pMac->roam.roamCmdPendingList);
7616 pEntry = csrLLPeekHead(&pMac->roam.roamCmdPendingList, LL_ACCESS_NOLOCK);
7617 while (pEntry)
7618 {
7619 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7620 if (( eSmeCommandRoam == pCommand->command ) && ( sessionId == pCommand->sessionId ) )
7621 {
7622 fRet = eANI_BOOLEAN_TRUE;
7623 break;
7624 }
7625 pEntry = csrLLNext(&pMac->roam.roamCmdPendingList, pEntry, LL_ACCESS_NOLOCK);
7626 }
7627 csrLLUnlock(&pMac->roam.roamCmdPendingList);
7628 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007629 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007630 return (fRet);
7631}
7632
Jeff Johnson295189b2012-06-20 16:38:30 -07007633tANI_BOOLEAN csrIsRoamCommandWaiting(tpAniSirGlobal pMac)
7634{
7635 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7636 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -07007637 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
7638 {
7639 if( CSR_IS_SESSION_VALID( pMac, i ) && ( fRet = csrIsRoamCommandWaitingForSession( pMac, i ) ) )
7640 {
7641 break;
7642 }
7643 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007644 return ( fRet );
7645}
7646
Jeff Johnson295189b2012-06-20 16:38:30 -07007647tANI_BOOLEAN csrIsCommandWaiting(tpAniSirGlobal pMac)
7648{
7649 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07007650 //alwasy lock active list before locking pending list
7651 csrLLLock( &pMac->sme.smeCmdActiveList );
7652 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7653 if(eANI_BOOLEAN_FALSE == fRet)
7654 {
7655 fRet = csrLLIsListEmpty(&pMac->sme.smeCmdPendingList, LL_ACCESS_LOCK);
7656 }
7657 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007658 return (fRet);
7659}
7660
Jeff Johnson295189b2012-06-20 16:38:30 -07007661tANI_BOOLEAN csrIsScanForRoamCommandActive( tpAniSirGlobal pMac )
7662{
7663 tANI_BOOLEAN fRet = eANI_BOOLEAN_FALSE;
7664 tListElem *pEntry;
7665 tCsrCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07007666 //alwasy lock active list before locking pending list
7667 csrLLLock( &pMac->sme.smeCmdActiveList );
7668 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_NOLOCK);
7669 if( pEntry )
7670 {
7671 pCommand = GET_BASE_ADDR(pEntry, tCsrCmd, Link);
7672 if( ( eCsrRoamCommandScan == pCommand->command ) &&
7673 ( ( eCsrScanForSsid == pCommand->u.scanCmd.reason ) ||
7674 ( eCsrScanForCapsChange == pCommand->u.scanCmd.reason ) ||
7675 ( eCsrScanP2PFindPeer == pCommand->u.scanCmd.reason ) ) )
7676 {
7677 fRet = eANI_BOOLEAN_TRUE;
7678 }
7679 }
7680 csrLLUnlock( &pMac->sme.smeCmdActiveList );
Jeff Johnson295189b2012-06-20 16:38:30 -07007681 return (fRet);
7682}
Jeff Johnson295189b2012-06-20 16:38:30 -07007683eHalStatus csrRoamIssueReassociateCmd( tpAniSirGlobal pMac, tANI_U32 sessionId )
7684{
7685 eHalStatus status = eHAL_STATUS_SUCCESS;
7686 tSmeCmd *pCommand = NULL;
7687 tANI_BOOLEAN fHighPriority = eANI_BOOLEAN_TRUE;
7688 tANI_BOOLEAN fRemoveCmd = FALSE;
7689 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -07007690 // Delete the old assoc command. All is setup for reassoc to be serialized
7691 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
7692 if ( pEntry )
7693 {
7694 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
7695 if ( !pCommand )
7696 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007697 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007698 return eHAL_STATUS_RESOURCES;
7699 }
7700 if ( eSmeCommandRoam == pCommand->command )
7701 {
7702 if (pCommand->u.roamCmd.roamReason == eCsrSmeIssuedAssocToSimilarAP)
7703 {
7704 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
7705 }
7706 else
7707 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007708 smsLog( pMac, LOGE, FL(" Unexpected active roam command present ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007709 }
7710 if (fRemoveCmd == FALSE)
7711 {
7712 // Implies we did not get the serialized assoc command we
7713 // were expecting
7714 pCommand = NULL;
7715 }
7716 }
7717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007718 if(NULL == pCommand)
7719 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007720 smsLog( pMac, LOGE, FL(" fail to get command buffer as expected based on previous connect roam command") );
Jeff Johnson295189b2012-06-20 16:38:30 -07007721 return eHAL_STATUS_RESOURCES;
7722 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007723 do
7724 {
7725 //Change the substate in case it is wait-for-key
7726 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
7727 {
7728 csrRoamStopWaitForKeyTimer( pMac );
7729 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId );
7730 }
7731 pCommand->command = eSmeCommandRoam;
7732 pCommand->sessionId = (tANI_U8)sessionId;
7733 pCommand->u.roamCmd.roamReason = eCsrSmeIssuedFTReassoc;
Jeff Johnson295189b2012-06-20 16:38:30 -07007734 status = csrQueueSmeCommand(pMac, pCommand, fHighPriority);
7735 if( !HAL_STATUS_SUCCESS( status ) )
7736 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007737 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07007738 csrReleaseCommandRoam( pMac, pCommand );
7739 }
7740 } while( 0 );
7741
Jeff Johnson295189b2012-06-20 16:38:30 -07007742 return( status );
7743}
7744static void csrRoamingStateConfigCnfProcessor( tpAniSirGlobal pMac, tANI_U32 result )
7745{
7746 tListElem *pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
7747 tCsrScanResult *pScanResult = NULL;
7748 tSirBssDescription *pBssDesc = NULL;
7749 tSmeCmd *pCommand = NULL;
7750 tANI_U32 sessionId;
7751 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -07007752 if(NULL == pEntry)
7753 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307754 smsLog(pMac, LOGE, " CFG_CNF with active list empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07007755 return;
7756 }
7757 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
7758 sessionId = pCommand->sessionId;
7759 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07007760
7761 if(!pSession)
7762 {
7763 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
7764 return;
7765 }
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307766 smsLog(pMac, LOG1, FL("CFG return value is %d "
7767 " current state is : %d substate is : %d "),
7768 result, pMac->roam.curState[sessionId],
7769 pMac->roam.curSubState[sessionId]);
Jeff Johnson295189b2012-06-20 16:38:30 -07007770 if(CSR_IS_ROAMING(pSession) && pSession->fCancelRoaming)
7771 {
7772 //the roaming is cancelled. Simply complete the command
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007773 smsLog(pMac, LOGW, FL(" Roam command cancelled"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007774 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7775 }
Venkata Prathyusha Kuntupalli239278b2013-03-26 15:58:18 -07007776 /* If the roaming has stopped, not to continue the roaming command*/
7777 else if ( !CSR_IS_ROAMING(pSession) && CSR_IS_ROAMING_COMMAND(pCommand) )
7778 {
7779 //No need to complete roaming here as it already completes
7780 smsLog(pMac, LOGW, FL(" Roam command (reason %d) aborted due to roaming completed\n"),
7781 pCommand->u.roamCmd.roamReason);
7782 csrSetAbortRoamingCommand( pMac, pCommand );
7783 csrRoamComplete(pMac, eCsrNothingToJoin, NULL);
7784 }
Jeff Johnson295189b2012-06-20 16:38:30 -07007785 else
7786 {
7787 if ( CCM_IS_RESULT_SUCCESS(result) )
7788 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307789 smsLog(pMac, LOG1, "Cfg sequence complete");
Jeff Johnson295189b2012-06-20 16:38:30 -07007790 // Successfully set the configuration parameters for the new Bss. Attempt to
7791 // join the roaming Bss.
7792 if(pCommand->u.roamCmd.pRoamBssEntry)
7793 {
7794 pScanResult = GET_BASE_ADDR(pCommand->u.roamCmd.pRoamBssEntry, tCsrScanResult, Link);
7795 pBssDesc = &pScanResult->Result.BssDescriptor;
7796 }
7797 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) ||
7798 CSR_IS_WDS( &pCommand->u.roamCmd.roamProfile )
Jeff Johnson295189b2012-06-20 16:38:30 -07007799 || CSR_IS_INFRA_AP(&pCommand->u.roamCmd.roamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07007800 )
7801 {
7802 if(!HAL_STATUS_SUCCESS(csrRoamIssueStartBss( pMac, sessionId,
7803 &pSession->bssParams, &pCommand->u.roamCmd.roamProfile,
7804 pBssDesc, pCommand->u.roamCmd.roamId )))
7805 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307806 smsLog(pMac, LOGE, " CSR start BSS failed");
Jeff Johnson295189b2012-06-20 16:38:30 -07007807 //We need to complete the command
7808 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7809 }
7810 }
7811 else
7812 {
7813 if (!pCommand->u.roamCmd.pRoamBssEntry)
7814 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05307815 smsLog(pMac, LOGE, " pRoamBssEntry is NULL");
Jeff Johnson295189b2012-06-20 16:38:30 -07007816 //We need to complete the command
7817 csrRoamComplete(pMac, eCsrJoinFailure, NULL);
7818 return;
7819 }
7820 // If we are roaming TO an Infrastructure BSS...
7821 VOS_ASSERT(pScanResult != NULL);
7822 if ( csrIsInfraBssDesc( pBssDesc ) )
7823 {
7824 tDot11fBeaconIEs *pIesLocal = (tDot11fBeaconIEs *)pScanResult->Result.pvIes;
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307825 smsLog(pMac, LOG1, " Roaming in a Infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007826 if(pIesLocal || (HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIesLocal))) )
7827 {
7828 // ..and currently in an Infrastructure connection....
7829 if( csrIsConnStateConnectedInfra( pMac, sessionId ) )
7830 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307831 smsLog(pMac, LOG1, " Connected to infra BSS");
Jeff Johnson295189b2012-06-20 16:38:30 -07007832 // ...and the SSIDs are equal, then we Reassoc.
7833 if ( csrIsSsidEqual( pMac, pSession->pConnectBssDesc, pBssDesc,
7834 pIesLocal ) )
7835 // ..and currently in an infrastructure connection
7836 {
7837 // then issue a Reassoc.
7838 pCommand->u.roamCmd.fReassoc = eANI_BOOLEAN_TRUE;
7839 csrRoamIssueReassociate( pMac, sessionId, pBssDesc, pIesLocal,
7840 &pCommand->u.roamCmd.roamProfile );
7841 }
7842 else
7843 {
7844
7845 // otherwise, we have to issue a new Join request to LIM because we disassociated from the
7846 // previously associated AP.
7847 if(!HAL_STATUS_SUCCESS(csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7848 pIesLocal,
7849 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId )))
7850 {
7851 //try something else
7852 csrRoam( pMac, pCommand );
7853 }
7854 }
7855 }
7856 else
7857 {
7858 eHalStatus status = eHAL_STATUS_SUCCESS;
7859
7860 /* We need to come with other way to figure out that this is because of HO in BMP
7861 The below API will be only available for Android as it uses a different HO algorithm */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007862 /* Reassoc request will be used only for ESE and 11r handoff whereas other legacy roaming should
Jeff Johnson295189b2012-06-20 16:38:30 -07007863 * use join request */
7864#ifdef WLAN_FEATURE_VOWIFI_11R
7865 if (csrRoamIsHandoffInProgress(pMac) &&
7866 csrRoamIs11rAssoc(pMac))
7867 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307868 smsLog(pMac, LOG1, " HandoffInProgress with 11r enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07007869 status = csrRoamIssueReassociate(pMac, sessionId, pBssDesc,
7870 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ), &pCommand->u.roamCmd.roamProfile);
7871 }
7872 else
7873#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007874#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07007875 if (csrRoamIsHandoffInProgress(pMac) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08007876 csrRoamIsESEAssoc(pMac))
Jeff Johnson295189b2012-06-20 16:38:30 -07007877 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307878 smsLog(pMac, LOG1, " HandoffInProgress with ESE enabled");
Jeff Johnson295189b2012-06-20 16:38:30 -07007879 // Now serialize the reassoc command.
7880 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7881 }
7882 else
7883#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007884#ifdef FEATURE_WLAN_LFR
7885 if (csrRoamIsHandoffInProgress(pMac) &&
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05307886 csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007887 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307888 smsLog(pMac, LOG1, " HandoffInProgress with LFR enabled");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07007889 // Now serialize the reassoc command.
7890 status = csrRoamIssueReassociateCmd(pMac, sessionId);
7891 }
7892 else
7893#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07007894 // else we are not connected and attempting to Join. Issue the
7895 // Join request.
7896 {
Kaushik, Sushant74dbbba2014-05-30 10:31:41 +05307897 smsLog(pMac, LOG1, " Not connected, Attempting to Join");
Jeff Johnson295189b2012-06-20 16:38:30 -07007898 status = csrRoamIssueJoin( pMac, sessionId, pBssDesc,
7899 (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ),
7900 &pCommand->u.roamCmd.roamProfile, pCommand->u.roamCmd.roamId );
7901 }
7902 if(!HAL_STATUS_SUCCESS(status))
7903 {
7904 //try something else
7905 csrRoam( pMac, pCommand );
7906 }
7907 }
7908 if( !pScanResult->Result.pvIes )
7909 {
7910 //Locally allocated
Kiet Lam64c1b492013-07-12 13:56:44 +05307911 vos_mem_free(pIesLocal);
Jeff Johnson295189b2012-06-20 16:38:30 -07007912 }
7913 }
7914 }//if ( csrIsInfraBssDesc( pBssDesc ) )
7915 else
7916 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007917 smsLog(pMac, LOGW, FL(" found BSSType mismatching the one in BSS description"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007918 }
7919 }//else
7920 }//if ( WNI_CFG_SUCCESS == result )
7921 else
7922 {
7923 // In the event the configuration failed, for infra let the roam processor
7924 //attempt to join something else...
7925 if( pCommand->u.roamCmd.pRoamBssEntry && CSR_IS_INFRASTRUCTURE( &pCommand->u.roamCmd.roamProfile ) )
7926 {
7927 csrRoam(pMac, pCommand);
7928 }
7929 else
7930 {
7931 //We need to complete the command
7932 if ( csrIsBssTypeIBSS( pCommand->u.roamCmd.roamProfile.BSSType ) )
7933 {
7934 csrRoamComplete(pMac, eCsrStartBssFailure, NULL);
7935 }
7936 else
7937 {
7938 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
7939 }
7940 }
7941 }
7942 }//we have active entry
7943}
7944
Jeff Johnson295189b2012-06-20 16:38:30 -07007945static void csrRoamRoamingStateAuthRspProcessor( tpAniSirGlobal pMac, tSirSmeAuthRsp *pSmeAuthRsp )
7946{
7947 //No one is sending eWNI_SME_AUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007948 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07007949 if ( eSIR_SME_SUCCESS == pSmeAuthRsp->statusCode )
7950 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007951 smsLog( pMac, LOGW, "CSR SmeAuthReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007952 // Successfully authenticated with a new Bss. Attempt to stop the current Bss and
7953 // join the new one...
7954 /***pBssDesc = profGetRoamingBssDesc( pAdapter, &pHddProfile );
Jeff Johnson295189b2012-06-20 16:38:30 -07007955 roamStopNetwork( pAdapter, &pBssDesc->SirBssDescription );***/
7956 }
7957 else {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007958 smsLog( pMac, LOGW, "CSR SmeAuthReq failed with statusCode= 0x%08X [%d]", pSmeAuthRsp->statusCode, pSmeAuthRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007959 /***profHandleLostLinkAfterReset(pAdapter);
7960 // In the event the authenticate fails, let the roam processor attempt to join something else...
7961 roamRoam( pAdapter );***/
7962 }
7963}
7964
Jeff Johnson295189b2012-06-20 16:38:30 -07007965static void csrRoamRoamingStateReassocRspProcessor( tpAniSirGlobal pMac, tpSirSmeJoinRsp pSmeJoinRsp )
7966{
7967 eCsrRoamCompleteResult result;
7968 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
7969 tCsrRoamInfo roamInfo;
7970 tANI_U32 roamId = 0;
7971
7972 if ( eSIR_SME_SUCCESS == pSmeJoinRsp->statusCode )
7973 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08007974 smsLog( pMac, LOGW, "CSR SmeReassocReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07007975 result = eCsrReassocSuccess;
Jeff Johnson295189b2012-06-20 16:38:30 -07007976 /* Defeaturize this part later if needed */
7977#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
7978 /* Since the neighbor roam algorithm uses reassoc req for handoff instead of join,
7979 * we need the response contents while processing the result in csrRoamProcessResults() */
7980 if (csrRoamIsHandoffInProgress(pMac))
7981 {
7982 /* Need to dig more on indicating events to SME QoS module */
7983 sme_QosCsrEventInd(pMac, pSmeJoinRsp->sessionId, SME_QOS_CSR_HANDOFF_COMPLETE, NULL);
7984 csrRoamComplete( pMac, result, pSmeJoinRsp);
7985 }
7986 else
7987#endif
7988 {
7989 csrRoamComplete( pMac, result, NULL );
7990 }
7991 }
7992 /* Should we handle this similar to handling the join failure? Is it ok
7993 * to call csrRoamComplete() with state as CsrJoinFailure */
7994 else
7995 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07007996 smsLog( pMac, LOGW, "CSR SmeReassocReq failed with statusCode= 0x%08X [%d]", pSmeJoinRsp->statusCode, pSmeJoinRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07007997 result = eCsrReassocFailure;
7998#ifdef WLAN_FEATURE_VOWIFI_11R
7999 if ((eSIR_SME_FT_REASSOC_TIMEOUT_FAILURE == pSmeJoinRsp->statusCode) ||
Mukul Sharmaa052e3d2014-09-08 23:47:06 +05308000 (eSIR_SME_FT_REASSOC_FAILURE == pSmeJoinRsp->statusCode) ||
8001 (eSIR_SME_JOIN_DEAUTH_FROM_AP_DURING_ADD_STA == pSmeJoinRsp->statusCode))
Jeff Johnson295189b2012-06-20 16:38:30 -07008002 {
8003 // Inform HDD to turn off FT flag in HDD
8004 if (pNeighborRoamInfo)
8005 {
8006 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8007 csrRoamCallCallback(pMac, pNeighborRoamInfo->csrSessionId,
8008 &roamInfo, roamId, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
Madan Mohan Koyyalamudi57772162012-10-18 19:46:14 -07008009 /*
8010 * Since the above callback sends a disconnect
8011 * to HDD, we should clean-up our state
8012 * machine as well to be in sync with the upper
8013 * layers. There is no need to send a disassoc
8014 * since: 1) we will never reassoc to the current
8015 * AP in LFR, and 2) there is no need to issue a
8016 * disassoc to the AP with which we were trying
8017 * to reassoc.
8018 */
8019 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8020 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07008021 }
8022 }
8023#endif
8024 // In the event that the Reassociation fails, then we need to Disassociate the current association and keep
8025 // roaming. Note that we will attempt to Join the AP instead of a Reassoc since we may have attempted a
8026 // 'Reassoc to self', which AP's that don't support Reassoc will force a Disassoc.
8027 //The disassoc rsp message will remove the command from active list
8028 if(!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate( pMac, pSmeJoinRsp->sessionId,
8029 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE )))
8030 {
8031 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8032 }
8033 }
8034}
8035
Jeff Johnson295189b2012-06-20 16:38:30 -07008036static void csrRoamRoamingStateStopBssRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSmeRsp)
8037{
Jeff Johnson295189b2012-06-20 16:38:30 -07008038#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8039 {
8040 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07008041 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
8042 if(pIbssLog)
8043 {
8044 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_RSP;
8045 if(eSIR_SME_SUCCESS != pSmeRsp->statusCode)
8046 {
8047 pIbssLog->status = WLAN_IBSS_STATUS_FAILURE;
8048 }
8049 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
8050 }
8051 }
8052#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008053 pMac->roam.roamSession[pSmeRsp->sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8054 if(CSR_IS_ROAM_SUBSTATE_STOP_BSS_REQ( pMac, pSmeRsp->sessionId))
8055 {
8056 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8057 }
8058 else if(CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId))
8059 {
8060 csrRoamReissueRoamCommand(pMac);
8061 }
8062}
8063
Jeff Johnson295189b2012-06-20 16:38:30 -07008064void csrRoamRoamingStateDisassocRspProcessor( tpAniSirGlobal pMac, tSirSmeDisassocRsp *pSmeRsp )
8065{
8066 tSirResultCodes statusCode;
8067#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
8068 tScanResultHandle hBSSList;
8069 tANI_BOOLEAN fCallCallback, fRemoveCmd;
8070 eHalStatus status;
8071 tCsrRoamInfo roamInfo;
8072 tCsrScanResultFilter *pScanFilter = NULL;
8073 tANI_U32 roamId = 0;
8074 tCsrRoamProfile *pCurRoamProfile = NULL;
8075 tListElem *pEntry = NULL;
8076 tSmeCmd *pCommand = NULL;
8077#endif
8078 tANI_U32 sessionId;
8079 tCsrRoamSession *pSession;
Jeff Johnsone7245742012-09-05 17:12:55 -07008080
Jeff Johnson295189b2012-06-20 16:38:30 -07008081 tSirSmeDisassocRsp SmeDisassocRsp;
8082
8083 csrSerDesUnpackDiassocRsp((tANI_U8 *)pSmeRsp, &SmeDisassocRsp);
8084 sessionId = SmeDisassocRsp.sessionId;
8085 statusCode = SmeDisassocRsp.statusCode;
8086
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008087 smsLog( pMac, LOG2, "csrRoamRoamingStateDisassocRspProcessor sessionId %d", sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07008088
8089 if ( csrIsConnStateInfra( pMac, sessionId ) )
8090 {
8091 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
8092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008093 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07008094
8095 if(!pSession)
8096 {
8097 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8098 return;
8099 }
8100
Jeff Johnson295189b2012-06-20 16:38:30 -07008101 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, sessionId ) )
8102 {
8103 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8104 }
8105 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, sessionId ) ||
8106 CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, sessionId ) )
8107 {
8108 if ( eSIR_SME_SUCCESS == statusCode )
8109 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008110 smsLog( pMac, LOG2, "CSR SmeDisassocReq force disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008111 //A callback to HDD will be issued from csrRoamComplete so no need to do anything here
8112 }
8113 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8114 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008115 else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, sessionId ) )
8116 {
Kaushik, Sushant8489f472014-01-27 11:41:22 +05308117 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO_HIGH,
8118 "CSR SmeDisassocReq due to HO on session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07008119#if defined (WLAN_FEATURE_NEIGHBOR_ROAMING)
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008120 /*
8121 * First ensure if the roam profile is in the scan cache.
8122 * If not, post a reassoc failure and disconnect.
8123 */
Kiet Lam64c1b492013-07-12 13:56:44 +05308124 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
8125 if ( NULL == pScanFilter )
8126 status = eHAL_STATUS_FAILURE;
8127 else
8128 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008129 if(HAL_STATUS_SUCCESS(status))
8130 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308131 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008132 status = csrRoamPrepareFilterFromProfile(pMac,
8133 &pMac->roam.neighborRoamInfo.csrNeighborRoamProfile, pScanFilter);
8134 if(!HAL_STATUS_SUCCESS(status))
8135 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008136 smsLog(pMac, LOGE, "%s: failed to prepare scan filter with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008137 __func__, status);
8138 goto POST_ROAM_FAILURE;
8139 }
8140 else
8141 {
8142 status = csrScanGetResult(pMac, pScanFilter, &hBSSList);
8143 if (!HAL_STATUS_SUCCESS(status))
8144 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008145 smsLog( pMac, LOGE,"%s: csrScanGetResult failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008146 __func__, status);
8147 goto POST_ROAM_FAILURE;
8148 }
8149 }
8150 }
8151 else
8152 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008153 smsLog( pMac, LOGE,"%s: alloc for pScanFilter failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008154 __func__, status);
8155 goto POST_ROAM_FAILURE;
8156 }
8157
8158 /*
8159 * After ensuring that the roam profile is in the scan result list,
8160 * dequeue the command from the active list.
8161 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008162 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
8163 if ( pEntry )
8164 {
8165 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008166 /* If the head of the queue is Active and it is a ROAM command, remove
8167 * and put this on the Free queue.
8168 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008169 if ( eSmeCommandRoam == pCommand->command )
8170 {
Jeff Johnsone7245742012-09-05 17:12:55 -07008171
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008172 /*
8173 * we need to process the result first before removing it from active list
8174 * because state changes still happening insides roamQProcessRoamResults so
8175 * no other roam command should be issued.
8176 */
Jeff Johnson295189b2012-06-20 16:38:30 -07008177 fRemoveCmd = csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK );
8178 if(pCommand->u.roamCmd.fReleaseProfile)
8179 {
8180 csrReleaseProfile(pMac, &pCommand->u.roamCmd.roamProfile);
8181 pCommand->u.roamCmd.fReleaseProfile = eANI_BOOLEAN_FALSE;
8182 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008183 if( fRemoveCmd )
Jeff Johnson295189b2012-06-20 16:38:30 -07008184 csrReleaseCommandRoam( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07008185 else
8186 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008187 smsLog( pMac, LOGE, "%s: fail to remove cmd reason %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008188 __func__, pCommand->u.roamCmd.roamReason );
Jeff Johnson295189b2012-06-20 16:38:30 -07008189 }
8190 }
8191 else
8192 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008193 smsLog( pMac, LOGE, "%s: roam command not active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008194 }
8195 }
8196 else
8197 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008198 smsLog( pMac, LOGE, "%s: NO commands are active", __func__ );
Jeff Johnson295189b2012-06-20 16:38:30 -07008199 }
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008200
8201 /* Notify HDD about handoff and provide the BSSID too */
Jeff Johnson295189b2012-06-20 16:38:30 -07008202 roamInfo.reasonCode = eCsrRoamReasonBetterAP;
8203
Kiet Lam64c1b492013-07-12 13:56:44 +05308204 vos_mem_copy(roamInfo.bssid,
8205 pMac->roam.neighborRoamInfo.csrNeighborRoamProfile.BSSIDs.bssid,
8206 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008207
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008208 csrRoamCallCallback(pMac,sessionId, &roamInfo, 0,
8209 eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_NONE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008210
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008211 /* Copy the connected profile to apply the same for this connection as well */
Kiet Lam64c1b492013-07-12 13:56:44 +05308212 pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
8213 if ( pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -07008214 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308215 vos_mem_set(pCurRoamProfile, sizeof(tCsrRoamProfile), 0);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008216 csrRoamCopyProfile(pMac, pCurRoamProfile, pSession->pCurRoamProfile);
8217 //make sure to put it at the head of the cmd queue
8218 status = csrRoamIssueConnect(pMac, sessionId, pCurRoamProfile,
8219 hBSSList, eCsrSmeIssuedAssocToSimilarAP,
8220 roamId, eANI_BOOLEAN_TRUE, eANI_BOOLEAN_FALSE);
8221
Jeff Johnson295189b2012-06-20 16:38:30 -07008222 if(!HAL_STATUS_SUCCESS(status))
8223 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008224 smsLog( pMac, LOGE,"%s: csrRoamIssueConnect failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008225 __func__, status);
8226 fCallCallback = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008227 }
8228
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008229 /* Notify sub-modules like QoS etc. that handoff happening */
8230 sme_QosCsrEventInd(pMac, sessionId, SME_QOS_CSR_HANDOFF_ASSOC_REQ, NULL);
Dhanashri Atree3a2a592013-03-08 13:18:42 -08008231 csrReleaseProfile(pMac, pCurRoamProfile);
Kiet Lam64c1b492013-07-12 13:56:44 +05308232 vos_mem_free(pCurRoamProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -07008233 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308234 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008235 return;
8236 }
8237
8238POST_ROAM_FAILURE:
8239 if (pScanFilter)
8240 {
8241 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +05308242 vos_mem_free(pScanFilter);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008243 }
8244 if (pCurRoamProfile)
Kiet Lam64c1b492013-07-12 13:56:44 +05308245 vos_mem_free(pCurRoamProfile);
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008246
8247 /* Inform the upper layers that the reassoc failed */
8248 vos_mem_zero(&roamInfo, sizeof(tCsrRoamInfo));
8249 csrRoamCallCallback(pMac, sessionId,
8250 &roamInfo, 0, eCSR_ROAM_FT_REASSOC_FAILED, eSIR_SME_SUCCESS);
8251
8252 /*
8253 * Issue a disassoc request so that PE/LIM uses this to clean-up the FT session.
8254 * Upon success, we would re-enter this routine after receiving the disassoc
8255 * response and will fall into the reassoc fail sub-state. And, eventually
8256 * call csrRoamComplete which would remove the roam command from SME active
8257 * queue.
8258 */
8259 if (!HAL_STATUS_SUCCESS(csrRoamIssueDisassociate(pMac, sessionId,
8260 eCSR_ROAM_SUBSTATE_DISASSOC_REASSOC_FAILURE, FALSE)))
8261 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008262 smsLog( pMac, LOGE,"%s: csrRoamIssueDisassociate failed with status %d",
Madan Mohan Koyyalamudi397f0852012-11-27 16:27:38 -08008263 __func__, status);
8264 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07008265 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008266#endif
Jeff Johnsone7245742012-09-05 17:12:55 -07008267
Jeff Johnson295189b2012-06-20 16:38:30 -07008268 } //else if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac ) )
8269 else if ( CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, sessionId ) )
8270 {
8271 // Disassoc due to Reassoc failure falls into this codepath....
8272 csrRoamComplete( pMac, eCsrJoinFailure, NULL );
8273 }
8274 else
8275 {
8276 if ( eSIR_SME_SUCCESS == statusCode )
8277 {
8278 // Successfully disassociated from the 'old' Bss...
8279 //
8280 // We get Disassociate response in three conditions.
8281 // - First is the case where we are disasociating from an Infra Bss to start an IBSS.
8282 // - Second is the when we are disassociating from an Infra Bss to join an IBSS or a new
8283 // Infrastructure network.
8284 // - Third is where we are doing an Infra to Infra roam between networks with different
8285 // SSIDs. In all cases, we set the new Bss configuration here and attempt to join
8286
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008287 smsLog( pMac, LOG2, "CSR SmeDisassocReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008288 }
8289 else
8290 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008291 smsLog( pMac, LOGE, "SmeDisassocReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008292 }
8293 //We are not done yet. Get the data and continue roaming
8294 csrRoamReissueRoamCommand(pMac);
8295 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008296}
8297
Jeff Johnson295189b2012-06-20 16:38:30 -07008298static void csrRoamRoamingStateDeauthRspProcessor( tpAniSirGlobal pMac, tSirSmeDeauthRsp *pSmeRsp )
8299{
8300 tSirResultCodes statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008301 //No one is sending eWNI_SME_DEAUTH_REQ to PE.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008302 smsLog(pMac, LOGW, FL("is no-op"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008303 statusCode = csrGetDeAuthRspStatusCode( pSmeRsp );
Leela Venkata Kiran Kumar Reddy Chirala56df73f2014-01-30 14:18:00 -08008304 pMac->roam.deauthRspStatus = statusCode;
Jeff Johnson295189b2012-06-20 16:38:30 -07008305 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId) )
8306 {
8307 csrRoamComplete( pMac, eCsrNothingToJoin, NULL );
8308 }
8309 else
8310 {
8311 if ( eSIR_SME_SUCCESS == statusCode )
8312 {
8313 // Successfully deauth from the 'old' Bss...
8314 //
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008315 smsLog( pMac, LOG2, "CSR SmeDeauthReq disassociated Successfully" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008316 }
8317 else
8318 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008319 smsLog( pMac, LOGW, "SmeDeauthReq failed with statusCode= 0x%08X", statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008320 }
8321 //We are not done yet. Get the data and continue roaming
8322 csrRoamReissueRoamCommand(pMac);
8323 }
8324}
8325
Jeff Johnson295189b2012-06-20 16:38:30 -07008326static void csrRoamRoamingStateStartBssRspProcessor( tpAniSirGlobal pMac, tSirSmeStartBssRsp *pSmeStartBssRsp )
8327{
8328 eCsrRoamCompleteResult result;
8329
8330 if ( eSIR_SME_SUCCESS == pSmeStartBssRsp->statusCode )
8331 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008332 smsLog( pMac, LOGW, "SmeStartBssReq Successful" );
Jeff Johnson295189b2012-06-20 16:38:30 -07008333 result = eCsrStartBssSuccess;
8334 }
8335 else
8336 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008337 smsLog( pMac, LOGW, "SmeStartBssReq failed with statusCode= 0x%08X", pSmeStartBssRsp->statusCode );
Jeff Johnson295189b2012-06-20 16:38:30 -07008338 //Let csrRoamComplete decide what to do
8339 result = eCsrStartBssFailure;
8340 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008341 csrRoamComplete( pMac, result, pSmeStartBssRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -07008342}
8343
Jeff Johnson295189b2012-06-20 16:38:30 -07008344/*
8345 We need to be careful on whether to cast pMsgBuf (pSmeRsp) to other type of strucutres.
8346 It depends on how the message is constructed. If the message is sent by limSendSmeRsp,
8347 the pMsgBuf is only a generic response and can only be used as pointer to tSirSmeRsp.
8348 For the messages where sender allocates memory for specific structures, then it can be
8349 cast accordingly.
8350*/
8351void csrRoamingStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8352{
8353 tSirSmeRsp *pSmeRsp;
8354 tSmeIbssPeerInd *pIbssPeerInd;
8355 tCsrRoamInfo roamInfo;
8356 // TODO Session Id need to be acquired in this function
8357 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07008358 pSmeRsp = (tSirSmeRsp *)pMsgBuf;
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308359 smsLog(pMac, LOG2, FL("Message %d[0x%04X] received in substate %s"),
8360 pSmeRsp->messageType, pSmeRsp->messageType,
8361 macTraceGetcsrRoamSubState(
8362 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008363 pSmeRsp->messageType = (pSmeRsp->messageType);
8364 pSmeRsp->length = (pSmeRsp->length);
8365 pSmeRsp->statusCode = (pSmeRsp->statusCode);
Jeff Johnson295189b2012-06-20 16:38:30 -07008366 switch (pSmeRsp->messageType)
8367 {
8368
8369 case eWNI_SME_JOIN_RSP: // in Roaming state, process the Join response message...
8370 if (CSR_IS_ROAM_SUBSTATE_JOIN_REQ(pMac, pSmeRsp->sessionId))
8371 {
8372 //We sent a JOIN_REQ
8373 csrRoamJoinRspProcessor( pMac, (tSirSmeJoinRsp *)pSmeRsp );
8374 }
8375 break;
8376
8377 case eWNI_SME_AUTH_RSP: // or the Authenticate response message...
8378 if (CSR_IS_ROAM_SUBSTATE_AUTH_REQ( pMac, pSmeRsp->sessionId) )
8379 {
8380 //We sent a AUTH_REQ
8381 csrRoamRoamingStateAuthRspProcessor( pMac, (tSirSmeAuthRsp *)pSmeRsp );
8382 }
8383 break;
8384
8385 case eWNI_SME_REASSOC_RSP: // or the Reassociation response message...
8386 if (CSR_IS_ROAM_SUBSTATE_REASSOC_REQ( pMac, pSmeRsp->sessionId) )
8387 {
8388 csrRoamRoamingStateReassocRspProcessor( pMac, (tpSirSmeJoinRsp )pSmeRsp );
8389 }
8390 break;
8391
8392 case eWNI_SME_STOP_BSS_RSP: // or the Stop Bss response message...
8393 {
8394 csrRoamRoamingStateStopBssRspProcessor(pMac, pSmeRsp);
8395 }
8396 break;
8397
8398 case eWNI_SME_DISASSOC_RSP: // or the Disassociate response message...
8399 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_REQ( pMac, pSmeRsp->sessionId ) ||
8400 CSR_IS_ROAM_SUBSTATE_DISASSOC_NO_JOIN( pMac, pSmeRsp->sessionId ) ||
8401 CSR_IS_ROAM_SUBSTATE_REASSOC_FAIL( pMac, pSmeRsp->sessionId ) ||
8402 CSR_IS_ROAM_SUBSTATE_DISASSOC_FORCED( pMac, pSmeRsp->sessionId ) ||
8403 CSR_IS_ROAM_SUBSTATE_DISCONNECT_CONTINUE( pMac, pSmeRsp->sessionId ) ||
8404//HO
8405 CSR_IS_ROAM_SUBSTATE_DISASSOC_HO( pMac, pSmeRsp->sessionId ) )
8406 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308407 smsLog(pMac, LOG1, FL("eWNI_SME_DISASSOC_RSP subState = %s"),
8408 macTraceGetcsrRoamSubState(
8409 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008410 csrRoamRoamingStateDisassocRspProcessor( pMac, (tSirSmeDisassocRsp *)pSmeRsp );
Mukul Sharmabe91e2f2014-06-29 22:09:20 +05308411#ifdef DEBUG_ROAM_DELAY
8412 vos_record_roam_event(e_SME_DISASSOC_COMPLETE, NULL, 0);
8413#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07008414 }
8415 break;
8416
8417 case eWNI_SME_DEAUTH_RSP: // or the Deauthentication response message...
8418 if ( CSR_IS_ROAM_SUBSTATE_DEAUTH_REQ( pMac, pSmeRsp->sessionId ) )
8419 {
8420 csrRoamRoamingStateDeauthRspProcessor( pMac, (tSirSmeDeauthRsp *)pSmeRsp );
8421 }
8422 break;
8423
8424 case eWNI_SME_START_BSS_RSP: // or the Start BSS response message...
8425 if (CSR_IS_ROAM_SUBSTATE_START_BSS_REQ( pMac, pSmeRsp->sessionId ) )
8426 {
8427 csrRoamRoamingStateStartBssRspProcessor( pMac, (tSirSmeStartBssRsp *)pSmeRsp );
8428 }
8429 break;
8430
8431 case WNI_CFG_SET_CNF: // process the Config Confirm messages when we are in 'Config' substate...
8432 if ( CSR_IS_ROAM_SUBSTATE_CONFIG( pMac, pSmeRsp->sessionId ) )
8433 {
8434 csrRoamingStateConfigCnfProcessor( pMac, ((tCsrCfgSetRsp *)pSmeRsp)->respStatus );
8435 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008436 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008437 //In case CSR issues STOP_BSS, we need to tell HDD about peer departed becasue PE is removing them
8438 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
8439 pIbssPeerInd = (tSmeIbssPeerInd*)pSmeRsp;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008440 smsLog(pMac, LOGE, "CSR: Peer departed notification from LIM in joining state");
Kiet Lam64c1b492013-07-12 13:56:44 +05308441 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
8442 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008443 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
8444 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +05308445 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
8446 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008447 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
8448 eCSR_ROAM_CONNECT_STATUS_UPDATE,
8449 eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
8450 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008451 default:
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05308452 smsLog(pMac, LOG1,
8453 FL("Unexpected message type = %d[0x%X] received in substate %s"),
8454 pSmeRsp->messageType, pSmeRsp->messageType,
8455 macTraceGetcsrRoamSubState(
8456 pMac->roam.curSubState[pSmeRsp->sessionId]));
Jeff Johnson295189b2012-06-20 16:38:30 -07008457
8458 //If we are connected, check the link status change
8459 if(!csrIsConnStateDisconnected(pMac, sessionId))
8460 {
8461 csrRoamCheckForLinkStatusChange( pMac, pSmeRsp );
8462 }
8463 break;
8464 }
8465}
8466
Jeff Johnson295189b2012-06-20 16:38:30 -07008467void csrRoamJoinedStateMsgProcessor( tpAniSirGlobal pMac, void *pMsgBuf )
8468{
8469 tSirSmeRsp *pSirMsg = (tSirSmeRsp *)pMsgBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -07008470 switch (pSirMsg->messageType)
8471 {
8472 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008473 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -07008474 csrRoamStatsRspProcessor( pMac, pSirMsg );
8475 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008476 case eWNI_SME_UPPER_LAYER_ASSOC_CNF:
8477 {
8478 tCsrRoamSession *pSession;
8479 tSirSmeAssocIndToUpperLayerCnf *pUpperLayerAssocCnf;
8480 tCsrRoamInfo roamInfo;
8481 tCsrRoamInfo *pRoamInfo = NULL;
8482 tANI_U32 sessionId;
8483 eHalStatus status;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008484 smsLog( pMac, LOG1, FL("ASSOCIATION confirmation can be given to upper layer "));
Kiet Lam64c1b492013-07-12 13:56:44 +05308485 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008486 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07008487 pUpperLayerAssocCnf = (tSirSmeAssocIndToUpperLayerCnf *)pMsgBuf;
8488 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pUpperLayerAssocCnf->bssId, &sessionId );
8489 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -07008490
8491 if(!pSession)
8492 {
8493 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8494 return;
8495 }
8496
Jeff Johnson295189b2012-06-20 16:38:30 -07008497 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
8498 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07008499 pRoamInfo->staId = (tANI_U8)pUpperLayerAssocCnf->aid;
8500 pRoamInfo->rsnIELen = (tANI_U8)pUpperLayerAssocCnf->rsnIE.length;
8501 pRoamInfo->prsnIE = pUpperLayerAssocCnf->rsnIE.rsnIEdata;
Jeff Johnson295189b2012-06-20 16:38:30 -07008502 pRoamInfo->addIELen = (tANI_U8)pUpperLayerAssocCnf->addIE.length;
8503 pRoamInfo->paddIE = pUpperLayerAssocCnf->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05308504 vos_mem_copy(pRoamInfo->peerMac, pUpperLayerAssocCnf->peerMacAddr,
8505 sizeof(tSirMacAddr));
8506 vos_mem_copy(&pRoamInfo->bssid, pUpperLayerAssocCnf->bssId,
8507 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008508 pRoamInfo->wmmEnabledSta = pUpperLayerAssocCnf->wmmEnabledSta;
Jeff Johnson295189b2012-06-20 16:38:30 -07008509 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) )
8510 {
8511 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_INFRA_CONNECTED;
8512 pRoamInfo->fReassocReq = pUpperLayerAssocCnf->reassocReq;
8513 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
8514 }
8515 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
8516 {
8517 vos_sleep( 100 );
8518 pMac->roam.roamSession[sessionId].connectState = eCSR_ASSOC_STATE_TYPE_WDS_CONNECTED;//Sta
8519 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
8520 }
8521
Jeff Johnson295189b2012-06-20 16:38:30 -07008522 }
8523 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07008524 default:
8525 csrRoamCheckForLinkStatusChange( pMac, pSirMsg );
8526 break;
8527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008528}
8529
Jeff Johnson295189b2012-06-20 16:38:30 -07008530eHalStatus csrRoamIssueSetContextReq( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrEncryptionType EncryptType,
8531 tSirBssDescription *pBssDescription,
8532 tSirMacAddr *bssId, tANI_BOOLEAN addKey,
8533 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
8534 tANI_U8 keyId, tANI_U16 keyLength,
8535 tANI_U8 *pKey, tANI_U8 paeRole )
8536{
8537 eHalStatus status = eHAL_STATUS_SUCCESS;
8538 tAniEdType edType;
8539
8540 if(eCSR_ENCRYPT_TYPE_UNKNOWN == EncryptType)
8541 {
8542 EncryptType = eCSR_ENCRYPT_TYPE_NONE; //***
8543 }
8544
8545 edType = csrTranslateEncryptTypeToEdType( EncryptType );
8546
8547 // Allow 0 keys to be set for the non-WPA encrypt types... For WPA encrypt types, the num keys must be non-zero
8548 // or LIM will reject the set context (assumes the SET_CONTEXT does not occur until the keys are distrubuted).
8549 if ( CSR_IS_ENC_TYPE_STATIC( EncryptType ) ||
8550 addKey )
8551 {
8552 tCsrRoamSetKey setKey;
Jeff Johnson295189b2012-06-20 16:38:30 -07008553 setKey.encType = EncryptType;
8554 setKey.keyDirection = aniKeyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308555 vos_mem_copy(&setKey.peerMac, bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008556 setKey.paeRole = paeRole; //0 for supplicant
8557 setKey.keyId = keyId; // Kye index
8558 setKey.keyLength = keyLength;
8559 if( keyLength )
8560 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308561 vos_mem_copy(setKey.Key, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008562 }
8563 status = csrRoamIssueSetKeyCommand( pMac, sessionId, &setKey, 0 );
8564 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008565 return (status);
8566}
8567
Jeff Johnson295189b2012-06-20 16:38:30 -07008568static eHalStatus csrRoamIssueSetKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8569 tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8570{
8571 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8572 tSmeCmd *pCommand = NULL;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008573#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008574 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008575#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07008576
8577 do
8578 {
8579 pCommand = csrGetCommandBuffer(pMac);
8580 if(NULL == pCommand)
8581 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008582 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008583 status = eHAL_STATUS_RESOURCES;
8584 break;
8585 }
Sushant Kaushike7de85f2014-06-16 17:13:30 +05308586 vos_mem_zero(pCommand, sizeof(tSmeCmd));
Jeff Johnson295189b2012-06-20 16:38:30 -07008587 pCommand->command = eSmeCommandSetKey;
8588 pCommand->sessionId = (tANI_U8)sessionId;
8589 // validate the key length, Adjust if too long...
8590 // for static WEP the keys are not set thru' SetContextReq
8591 if ( ( eCSR_ENCRYPT_TYPE_WEP40 == pSetKey->encType ) ||
8592 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pSetKey->encType ) )
8593 {
8594 //KeyLength maybe 0 for static WEP
8595 if( pSetKey->keyLength )
8596 {
8597 if ( pSetKey->keyLength < CSR_WEP40_KEY_LEN )
8598 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008599 smsLog( pMac, LOGW, "Invalid WEP40 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008600 break;
8601 }
8602
8603 pCommand->u.setKeyCmd.keyLength = CSR_WEP40_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308604 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8605 CSR_WEP40_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008606 }
8607 }
8608 else if ( ( eCSR_ENCRYPT_TYPE_WEP104 == pSetKey->encType ) ||
8609 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pSetKey->encType ) )
8610 {
8611 //KeyLength maybe 0 for static WEP
8612 if( pSetKey->keyLength )
8613 {
8614 if ( pSetKey->keyLength < CSR_WEP104_KEY_LEN )
8615 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008616 smsLog( pMac, LOGW, "Invalid WEP104 keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008617 break;
8618 }
8619
8620 pCommand->u.setKeyCmd.keyLength = CSR_WEP104_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308621 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8622 CSR_WEP104_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008623 }
8624 }
8625 else if ( eCSR_ENCRYPT_TYPE_TKIP == pSetKey->encType )
8626 {
8627 if ( pSetKey->keyLength < CSR_TKIP_KEY_LEN )
8628 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008629 smsLog( pMac, LOGW, "Invalid TKIP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008630 break;
8631 }
8632 pCommand->u.setKeyCmd.keyLength = CSR_TKIP_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308633 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8634 CSR_TKIP_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008635 }
8636 else if ( eCSR_ENCRYPT_TYPE_AES == pSetKey->encType )
8637 {
8638 if ( pSetKey->keyLength < CSR_AES_KEY_LEN )
8639 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008640 smsLog( pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008641 break;
8642 }
8643 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308644 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8645 CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008646 }
8647#ifdef FEATURE_WLAN_WAPI
8648 else if ( eCSR_ENCRYPT_TYPE_WPI == pSetKey->encType )
8649 {
8650 if ( pSetKey->keyLength < CSR_WAPI_KEY_LEN )
8651 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008652 smsLog( pMac, LOGW, "Invalid WAPI keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008653 break;
8654 }
8655 pCommand->u.setKeyCmd.keyLength = CSR_WAPI_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308656 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key,
8657 CSR_WAPI_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008658 }
8659#endif /* FEATURE_WLAN_WAPI */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008660#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008661 else if ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
8662 {
8663 if ( pSetKey->keyLength < CSR_KRK_KEY_LEN )
8664 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008665 smsLog( pMac, LOGW, "Invalid KRK keylength [= %d] in SetContext call", pSetKey->keyLength );
Jeff Johnson295189b2012-06-20 16:38:30 -07008666 break;
8667 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008668 vos_mem_copy(pSession->eseCckmInfo.krk, pSetKey->Key,
Kiet Lam64c1b492013-07-12 13:56:44 +05308669 CSR_KRK_KEY_LEN);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008670 pSession->eseCckmInfo.reassoc_req_num=1;
8671 pSession->eseCckmInfo.krk_plumbed = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008672 status = eHAL_STATUS_SUCCESS;
8673 break;
8674 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008675#endif /* FEATURE_WLAN_ESE */
Jeff Johnsone7245742012-09-05 17:12:55 -07008676
Jeff Johnson295189b2012-06-20 16:38:30 -07008677#ifdef WLAN_FEATURE_11W
8678 //Check for 11w BIP
Chet Lanctot186b5732013-03-18 10:26:30 -07008679 else if (eCSR_ENCRYPT_TYPE_AES_CMAC == pSetKey->encType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008680 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008681 if (pSetKey->keyLength < CSR_AES_KEY_LEN)
Jeff Johnson295189b2012-06-20 16:38:30 -07008682 {
Chet Lanctot186b5732013-03-18 10:26:30 -07008683 smsLog(pMac, LOGW, "Invalid AES/CCMP keylength [= %d] in SetContext call", pSetKey->keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07008684 break;
8685 }
8686 pCommand->u.setKeyCmd.keyLength = CSR_AES_KEY_LEN;
Kiet Lam64c1b492013-07-12 13:56:44 +05308687 vos_mem_copy(pCommand->u.setKeyCmd.Key, pSetKey->Key, CSR_AES_KEY_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008688 }
8689#endif
8690 status = eHAL_STATUS_SUCCESS;
8691 pCommand->u.setKeyCmd.roamId = roamId;
8692 pCommand->u.setKeyCmd.encType = pSetKey->encType;
8693 pCommand->u.setKeyCmd.keyDirection = pSetKey->keyDirection; //Tx, Rx or Tx-and-Rx
Kiet Lam64c1b492013-07-12 13:56:44 +05308694 vos_mem_copy(&pCommand->u.setKeyCmd.peerMac, &pSetKey->peerMac,
8695 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07008696 pCommand->u.setKeyCmd.paeRole = pSetKey->paeRole; //0 for supplicant
8697 pCommand->u.setKeyCmd.keyId = pSetKey->keyId;
Kiet Lam64c1b492013-07-12 13:56:44 +05308698 vos_mem_copy(pCommand->u.setKeyCmd.keyRsc, pSetKey->keyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07008699 //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
8700
8701 status = csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
8702 if( !HAL_STATUS_SUCCESS( status ) )
8703 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008704 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008705 }
8706 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008707 // Free the command if there has been a failure, or it is a
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008708 // "local" operation like the set ESE CCKM KRK key.
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008709 if ( ( NULL != pCommand ) &&
8710 ( (!HAL_STATUS_SUCCESS( status ) )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008711#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07008712 || ( eCSR_ENCRYPT_TYPE_KRK == pSetKey->encType )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08008713#endif /* FEATURE_WLAN_ESE */
Jeff Johnson74b3ec52013-04-03 13:45:51 -07008714 ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07008715 {
8716 csrReleaseCommandSetKey( pMac, pCommand );
8717 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008718 return( status );
8719}
8720
Jeff Johnson295189b2012-06-20 16:38:30 -07008721eHalStatus csrRoamIssueRemoveKeyCommand( tpAniSirGlobal pMac, tANI_U32 sessionId,
8722 tCsrRoamRemoveKey *pRemoveKey, tANI_U32 roamId )
8723{
8724 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
8725 tSmeCmd *pCommand = NULL;
8726 tANI_BOOLEAN fImediate = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008727 do
8728 {
8729 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8730 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008731 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008732 status = eHAL_STATUS_CSR_WRONG_STATE;
8733 break;
8734 }
8735 pCommand = csrGetCommandBuffer(pMac);
8736 if(NULL == pCommand)
8737 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008738 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008739 status = eHAL_STATUS_RESOURCES;
8740 break;
8741 }
8742 pCommand->command = eSmeCommandRemoveKey;
8743 pCommand->sessionId = (tANI_U8)sessionId;
8744 pCommand->u.removeKeyCmd.roamId = roamId;
8745 pCommand->u.removeKeyCmd.encType = pRemoveKey->encType;
Kiet Lam64c1b492013-07-12 13:56:44 +05308746 vos_mem_copy(&pCommand->u.removeKeyCmd.peerMac, &pRemoveKey->peerMac,
8747 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008748 pCommand->u.removeKeyCmd.keyId = pRemoveKey->keyId;
8749 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
8750 {
8751 //in this case, put it to the end of the Q incase there is a set key pending.
8752 fImediate = eANI_BOOLEAN_FALSE;
8753 }
Arif Hussain24bafea2013-11-15 15:10:03 -08008754 smsLog( pMac, LOGE, FL("keyType=%d, keyId=%d, PeerMac="MAC_ADDRESS_STR),
Jeff Johnson295189b2012-06-20 16:38:30 -07008755 pRemoveKey->encType, pRemoveKey->keyId,
Arif Hussain24bafea2013-11-15 15:10:03 -08008756 MAC_ADDR_ARRAY(pCommand->u.removeKeyCmd.peerMac));
Jeff Johnson295189b2012-06-20 16:38:30 -07008757 status = csrQueueSmeCommand(pMac, pCommand, fImediate);
8758 if( !HAL_STATUS_SUCCESS( status ) )
8759 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008760 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008761 break;
8762 }
8763 } while (0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008764 if( !HAL_STATUS_SUCCESS( status ) && ( NULL != pCommand ) )
8765 {
8766 csrReleaseCommandRemoveKey( pMac, pCommand );
8767 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008768 return (status );
8769}
8770
Jeff Johnson295189b2012-06-20 16:38:30 -07008771eHalStatus csrRoamProcessSetKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8772{
8773 eHalStatus status;
8774 tANI_U8 numKeys = ( pCommand->u.setKeyCmd.keyLength ) ? 1 : 0;
8775 tAniEdType edType = csrTranslateEncryptTypeToEdType( pCommand->u.setKeyCmd.encType );
8776 tANI_BOOLEAN fUnicast = ( pCommand->u.setKeyCmd.peerMac[0] == 0xFF ) ? eANI_BOOLEAN_FALSE : eANI_BOOLEAN_TRUE;
8777 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008778#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8779 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8780 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05308781 if(!pSession)
8782 {
8783 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8784 return eHAL_STATUS_FAILURE;
8785 }
lukez3c809222013-05-03 10:23:02 -07008786 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008787 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308788 vos_mem_set(&setKeyEvent,
8789 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008790 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8791 {
8792 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_REQ;
8793 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8794 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
8795 }
8796 else
8797 {
8798 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_REQ;
8799 setKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pCommand->u.setKeyCmd.encType);
8800 setKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8801 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308802 vos_mem_copy(setKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
lukez3c809222013-05-03 10:23:02 -07008803 if(CSR_IS_ENC_TYPE_STATIC(pCommand->u.setKeyCmd.encType))
Jeff Johnson295189b2012-06-20 16:38:30 -07008804 {
8805 tANI_U32 defKeyId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008806 //It has to be static WEP here
8807 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_WEP_DEFAULT_KEYID, &defKeyId)))
8808 {
8809 setKeyEvent.keyId = (v_U8_t)defKeyId;
8810 }
8811 }
8812 else
8813 {
8814 setKeyEvent.keyId = pCommand->u.setKeyCmd.keyId;
8815 }
8816 setKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8817 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8818 }
8819#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008820 if( csrIsSetKeyAllowed(pMac, sessionId) )
8821 {
8822 status = csrSendMBSetContextReqMsg( pMac, sessionId,
8823 ( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac,
8824 numKeys, edType, fUnicast, pCommand->u.setKeyCmd.keyDirection,
8825 pCommand->u.setKeyCmd.keyId, pCommand->u.setKeyCmd.keyLength,
8826 pCommand->u.setKeyCmd.Key, pCommand->u.setKeyCmd.paeRole,
8827 pCommand->u.setKeyCmd.keyRsc);
8828 }
8829 else
8830 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008831 smsLog( pMac, LOGW, FL(" cannot process not connected") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008832 //Set this status so the error handling take care of the case.
8833 status = eHAL_STATUS_CSR_WRONG_STATE;
8834 }
8835 if( !HAL_STATUS_SUCCESS(status) )
8836 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008837 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008838 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.setKeyCmd.roamId, eCSR_ROAM_SET_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
Jeff Johnson295189b2012-06-20 16:38:30 -07008839#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
lukez3c809222013-05-03 10:23:02 -07008840 if(eSIR_ED_NONE != edType)
Jeff Johnson295189b2012-06-20 16:38:30 -07008841 {
8842 if( *(( tANI_U8 *)&pCommand->u.setKeyCmd.peerMac) & 0x01 )
8843 {
8844 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
8845 }
8846 else
8847 {
8848 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
8849 }
8850 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
8851 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
8852 }
8853#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008854 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008855 return ( status );
8856}
8857
Jeff Johnson295189b2012-06-20 16:38:30 -07008858eHalStatus csrRoamProcessRemoveKeyCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
8859{
8860 eHalStatus status;
8861 tpSirSmeRemoveKeyReq pMsg = NULL;
8862 tANI_U16 wMsgLen = sizeof(tSirSmeRemoveKeyReq);
8863 tANI_U8 *p;
8864 tANI_U32 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -07008865#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8866 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
8867 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Girish Gowli2857eb22014-07-31 19:49:46 +05308868 if(!pSession)
8869 {
8870 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
8871 return eHAL_STATUS_FAILURE;
8872 }
Kiet Lam64c1b492013-07-12 13:56:44 +05308873 vos_mem_set(&removeKeyEvent,
8874 sizeof(vos_event_wlan_security_payload_type),0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008875 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_REQ;
8876 removeKeyEvent.encryptionModeMulticast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
8877 removeKeyEvent.encryptionModeUnicast = (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +05308878 vos_mem_copy(removeKeyEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07008879 removeKeyEvent.keyId = pCommand->u.removeKeyCmd.keyId;
8880 removeKeyEvent.authMode = (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
8881 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8882#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008883 if( csrIsSetKeyAllowed(pMac, sessionId) )
8884 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308885 pMsg = vos_mem_malloc(wMsgLen);
8886 if ( NULL == pMsg )
8887 status = eHAL_STATUS_FAILURE;
8888 else
8889 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008890 }
8891 else
8892 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08008893 smsLog( pMac, LOGW, FL(" wrong state not allowed to set key") );
Jeff Johnson295189b2012-06-20 16:38:30 -07008894 //Set the error status so error handling kicks in below
8895 status = eHAL_STATUS_CSR_WRONG_STATE;
8896 }
8897 if( HAL_STATUS_SUCCESS( status ) )
8898 {
Kiet Lam64c1b492013-07-12 13:56:44 +05308899 vos_mem_set(pMsg, wMsgLen ,0);
Jeff Johnson295189b2012-06-20 16:38:30 -07008900 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_REMOVEKEY_REQ);
8901 pMsg->length = pal_cpu_to_be16(wMsgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -07008902 pMsg->sessionId = (tANI_U8)sessionId;
8903 pMsg->transactionId = 0;
8904 p = (tANI_U8 *)pMsg + sizeof(pMsg->messageType) + sizeof(pMsg->length) +
8905 sizeof(pMsg->sessionId) + sizeof(pMsg->transactionId);
8906 // bssId - copy from session Info
Kiet Lam64c1b492013-07-12 13:56:44 +05308907 vos_mem_copy(p,
8908 &pMac->roam.roamSession[sessionId].connectedProfile.bssid,
8909 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008910 p += sizeof(tSirMacAddr);
8911 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +05308912 vos_mem_copy(p, pCommand->u.removeKeyCmd.peerMac, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07008913 p += sizeof(tSirMacAddr);
8914 // edType
8915 *p = (tANI_U8)csrTranslateEncryptTypeToEdType( pCommand->u.removeKeyCmd.encType );
8916 p++;
8917 // weptype
8918 if( ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pCommand->u.removeKeyCmd.encType ) ||
8919 ( eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pCommand->u.removeKeyCmd.encType ) )
8920 {
8921 *p = (tANI_U8)eSIR_WEP_STATIC;
8922 }
8923 else
8924 {
8925 *p = (tANI_U8)eSIR_WEP_DYNAMIC;
8926 }
8927 p++;
8928 //keyid
8929 *p = pCommand->u.removeKeyCmd.keyId;
8930 p++;
8931 *p = (pCommand->u.removeKeyCmd.peerMac[0] == 0xFF ) ? 0 : 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07008932 status = palSendMBMessage(pMac->hHdd, pMsg);
8933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008934 if( !HAL_STATUS_SUCCESS( status ) )
8935 {
Jeff Johnsonce8ad512013-10-30 12:34:42 -07008936 smsLog( pMac, LOGE, FL(" error status %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -07008937#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
8938 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
Madan Mohan Koyyalamudi4e31b132012-11-02 13:13:52 -07008939 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07008940 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
8941#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07008942 csrRoamCallCallback( pMac, sessionId, NULL, pCommand->u.removeKeyCmd.roamId, eCSR_ROAM_REMOVE_KEY_COMPLETE, eCSR_ROAM_RESULT_FAILURE);
8943 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008944 return ( status );
8945}
8946
Jeff Johnson295189b2012-06-20 16:38:30 -07008947eHalStatus csrRoamSetKey( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamSetKey *pSetKey, tANI_U32 roamId )
8948{
8949 eHalStatus status;
8950
8951 if( !csrIsSetKeyAllowed(pMac, sessionId) )
8952 {
8953 status = eHAL_STATUS_CSR_WRONG_STATE;
8954 }
8955 else
8956 {
8957 status = csrRoamIssueSetKeyCommand( pMac, sessionId, pSetKey, roamId );
8958 }
Jeff Johnson295189b2012-06-20 16:38:30 -07008959 return ( status );
8960}
8961
Jeff Johnson295189b2012-06-20 16:38:30 -07008962/*
8963 Prepare a filter base on a profile for parsing the scan results.
8964 Upon successful return, caller MUST call csrFreeScanFilter on
8965 pScanFilter when it is done with the filter.
8966*/
8967eHalStatus csrRoamPrepareFilterFromProfile(tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
8968 tCsrScanResultFilter *pScanFilter)
8969{
8970 eHalStatus status = eHAL_STATUS_SUCCESS;
8971 tANI_U32 size = 0;
8972 tANI_U8 index = 0;
8973
8974 do
8975 {
8976 if(pProfile->BSSIDs.numOfBSSIDs)
8977 {
8978 size = sizeof(tCsrBssid) * pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308979 pScanFilter->BSSIDs.bssid = vos_mem_malloc(size);
8980 if ( NULL == pScanFilter->BSSIDs.bssid )
8981 status = eHAL_STATUS_FAILURE;
8982 else
8983 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07008984 if(!HAL_STATUS_SUCCESS(status))
8985 {
8986 break;
8987 }
8988 pScanFilter->BSSIDs.numOfBSSIDs = pProfile->BSSIDs.numOfBSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05308989 vos_mem_copy(pScanFilter->BSSIDs.bssid, pProfile->BSSIDs.bssid, size);
Jeff Johnson295189b2012-06-20 16:38:30 -07008990 }
8991 if(pProfile->SSIDs.numOfSSIDs)
8992 {
8993 if( !CSR_IS_WDS_STA( pProfile ) )
8994 {
8995 pScanFilter->SSIDs.numOfSSIDs = pProfile->SSIDs.numOfSSIDs;
8996 }
8997 else
8998 {
8999 //For WDS station
9000 //We always use index 1 for self SSID. Index 0 for peer's SSID that we want to join
9001 pScanFilter->SSIDs.numOfSSIDs = 1;
9002 }
9003 size = sizeof(tCsrSSIDInfo) * pProfile->SSIDs.numOfSSIDs;
Kiet Lam64c1b492013-07-12 13:56:44 +05309004 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(size);
9005 if ( NULL == pScanFilter->SSIDs.SSIDList )
9006 status = eHAL_STATUS_FAILURE;
9007 else
9008 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -07009009 if(!HAL_STATUS_SUCCESS(status))
9010 {
9011 break;
9012 }
Kiet Lam64c1b492013-07-12 13:56:44 +05309013 vos_mem_copy(pScanFilter->SSIDs.SSIDList, pProfile->SSIDs.SSIDList,
9014 size);
Jeff Johnson295189b2012-06-20 16:38:30 -07009015 }
9016 if(!pProfile->ChannelInfo.ChannelList || (pProfile->ChannelInfo.ChannelList[0] == 0) )
9017 {
9018 pScanFilter->ChannelInfo.numOfChannels = 0;
9019 pScanFilter->ChannelInfo.ChannelList = NULL;
9020 }
9021 else if(pProfile->ChannelInfo.numOfChannels)
9022 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309023 pScanFilter->ChannelInfo.ChannelList = vos_mem_malloc(
9024 sizeof(*pScanFilter->ChannelInfo.ChannelList) *
9025 pProfile->ChannelInfo.numOfChannels);
9026 if ( NULL == pScanFilter->ChannelInfo.ChannelList )
9027 status = eHAL_STATUS_FAILURE;
9028 else
9029 status = eHAL_STATUS_SUCCESS;
9030
Jeff Johnson295189b2012-06-20 16:38:30 -07009031 pScanFilter->ChannelInfo.numOfChannels = 0;
9032 if(HAL_STATUS_SUCCESS(status))
9033 {
9034 for(index = 0; index < pProfile->ChannelInfo.numOfChannels; index++)
9035 {
9036 if(csrRoamIsChannelValid(pMac, pProfile->ChannelInfo.ChannelList[index]))
9037 {
9038 pScanFilter->ChannelInfo.ChannelList[pScanFilter->ChannelInfo.numOfChannels]
9039 = pProfile->ChannelInfo.ChannelList[index];
9040 pScanFilter->ChannelInfo.numOfChannels++;
9041 }
9042 else
9043 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009044 smsLog(pMac, LOG1, FL("process a channel (%d) that is invalid"), pProfile->ChannelInfo.ChannelList[index]);
Jeff Johnson295189b2012-06-20 16:38:30 -07009045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009046 }
9047 }
9048 else
9049 {
9050 break;
9051 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009052 }
9053 else
9054 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +05309055 smsLog(pMac, LOGE, FL("Channel list empty"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009056 status = eHAL_STATUS_FAILURE;
9057 break;
9058 }
9059 pScanFilter->uapsd_mask = pProfile->uapsd_mask;
9060 pScanFilter->authType = pProfile->AuthType;
9061 pScanFilter->EncryptionType = pProfile->EncryptionType;
9062 pScanFilter->mcEncryptionType = pProfile->mcEncryptionType;
9063 pScanFilter->BSSType = pProfile->BSSType;
9064 pScanFilter->phyMode = pProfile->phyMode;
9065#ifdef FEATURE_WLAN_WAPI
9066 //check if user asked for WAPI with 11n or auto mode, in that case modify
9067 //the phymode to 11g
9068 if(csrIsProfileWapi(pProfile))
9069 {
9070 if(pScanFilter->phyMode & eCSR_DOT11_MODE_11n)
9071 {
9072 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_11n;
9073 }
9074 if(pScanFilter->phyMode & eCSR_DOT11_MODE_AUTO)
9075 {
9076 pScanFilter->phyMode &= ~eCSR_DOT11_MODE_AUTO;
9077 }
9078 if(!pScanFilter->phyMode)
9079 {
9080 pScanFilter->phyMode = eCSR_DOT11_MODE_11g;
9081 }
9082 }
9083#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -07009084 /*Save the WPS info*/
9085 pScanFilter->bWPSAssociation = pProfile->bWPSAssociation;
Leela Venkata Kiran Kumar Reddy Chiralae208a832014-04-27 22:34:25 -07009086 pScanFilter->bOSENAssociation = pProfile->bOSENAssociation;
Jeff Johnson295189b2012-06-20 16:38:30 -07009087 if( pProfile->countryCode[0] )
9088 {
9089 //This causes the matching function to use countryCode as one of the criteria.
Kiet Lam64c1b492013-07-12 13:56:44 +05309090 vos_mem_copy(pScanFilter->countryCode, pProfile->countryCode,
9091 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07009092 }
9093#ifdef WLAN_FEATURE_VOWIFI_11R
9094 if (pProfile->MDID.mdiePresent)
9095 {
9096 pScanFilter->MDID.mdiePresent = 1;
9097 pScanFilter->MDID.mobilityDomain = pProfile->MDID.mobilityDomain;
9098 }
9099#endif
Abhishek Singh3b56d3a2014-06-25 12:37:39 +05309100
9101#ifdef WLAN_FEATURE_11W
9102 // Management Frame Protection
9103 pScanFilter->MFPEnabled = pProfile->MFPEnabled;
9104 pScanFilter->MFPRequired = pProfile->MFPRequired;
9105 pScanFilter->MFPCapable = pProfile->MFPCapable;
9106#endif
9107
Jeff Johnson295189b2012-06-20 16:38:30 -07009108 }while(0);
9109
9110 if(!HAL_STATUS_SUCCESS(status))
9111 {
9112 csrFreeScanFilter(pMac, pScanFilter);
9113 }
9114
9115 return(status);
9116}
9117
Jeff Johnson295189b2012-06-20 16:38:30 -07009118tANI_BOOLEAN csrRoamIssueWmStatusChange( tpAniSirGlobal pMac, tANI_U32 sessionId,
9119 eCsrRoamWmStatusChangeTypes Type, tSirSmeRsp *pSmeRsp )
9120{
9121 tANI_BOOLEAN fCommandQueued = eANI_BOOLEAN_FALSE;
9122 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -07009123 do
9124 {
9125 // Validate the type is ok...
9126 if ( ( eCsrDisassociated != Type ) && ( eCsrDeauthenticated != Type ) ) break;
9127 pCommand = csrGetCommandBuffer( pMac );
9128 if ( !pCommand )
9129 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009130 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009131 break;
9132 }
9133 //Change the substate in case it is waiting for key
9134 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId ) )
9135 {
9136 csrRoamStopWaitForKeyTimer( pMac );
9137 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
9138 }
9139 pCommand->command = eSmeCommandWmStatusChange;
9140 pCommand->sessionId = (tANI_U8)sessionId;
9141 pCommand->u.wmStatusChangeCmd.Type = Type;
9142 if ( eCsrDisassociated == Type )
9143 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309144 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg,
9145 pSmeRsp,
9146 sizeof( pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009147 }
9148 else
9149 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309150 vos_mem_copy(&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg,
9151 pSmeRsp,
9152 sizeof( pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg ));
Jeff Johnson295189b2012-06-20 16:38:30 -07009153 }
9154 if( HAL_STATUS_SUCCESS( csrQueueSmeCommand(pMac, pCommand, eANI_BOOLEAN_TRUE) ) )
9155 {
9156 fCommandQueued = eANI_BOOLEAN_TRUE;
9157 }
9158 else
9159 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009160 smsLog( pMac, LOGE, FL(" fail to send message ") );
Jeff Johnson295189b2012-06-20 16:38:30 -07009161 csrReleaseCommandWmStatusChange( pMac, pCommand );
9162 }
9163
Jeff Johnson295189b2012-06-20 16:38:30 -07009164 /* AP has issued Dissac/Deauth, Set the operating mode value to configured value */
9165 csrSetDefaultDot11Mode( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -07009166 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -07009167 return( fCommandQueued );
9168}
9169
Jeff Johnson295189b2012-06-20 16:38:30 -07009170static void csrUpdateRssi(tpAniSirGlobal pMac, void* pMsg)
9171{
9172 v_S7_t rssi = 0;
9173 tAniGetRssiReq *pGetRssiReq = (tAniGetRssiReq*)pMsg;
9174 if(pGetRssiReq)
9175 {
9176 if(NULL != pGetRssiReq->pVosContext)
9177 {
9178 WLANTL_GetRssi(pGetRssiReq->pVosContext, pGetRssiReq->staId, &rssi);
9179 }
9180 else
9181 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009182 smsLog( pMac, LOGE, FL("pGetRssiReq->pVosContext is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009183 return;
9184 }
9185
9186 if(NULL != pGetRssiReq->rssiCallback)
9187 {
9188 ((tCsrRssiCallback)(pGetRssiReq->rssiCallback))(rssi, pGetRssiReq->staId, pGetRssiReq->pDevContext);
9189 }
9190 else
9191 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009192 smsLog( pMac, LOGE, FL("pGetRssiReq->rssiCallback is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009193 return;
9194 }
9195 }
9196 else
9197 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009198 smsLog( pMac, LOGE, FL("pGetRssiReq is NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009199 }
9200 return;
9201}
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +05309202
9203static void csrUpdateSnr(tpAniSirGlobal pMac, void* pMsg)
9204{
9205 tANI_S8 snr = 0;
9206 tAniGetSnrReq *pGetSnrReq = (tAniGetSnrReq*)pMsg;
9207
9208 if (pGetSnrReq)
9209 {
9210 if (VOS_STATUS_SUCCESS !=
9211 WDA_GetSnr(pGetSnrReq->staId, &snr))
9212 {
9213 smsLog(pMac, LOGE, FL("Error in WLANTL_GetSnr"));
9214 return;
9215 }
9216
9217 if (pGetSnrReq->snrCallback)
9218 {
9219 ((tCsrSnrCallback)(pGetSnrReq->snrCallback))(snr, pGetSnrReq->staId,
9220 pGetSnrReq->pDevContext);
9221 }
9222 else
9223 {
9224 smsLog(pMac, LOGE, FL("pGetSnrReq->snrCallback is NULL"));
9225 return;
9226 }
9227 }
9228 else
9229 {
9230 smsLog(pMac, LOGE, FL("pGetSnrReq is NULL"));
9231 }
9232 return;
9233}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009234#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009235void csrRoamRssiRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9236{
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009237 tAniGetRoamRssiRsp* pRoamRssiRsp = (tAniGetRoamRssiRsp*)pMsg;
9238
Jeff Johnson36d483b2013-04-08 11:08:53 -07009239 if (NULL != pRoamRssiRsp)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009240 {
Jeff Johnson36d483b2013-04-08 11:08:53 -07009241 /* Get roam Rssi request is backed up and passed back to the response,
9242 Extract the request message to fetch callback */
9243 tpAniGetRssiReq reqBkp = (tAniGetRssiReq*)pRoamRssiRsp->rssiReq;
9244 v_S7_t rssi = pRoamRssiRsp->rssi;
9245
9246 if ((NULL != reqBkp) && (NULL != reqBkp->rssiCallback))
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009247 {
9248 ((tCsrRssiCallback)(reqBkp->rssiCallback))(rssi, pRoamRssiRsp->staId, reqBkp->pDevContext);
9249 reqBkp->rssiCallback = NULL;
9250 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009251 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009252 }
9253 else
9254 {
9255 smsLog( pMac, LOGE, FL("reqBkp->rssiCallback is NULL"));
9256 if (NULL != reqBkp)
9257 {
9258 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009259 pRoamRssiRsp->rssiReq = NULL;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -08009260 }
9261 }
9262 }
9263 else
9264 {
9265 smsLog( pMac, LOGE, FL("pRoamRssiRsp is NULL"));
9266 }
9267 return;
9268}
9269#endif
9270
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009271
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009272#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009273void csrTsmStatsRspProcessor(tpAniSirGlobal pMac, void* pMsg)
9274{
9275 tAniGetTsmStatsRsp* pTsmStatsRsp = (tAniGetTsmStatsRsp*)pMsg;
9276
9277 if (NULL != pTsmStatsRsp)
9278 {
9279 /* Get roam Rssi request is backed up and passed back to the response,
9280 Extract the request message to fetch callback */
9281 tpAniGetTsmStatsReq reqBkp = (tAniGetTsmStatsReq*)pTsmStatsRsp->tsmStatsReq;
9282
9283 if (NULL != reqBkp)
9284 {
9285 if (NULL != reqBkp->tsmStatsCallback)
9286 {
9287 ((tCsrTsmStatsCallback)(reqBkp->tsmStatsCallback))(pTsmStatsRsp->tsmMetrics,
9288 pTsmStatsRsp->staId, reqBkp->pDevContext);
9289 reqBkp->tsmStatsCallback = NULL;
9290 }
9291 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009292 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009293 }
9294 else
9295 {
9296 smsLog( pMac, LOGE, FL("reqBkp is NULL"));
9297 if (NULL != reqBkp)
9298 {
9299 vos_mem_free(reqBkp);
Kiran Kumar Lokere111cff42013-12-11 21:05:44 -08009300 pTsmStatsRsp->tsmStatsReq = NULL;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009301 }
9302 }
9303 }
9304 else
9305 {
9306 smsLog( pMac, LOGE, FL("pTsmStatsRsp is NULL"));
9307 }
9308 return;
9309}
9310
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009311void csrSendEseAdjacentApRepInd(tpAniSirGlobal pMac, tCsrRoamSession *pSession)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009312{
9313 tANI_U32 roamTS2 = 0;
9314 tCsrRoamInfo roamInfo;
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009315 tpPESession pSessionEntry = NULL;
9316 tANI_U8 sessionId = CSR_SESSION_ID_INVALID;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009317
9318 if (NULL == pSession)
9319 {
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009320 smsLog(pMac, LOGE, FL("pSession is NULL"));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009321 return;
9322 }
9323
9324 roamTS2 = vos_timer_get_system_time();
9325 roamInfo.tsmRoamDelay = roamTS2 - pSession->roamTS1;
Arif Hussaina7c8e412013-11-20 11:06:42 -08009326 smsLog(pMac, LOG1, "Bssid("MAC_ADDRESS_STR") Roaming Delay(%u ms)",
9327 MAC_ADDR_ARRAY(pSession->connectedProfile.bssid),
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009328 roamInfo.tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009329
Srinivas Girigowda026433f2013-10-28 11:51:55 -07009330 pSessionEntry = peFindSessionByBssid(pMac, pSession->connectedProfile.bssid, &sessionId);
9331 if (NULL == pSessionEntry)
9332 {
9333 smsLog(pMac, LOGE, FL("session %d not found"), sessionId);
9334 return;
9335 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009336 pSessionEntry->eseContext.tsm.tsmMetrics.RoamingDly = roamInfo.tsmRoamDelay;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009337 csrRoamCallCallback(pMac, pSession->sessionId, &roamInfo,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009338 0, eCSR_ROAM_ESE_ADJ_AP_REPORT_IND, 0);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009339}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009340#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07009341
Jeff Johnsone7245742012-09-05 17:12:55 -07009342static void csrRoamRssiIndHdlr(tpAniSirGlobal pMac, void* pMsg)
9343{
9344 WLANTL_TlIndicationReq *pTlRssiInd = (WLANTL_TlIndicationReq*)pMsg;
9345 if(pTlRssiInd)
9346 {
9347 if(NULL != pTlRssiInd->tlCallback)
9348 {
9349 ((WLANTL_RSSICrossThresholdCBType)(pTlRssiInd->tlCallback))
Srinivasdaaec712012-12-12 15:59:44 -08009350 (pTlRssiInd->pAdapter, pTlRssiInd->rssiNotification, pTlRssiInd->pUserCtxt, pTlRssiInd->avgRssi);
Jeff Johnsone7245742012-09-05 17:12:55 -07009351 }
9352 else
9353 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009354 smsLog( pMac, LOGE, FL("pTlRssiInd->tlCallback is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009355 }
9356 }
9357 else
9358 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009359 smsLog( pMac, LOGE, FL("pTlRssiInd is NULL"));
Jeff Johnsone7245742012-09-05 17:12:55 -07009360 }
9361 return;
9362}
Jeff Johnson295189b2012-06-20 16:38:30 -07009363
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309364eHalStatus csrSendResetApCapsChanged(tpAniSirGlobal pMac, tSirMacAddr *bssId)
9365{
9366 tpSirResetAPCapsChange pMsg;
9367 tANI_U16 len;
9368 eHalStatus status = eHAL_STATUS_SUCCESS;
9369
9370 /* Create the message and send to lim */
9371 len = sizeof(tSirResetAPCapsChange);
Kiet Lam64c1b492013-07-12 13:56:44 +05309372 pMsg = vos_mem_malloc(len);
9373 if ( NULL == pMsg )
9374 status = eHAL_STATUS_FAILURE;
9375 else
9376 status = eHAL_STATUS_SUCCESS;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309377 if (HAL_STATUS_SUCCESS(status))
9378 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309379 vos_mem_set(pMsg, sizeof(tSirResetAPCapsChange), 0);
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309380 pMsg->messageType = eWNI_SME_RESET_AP_CAPS_CHANGED;
9381 pMsg->length = len;
Kiet Lam64c1b492013-07-12 13:56:44 +05309382 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08009383 smsLog( pMac, LOG1, FL("CSR reset caps change for Bssid= "MAC_ADDRESS_STR),
9384 MAC_ADDR_ARRAY(pMsg->bssId));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309385 status = palSendMBMessage(pMac->hHdd, pMsg);
9386 }
9387 else
9388 {
9389 smsLog( pMac, LOGE, FL("Memory allocation failed\n"));
9390 }
9391 return status;
9392}
9393
Jeff Johnson295189b2012-06-20 16:38:30 -07009394void csrRoamCheckForLinkStatusChange( tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg )
9395{
9396 tSirSmeAssocInd *pAssocInd;
9397 tSirSmeDisassocInd *pDisassocInd;
9398 tSirSmeDeauthInd *pDeauthInd;
9399 tSirSmeWmStatusChangeNtf *pStatusChangeMsg;
9400 tSirSmeNewBssInfo *pNewBss;
9401 tSmeIbssPeerInd *pIbssPeerInd;
9402 tSirMacAddr Broadcastaddr = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
9403 tSirSmeApNewCaps *pApNewCaps;
9404 eCsrRoamResult result = eCSR_ROAM_RESULT_NONE;
9405 eRoamCmdStatus roamStatus = eCSR_ROAM_FAILED;
9406 tCsrRoamInfo *pRoamInfo = NULL;
9407 tCsrRoamInfo roamInfo;
9408 eHalStatus status;
9409 tANI_U32 sessionId = CSR_SESSION_ID_INVALID;
9410 tCsrRoamSession *pSession = NULL;
9411 tpSirSmeSwitchChannelInd pSwitchChnInd;
9412 tSmeMaxAssocInd *pSmeMaxAssocInd;
Kiet Lam64c1b492013-07-12 13:56:44 +05309413 vos_mem_set(&roamInfo, sizeof(roamInfo), 0);
krunal soni587bf012014-02-04 12:35:11 -08009414
9415
9416 if (NULL == pSirMsg)
9417 { smsLog(pMac, LOGE, FL("pSirMsg is NULL"));
9418 return;
9419 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009420 switch( pSirMsg->messageType )
9421 {
9422 case eWNI_SME_ASSOC_IND:
9423 {
9424 tCsrRoamSession *pSession;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009425 smsLog( pMac, LOG1, FL("ASSOCIATION Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009426 pAssocInd = (tSirSmeAssocInd *)pSirMsg;
9427 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pAssocInd->bssId, &sessionId );
9428 if( HAL_STATUS_SUCCESS( status ) )
9429 {
9430 pSession = CSR_GET_SESSION(pMac, sessionId);
9431
Jeff Johnson32d95a32012-09-10 13:15:23 -07009432 if(!pSession)
9433 {
9434 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9435 return;
9436 }
9437
Jeff Johnson295189b2012-06-20 16:38:30 -07009438 pRoamInfo = &roamInfo;
9439
9440 // Required for indicating the frames to upper layer
9441 pRoamInfo->assocReqLength = pAssocInd->assocReqLength;
9442 pRoamInfo->assocReqPtr = pAssocInd->assocReqPtr;
9443
9444 pRoamInfo->beaconPtr = pAssocInd->beaconPtr;
9445 pRoamInfo->beaconLength = pAssocInd->beaconLength;
9446 pRoamInfo->statusCode = eSIR_SME_SUCCESS; //send the status code as Success
9447 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9448
9449 pRoamInfo->staId = (tANI_U8)pAssocInd->staId;
9450 pRoamInfo->rsnIELen = (tANI_U8)pAssocInd->rsnIE.length;
9451 pRoamInfo->prsnIE = pAssocInd->rsnIE.rsnIEdata;
9452
9453 pRoamInfo->addIELen = (tANI_U8)pAssocInd->addIE.length;
9454 pRoamInfo->paddIE = pAssocInd->addIE.addIEdata;
Kiet Lam64c1b492013-07-12 13:56:44 +05309455 vos_mem_copy(pRoamInfo->peerMac, pAssocInd->peerMacAddr,
9456 sizeof(tSirMacAddr));
9457 vos_mem_copy(&pRoamInfo->bssid, pAssocInd->bssId,
9458 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009459 pRoamInfo->wmmEnabledSta = pAssocInd->wmmEnabledSta;
9460 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -07009461 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_WDS_IND, eCSR_ROAM_RESULT_WDS_ASSOCIATION_IND);//Sta
Jeff Johnson295189b2012-06-20 16:38:30 -07009462 if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile))
9463 {
9464 if( CSR_IS_ENC_TYPE_STATIC( pSession->pCurRoamProfile->negotiatedUCEncryptionType ))
9465 {
9466 csrRoamIssueSetContextReq( pMac, sessionId, pSession->pCurRoamProfile->negotiatedUCEncryptionType,
9467 pSession->pConnectBssDesc,
9468 &(pRoamInfo->peerMac),
9469 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
9470 pRoamInfo->fAuthRequired = FALSE;
9471 }
9472 else
9473 {
9474 pRoamInfo->fAuthRequired = TRUE;
9475 }
9476 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_IND);
9477 if (!HAL_STATUS_SUCCESS(status))
9478 pRoamInfo->statusCode = eSIR_SME_ASSOC_REFUSED;// Refused due to Mac filtering
9479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009480 /* Send Association completion message to PE */
9481 status = csrSendAssocCnfMsg( pMac, pAssocInd, status );//Sta
9482
9483 /* send a message to CSR itself just to avoid the EAPOL frames going
9484 * OTA before association response */
Jeff Johnson295189b2012-06-20 16:38:30 -07009485 if(CSR_IS_WDS_AP( pRoamInfo->u.pConnectedProfile))
9486 {
9487 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009489 else if(CSR_IS_INFRA_AP(pRoamInfo->u.pConnectedProfile) && (pRoamInfo->statusCode != eSIR_SME_ASSOC_REFUSED))
9490 {
9491 pRoamInfo->fReassocReq = pAssocInd->reassocReq;
9492 //status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_INFRA_ASSOCIATION_CNF);
9493 status = csrSendAssocIndToUpperLayerCnfMsg(pMac, pAssocInd, status, sessionId);
9494 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009495 }
9496 }
9497 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009498 case eWNI_SME_DISASSOC_IND:
Jeff Johnson295189b2012-06-20 16:38:30 -07009499 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309500 // Check if AP dis-associated us because of MIC failure. If so,
9501 // then we need to take action immediately and not wait till the
9502 // the WmStatusChange requests is pushed and processed
9503 tSmeCmd *pCommand;
9504
9505 pDisassocInd = (tSirSmeDisassocInd *)pSirMsg;
9506 status = csrRoamGetSessionIdFromBSSID( pMac,
9507 (tCsrBssid *)pDisassocInd->bssId, &sessionId );
9508 if( HAL_STATUS_SUCCESS( status ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07009509 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309510 smsLog( pMac, LOGE, FL("DISASSOCIATION Indication from MAC"
9511 " for session %d "), sessionId);
9512 smsLog( pMac, LOGE, FL("DISASSOCIATION from peer ="
9513 MAC_ADDRESS_STR " "
9514 " reason = %d status = %d "),
9515 MAC_ADDR_ARRAY(pDisassocInd->peerMacAddr),
9516 pDisassocInd->reasonCode,
9517 pDisassocInd->statusCode);
9518 // If we are in neighbor preauth done state then on receiving
9519 // disassoc or deauth we dont roam instead we just disassoc
9520 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009521 // This happens for ESE and 11r FT connections ONLY.
Agarwal Ashish4f616132013-12-30 23:32:50 +05309522#ifdef WLAN_FEATURE_VOWIFI_11R
9523 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9524 {
9525 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9526 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009527#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009528#ifdef FEATURE_WLAN_ESE
9529 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Agarwal Ashish4f616132013-12-30 23:32:50 +05309530 {
9531 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009533#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009534#ifdef FEATURE_WLAN_LFR
Agarwal Ashish4f616132013-12-30 23:32:50 +05309535 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
9536 {
9537 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9538 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009539#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309540 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -07009541
Agarwal Ashish4f616132013-12-30 23:32:50 +05309542 if (!pSession)
9543 {
9544 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9545 return;
9546 }
Jeff Johnson32d95a32012-09-10 13:15:23 -07009547
Agarwal Ashish4f616132013-12-30 23:32:50 +05309548 if ( csrIsConnStateInfra( pMac, sessionId ) )
9549 {
9550 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009552#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Agarwal Ashish4f616132013-12-30 23:32:50 +05309553 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
Jeff Johnson295189b2012-06-20 16:38:30 -07009554#endif
Agarwal Ashish4f616132013-12-30 23:32:50 +05309555 csrRoamLinkDown(pMac, sessionId);
9556 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDisassociated, pSirMsg );
9557 if (CSR_IS_INFRA_AP(&pSession->connectedProfile))
9558 {
Agarwal Ashish4f616132013-12-30 23:32:50 +05309559 pRoamInfo = &roamInfo;
9560 pRoamInfo->statusCode = pDisassocInd->statusCode;
9561 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9562 pRoamInfo->staId = (tANI_U8)pDisassocInd->staId;
Jeff Johnson295189b2012-06-20 16:38:30 -07009563
Agarwal Ashish4f616132013-12-30 23:32:50 +05309564 vos_mem_copy(pRoamInfo->peerMac, pDisassocInd->peerMacAddr,
9565 sizeof(tSirMacAddr));
9566 vos_mem_copy(&pRoamInfo->bssid, pDisassocInd->bssId,
9567 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009568
Agarwal Ashish4f616132013-12-30 23:32:50 +05309569 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
9570 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DISASSOC_IND);
Jeff Johnson295189b2012-06-20 16:38:30 -07009571
Agarwal Ashish4f616132013-12-30 23:32:50 +05309572 /*
9573 * STA/P2P client got disassociated so remove any pending deauth
9574 * commands in sme pending list
9575 */
Kaushik, Sushant488df382014-03-05 11:43:47 +05309576 pCommand = csrGetCommandBuffer(pMac);
9577 if (NULL == pCommand)
9578 {
9579 smsLog( pMac, LOGE, FL(" fail to get command buffer") );
9580 status = eHAL_STATUS_RESOURCES;
9581 return;
9582 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309583 pCommand->command = eSmeCommandRoam;
9584 pCommand->sessionId = (tANI_U8)sessionId;
9585 pCommand->u.roamCmd.roamReason = eCsrForcedDeauthSta;
9586 vos_mem_copy(pCommand->u.roamCmd.peerMac,
9587 pDisassocInd->peerMacAddr,
9588 sizeof(tSirMacAddr));
9589 csrRoamRemoveDuplicateCommand(pMac, sessionId, pCommand, eCsrForcedDeauthSta);
9590 csrReleaseCommand( pMac, pCommand );
Jeff Johnson295189b2012-06-20 16:38:30 -07009591
Agarwal Ashish4f616132013-12-30 23:32:50 +05309592 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009593 }
Agarwal Ashish4f616132013-12-30 23:32:50 +05309594 else
9595 {
9596 smsLog(pMac, LOGE, FL(" Session Id not found for BSSID " MAC_ADDRESS_STR),
9597 MAC_ADDR_ARRAY(pDisassocInd->bssId));
9598 }
Kiet Lam82004c62013-11-11 13:24:28 +05309599 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009600 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009601 case eWNI_SME_DEAUTH_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009602 smsLog( pMac, LOG1, FL("DEAUTHENTICATION Indication from MAC"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009603 pDeauthInd = (tpSirSmeDeauthInd)pSirMsg;
9604 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pDeauthInd->bssId, &sessionId );
9605 if( HAL_STATUS_SUCCESS( status ) )
9606 {
9607 // If we are in neighbor preauth done state then on receiving
9608 // disassoc or deauth we dont roam instead we just disassoc
9609 // from current ap and then go to disconnected state
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009610 // This happens for ESE and 11r FT connections ONLY.
Jeff Johnson295189b2012-06-20 16:38:30 -07009611#ifdef WLAN_FEATURE_VOWIFI_11R
9612 if (csrRoamIs11rAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
9613 {
9614 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9615 }
9616#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08009617#ifdef FEATURE_WLAN_ESE
9618 if (csrRoamIsESEAssoc(pMac) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson295189b2012-06-20 16:38:30 -07009619 {
9620 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9621 }
9622#endif
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009623#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +05309624 if (csrRoamIsFastRoamEnabled(pMac, sessionId) && (csrNeighborRoamStatePreauthDone(pMac)))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07009625 {
9626 csrNeighborRoamTranistionPreauthDoneToDisconnected(pMac);
9627 }
9628#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07009629 pSession = CSR_GET_SESSION( pMac, sessionId );
9630
Jeff Johnson32d95a32012-09-10 13:15:23 -07009631 if(!pSession)
9632 {
9633 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9634 return;
9635 }
9636
Jeff Johnson295189b2012-06-20 16:38:30 -07009637 if ( csrIsConnStateInfra( pMac, sessionId ) )
9638 {
9639 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
9640 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009641#ifndef WLAN_MDM_CODE_REDUCTION_OPT
9642 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_DISCONNECT_IND, NULL);
9643#endif
9644 csrRoamLinkDown(pMac, sessionId);
9645 csrRoamIssueWmStatusChange( pMac, sessionId, eCsrDeauthenticated, pSirMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -07009646 if(CSR_IS_INFRA_AP(&pSession->connectedProfile))
9647 {
9648
9649 pRoamInfo = &roamInfo;
9650
9651 pRoamInfo->statusCode = pDeauthInd->statusCode;
9652 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
9653
9654 pRoamInfo->staId = (tANI_U8)pDeauthInd->staId;
9655
Kiet Lam64c1b492013-07-12 13:56:44 +05309656 vos_mem_copy(pRoamInfo->peerMac, pDeauthInd->peerMacAddr,
9657 sizeof(tSirMacAddr));
9658 vos_mem_copy(&pRoamInfo->bssid, pDeauthInd->bssId,
9659 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009660
9661 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_DEAUTH_IND);
9662 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009663 }
9664 break;
9665
9666 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 -08009667 smsLog( pMac, LOGW, FL("eWNI_SME_SWITCH_CHL_REQ from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009668 pSwitchChnInd = (tpSirSmeSwitchChannelInd)pSirMsg;
9669 //Update with the new channel id.
9670 //The channel id is hidden in the statusCode.
9671 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pSwitchChnInd->bssId, &sessionId );
9672 if( HAL_STATUS_SUCCESS( status ) )
9673 {
9674 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009675 if(!pSession)
9676 {
9677 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9678 return;
9679 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009680 pSession->connectedProfile.operationChannel = (tANI_U8)pSwitchChnInd->newChannelId;
9681 if(pSession->pConnectBssDesc)
9682 {
9683 pSession->pConnectBssDesc->channelId = (tANI_U8)pSwitchChnInd->newChannelId;
9684 }
9685 }
9686 break;
9687
9688 case eWNI_SME_DEAUTH_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009689 smsLog( pMac, LOGW, FL("eWNI_SME_DEAUTH_RSP from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009690 {
9691 tSirSmeDeauthRsp* pDeauthRsp = (tSirSmeDeauthRsp *)pSirMsg;
9692 sessionId = pDeauthRsp->sessionId;
9693 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9694 {
9695 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009696 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9697 {
9698 pRoamInfo = &roamInfo;
9699 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309700 vos_mem_copy(pRoamInfo->peerMac, pDeauthRsp->peerMacAddr,
9701 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009702 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9703 pRoamInfo->statusCode = pDeauthRsp->statusCode;
9704 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9705 }
9706 }
9707 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009708 break;
9709
9710 case eWNI_SME_DISASSOC_RSP:
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -07009711 /* session id is invalid here so cant use it to access the array curSubstate as index */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009712 smsLog( pMac, LOGW, FL("eWNI_SME_DISASSOC_RSP from SME "));
Jeff Johnson295189b2012-06-20 16:38:30 -07009713 {
9714 tSirSmeDisassocRsp *pDisassocRsp = (tSirSmeDisassocRsp *)pSirMsg;
9715 sessionId = pDisassocRsp->sessionId;
9716 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
9717 {
9718 pSession = CSR_GET_SESSION(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07009719 if ( CSR_IS_INFRA_AP(&pSession->connectedProfile) )
9720 {
9721 pRoamInfo = &roamInfo;
9722 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
Kiet Lam64c1b492013-07-12 13:56:44 +05309723 vos_mem_copy(pRoamInfo->peerMac, pDisassocRsp->peerMacAddr,
9724 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -07009725 pRoamInfo->reasonCode = eCSR_ROAM_RESULT_FORCED;
9726 pRoamInfo->statusCode = pDisassocRsp->statusCode;
9727 status = csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_LOSTLINK, eCSR_ROAM_RESULT_FORCED);
9728 }
9729 }
9730 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009731 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009732 case eWNI_SME_MIC_FAILURE_IND:
9733 {
9734 tpSirSmeMicFailureInd pMicInd = (tpSirSmeMicFailureInd)pSirMsg;
9735 tCsrRoamInfo roamInfo, *pRoamInfo = NULL;
9736 eCsrRoamResult result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
Leo Chang9b01ad92013-09-12 17:26:56 -07009737
9738 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pMicInd->bssId, &sessionId );
9739 if( HAL_STATUS_SUCCESS( status ) )
9740 {
Kiet Lamf2f201e2013-11-16 21:24:16 +05309741 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Leo Chang9b01ad92013-09-12 17:26:56 -07009742 roamInfo.u.pMICFailureInfo = &pMicInd->info;
9743 pRoamInfo = &roamInfo;
9744 if(pMicInd->info.multicast)
9745 {
9746 result = eCSR_ROAM_RESULT_MIC_ERROR_GROUP;
9747 }
9748 else
9749 {
9750 result = eCSR_ROAM_RESULT_MIC_ERROR_UNICAST;
9751 }
9752 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_MIC_ERROR_IND, result);
9753 }
9754
Jeff Johnson295189b2012-06-20 16:38:30 -07009755#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9756 {
lukez3c809222013-05-03 10:23:02 -07009757 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Jeff Johnson295189b2012-06-20 16:38:30 -07009758 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009759 if(!pSession)
9760 {
9761 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9762 return;
9763 }
lukez3c809222013-05-03 10:23:02 -07009764
Kiet Lam64c1b492013-07-12 13:56:44 +05309765 vos_mem_set(&secEvent, sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009766 secEvent.eventId = WLAN_SECURITY_EVENT_MIC_ERROR;
9767 secEvent.encryptionModeMulticast =
9768 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
9769 secEvent.encryptionModeUnicast =
9770 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
9771 secEvent.authMode =
9772 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
Kiet Lam64c1b492013-07-12 13:56:44 +05309773 vos_mem_copy(secEvent.bssid,
9774 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009775 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
9776 }
9777#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009778 }
9779 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009780 case eWNI_SME_WPS_PBC_PROBE_REQ_IND:
9781 {
9782 tpSirSmeProbeReqInd pProbeReqInd = (tpSirSmeProbeReqInd)pSirMsg;
9783 tCsrRoamInfo roamInfo;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009784 smsLog( pMac, LOG1, FL("WPS PBC Probe request Indication from SME"));
Jeff Johnson295189b2012-06-20 16:38:30 -07009785
9786 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pProbeReqInd->bssId, &sessionId );
9787 if( HAL_STATUS_SUCCESS( status ) )
9788 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309789 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -07009790 roamInfo.u.pWPSPBCProbeReq = &pProbeReqInd->WPSPBCProbeReq;
9791 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_WPS_PBC_PROBE_REQ_IND,
9792 eCSR_ROAM_RESULT_WPS_PBC_PROBE_REQ_IND);
9793 }
9794 }
9795 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009796
Jeff Johnson295189b2012-06-20 16:38:30 -07009797 case eWNI_SME_WM_STATUS_CHANGE_NTF:
9798 pStatusChangeMsg = (tSirSmeWmStatusChangeNtf *)pSirMsg;
9799 switch( pStatusChangeMsg->statusChangeCode )
9800 {
9801 case eSIR_SME_IBSS_ACTIVE:
9802 sessionId = csrFindIbssSession( pMac );
9803 if( CSR_SESSION_ID_INVALID != sessionId )
9804 {
9805 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009806 if(!pSession)
9807 {
9808 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9809 return;
9810 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009811 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_CONNECTED;
9812 if(pSession->pConnectBssDesc)
9813 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309814 vos_mem_copy(&roamInfo.bssid,
9815 pSession->pConnectBssDesc->bssId,
9816 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009817 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
9818 pRoamInfo = &roamInfo;
9819 }
9820 else
9821 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009822 smsLog(pMac, LOGE, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -07009823 }
9824 result = eCSR_ROAM_RESULT_IBSS_CONNECT;
9825 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9826 }
9827 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009828 case eSIR_SME_IBSS_INACTIVE:
9829 sessionId = csrFindIbssSession( pMac );
9830 if( CSR_SESSION_ID_INVALID != sessionId )
9831 {
9832 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009833 if(!pSession)
9834 {
9835 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9836 return;
9837 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009838 pSession->connectState = eCSR_ASSOC_STATE_TYPE_IBSS_DISCONNECTED;
9839 result = eCSR_ROAM_RESULT_IBSS_INACTIVE;
9840 roamStatus = eCSR_ROAM_CONNECT_STATUS_UPDATE;
9841 }
9842 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009843 case eSIR_SME_JOINED_NEW_BSS: // IBSS coalescing.
9844 sessionId = csrFindIbssSession( pMac );
9845 if( CSR_SESSION_ID_INVALID != sessionId )
9846 {
9847 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009848 if(!pSession)
9849 {
9850 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9851 return;
9852 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009853 // update the connection state information
9854 pNewBss = &pStatusChangeMsg->statusChangeInfo.newBssInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -07009855#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9856 {
9857 vos_log_ibss_pkt_type *pIbssLog;
9858 tANI_U32 bi;
Jeff Johnson295189b2012-06-20 16:38:30 -07009859 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9860 if(pIbssLog)
9861 {
9862 pIbssLog->eventId = WLAN_IBSS_EVENT_COALESCING;
9863 if(pNewBss)
9864 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309865 vos_mem_copy(pIbssLog->bssid, pNewBss->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009866 if(pNewBss->ssId.length)
9867 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309868 vos_mem_copy(pIbssLog->ssid, pNewBss->ssId.ssId,
9869 pNewBss->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -07009870 }
9871 pIbssLog->operatingChannel = pNewBss->channelNumber;
9872 }
9873 if(HAL_STATUS_SUCCESS(ccmCfgGetInt(pMac, WNI_CFG_BEACON_INTERVAL, &bi)))
9874 {
9875 //***U8 is not enough for beacon interval
9876 pIbssLog->beaconInterval = (v_U8_t)bi;
9877 }
9878 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9879 }
9880 }
9881#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009882 csrRoamUpdateConnectedProfileFromNewBss( pMac, sessionId, pNewBss );
Shailender Karmuchi642e9812013-05-30 14:34:49 -07009883
9884 if ((eCSR_ENCRYPT_TYPE_NONE ==
9885 pSession->connectedProfile.EncryptionType ))
9886 {
9887 csrRoamIssueSetContextReq( pMac, sessionId,
9888 pSession->connectedProfile.EncryptionType,
9889 pSession->pConnectBssDesc,
9890 &Broadcastaddr,
9891 FALSE, FALSE, eSIR_TX_RX, 0, 0, NULL, 0 );
9892 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009893 result = eCSR_ROAM_RESULT_IBSS_COALESCED;
9894 roamStatus = eCSR_ROAM_IBSS_IND;
Kiet Lam64c1b492013-07-12 13:56:44 +05309895 vos_mem_copy(&roamInfo.bssid, &pNewBss->bssId,
9896 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009897 pRoamInfo = &roamInfo;
9898 //This BSSID is th ereal BSSID, let's save it
9899 if(pSession->pConnectBssDesc)
9900 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309901 vos_mem_copy(pSession->pConnectBssDesc->bssId,
9902 &pNewBss->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009903 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009904 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009905 smsLog(pMac, LOGW, "CSR: eSIR_SME_JOINED_NEW_BSS received from PE");
Jeff Johnson295189b2012-06-20 16:38:30 -07009906 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009907 // detection by LIM that the capabilities of the associated AP have changed.
9908 case eSIR_SME_AP_CAPS_CHANGED:
9909 pApNewCaps = &pStatusChangeMsg->statusChangeInfo.apNewCaps;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -08009910 smsLog(pMac, LOGW, "CSR handling eSIR_SME_AP_CAPS_CHANGED");
Jeff Johnson295189b2012-06-20 16:38:30 -07009911 status = csrRoamGetSessionIdFromBSSID( pMac, (tCsrBssid *)pApNewCaps->bssId, &sessionId );
9912 if( HAL_STATUS_SUCCESS( status ) )
9913 {
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009914 if ((eCSR_ROAMING_STATE_JOINED == pMac->roam.curState[sessionId]) &&
9915 ((eCSR_ROAM_SUBSTATE_JOINED_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309916 (eCSR_ROAM_SUBSTATE_NONE == pMac->roam.curSubState[sessionId]) ||
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009917 (eCSR_ROAM_SUBSTATE_JOINED_NON_REALTIME_TRAFFIC == pMac->roam.curSubState[sessionId]) ||
9918 (eCSR_ROAM_SUBSTATE_JOINED_NO_TRAFFIC == pMac->roam.curSubState[sessionId]))
9919 )
9920 {
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309921 smsLog(pMac, LOGW, "Calling csrRoamDisconnectInternal");
9922 csrRoamDisconnectInternal(pMac, sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009923 }
9924 else
9925 {
9926 smsLog(pMac, LOGW,
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +05309927 FL("Skipping csrScanForCapabilityChange as "
9928 "CSR is in state %s and sub-state %s"),
9929 macTraceGetcsrRoamState(
9930 pMac->roam.curState[sessionId]),
9931 macTraceGetcsrRoamSubState(
9932 pMac->roam.curSubState[sessionId]));
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309933 /* We ignore the caps change event if CSR is not in full connected state.
9934 * Send one event to PE to reset limSentCapsChangeNtf
9935 * Once limSentCapsChangeNtf set 0, lim can send sub sequent CAPS change event
9936 * otherwise lim cannot send any CAPS change events to SME */
9937 csrSendResetApCapsChanged(pMac, &pApNewCaps->bssId);
Madan Mohan Koyyalamudi30743902012-11-27 15:41:45 -08009938 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009939 }
9940 break;
Gopichand Nakkalacca24d12013-03-07 17:05:07 +05309941
Jeff Johnson295189b2012-06-20 16:38:30 -07009942 default:
9943 roamStatus = eCSR_ROAM_FAILED;
9944 result = eCSR_ROAM_RESULT_NONE;
9945 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009946 } // end switch on statusChangeCode
9947 if(eCSR_ROAM_RESULT_NONE != result)
9948 {
9949 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, roamStatus, result);
9950 }
9951 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07009952 case eWNI_SME_IBSS_NEW_PEER_IND:
9953 pIbssPeerInd = (tSmeIbssPeerInd *)pSirMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -07009954#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
9955 {
9956 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -07009957 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
9958 if(pIbssLog)
9959 {
9960 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_JOIN;
Kiet Lam64c1b492013-07-12 13:56:44 +05309961 vos_mem_copy(pIbssLog->peerMacAddr, &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -07009962 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
9963 }
9964 }
9965#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -07009966 sessionId = csrFindIbssSession( pMac );
9967 if( CSR_SESSION_ID_INVALID != sessionId )
9968 {
9969 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -07009970
9971 if(!pSession)
9972 {
9973 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
9974 return;
9975 }
Jeff Johnson295189b2012-06-20 16:38:30 -07009976 // Issue the set Context request to LIM to establish the Unicast STA context for the new peer...
9977 if(pSession->pConnectBssDesc)
9978 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309979 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
9980 sizeof(tCsrBssid));
9981 vos_mem_copy(&roamInfo.bssid, pSession->pConnectBssDesc->bssId,
9982 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -07009983 if(pIbssPeerInd->mesgLen > sizeof(tSmeIbssPeerInd))
9984 {
Kiet Lam64c1b492013-07-12 13:56:44 +05309985 roamInfo.pbFrames = vos_mem_malloc((pIbssPeerInd->mesgLen
9986 - sizeof(tSmeIbssPeerInd)));
9987 if ( NULL == roamInfo.pbFrames )
9988 status = eHAL_STATUS_FAILURE;
9989 else
9990 status = eHAL_STATUS_SUCCESS;
9991 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -07009992 {
9993 roamInfo.nBeaconLength = (pIbssPeerInd->mesgLen - sizeof(tSmeIbssPeerInd));
Kiet Lam64c1b492013-07-12 13:56:44 +05309994 vos_mem_copy(roamInfo.pbFrames,
9995 ((tANI_U8 *)pIbssPeerInd) + sizeof(tSmeIbssPeerInd),
9996 roamInfo.nBeaconLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07009997 }
9998 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
9999 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10000 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010001 roamInfo.pBssDesc = vos_mem_malloc(pSession->pConnectBssDesc->length);
10002 if ( NULL == roamInfo.pBssDesc )
10003 status = eHAL_STATUS_FAILURE;
10004 else
10005 status = eHAL_STATUS_SUCCESS;
10006 if (HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070010007 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010008 vos_mem_copy(roamInfo.pBssDesc,
10009 pSession->pConnectBssDesc,
10010 pSession->pConnectBssDesc->length);
Jeff Johnson295189b2012-06-20 16:38:30 -070010011 }
10012 if(HAL_STATUS_SUCCESS(status))
10013 {
10014 pRoamInfo = &roamInfo;
10015 }
10016 else
10017 {
10018 if(roamInfo.pbFrames)
10019 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010020 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010021 }
10022 if(roamInfo.pBssDesc)
10023 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010024 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010025 }
10026 }
10027 }
10028 else
10029 {
10030 pRoamInfo = &roamInfo;
10031 }
Shailender Karmuchi642e9812013-05-30 14:34:49 -070010032 if ((eCSR_ENCRYPT_TYPE_NONE ==
10033 pSession->connectedProfile.EncryptionType ))
10034 {
10035 csrRoamIssueSetContextReq( pMac, sessionId,
10036 pSession->connectedProfile.EncryptionType,
10037 pSession->pConnectBssDesc,
10038 &(pIbssPeerInd->peerAddr),
10039 FALSE, TRUE, eSIR_TX_RX, 0, 0, NULL, 0 ); // NO keys... these key parameters don't matter.
10040 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010041 }
10042 else
10043 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010044 smsLog(pMac, LOGW, " CSR eSIR_SME_IBSS_NEW_PEER connected BSS is empty");
Jeff Johnson295189b2012-06-20 16:38:30 -070010045 }
10046 //send up the sec type for the new peer
10047 if (pRoamInfo)
10048 {
10049 pRoamInfo->u.pConnectedProfile = &pSession->connectedProfile;
10050 }
10051 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0,
10052 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_NEW_PEER);
10053 if(pRoamInfo)
10054 {
10055 if(roamInfo.pbFrames)
10056 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010057 vos_mem_free(roamInfo.pbFrames);
Jeff Johnson295189b2012-06-20 16:38:30 -070010058 }
10059 if(roamInfo.pBssDesc)
10060 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010061 vos_mem_free(roamInfo.pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -070010062 }
10063 }
10064 }
10065 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010066 case eWNI_SME_IBSS_PEER_DEPARTED_IND:
10067 pIbssPeerInd = (tSmeIbssPeerInd*)pSirMsg;
10068 sessionId = csrFindIbssSession( pMac );
10069 if( CSR_SESSION_ID_INVALID != sessionId )
10070 {
Jeff Johnson295189b2012-06-20 16:38:30 -070010071#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10072 {
10073 vos_log_ibss_pkt_type *pIbssLog;
10074
10075 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
10076 if(pIbssLog)
10077 {
10078 pIbssLog->eventId = WLAN_IBSS_EVENT_PEER_LEAVE;
10079 if(pIbssPeerInd)
10080 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010081 vos_mem_copy(pIbssLog->peerMacAddr,
10082 &pIbssPeerInd->peerAddr, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010083 }
10084 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
10085 }
10086 }
10087#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010088 smsLog(pMac, LOGW, "CSR: Peer departed notification from LIM");
Jeff Johnson295189b2012-06-20 16:38:30 -070010089 roamInfo.staId = (tANI_U8)pIbssPeerInd->staId;
10090 roamInfo.ucastSig = (tANI_U8)pIbssPeerInd->ucastSig;
10091 roamInfo.bcastSig = (tANI_U8)pIbssPeerInd->bcastSig;
Kiet Lam64c1b492013-07-12 13:56:44 +053010092 vos_mem_copy(&roamInfo.peerMac, pIbssPeerInd->peerAddr,
10093 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010094 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10095 eCSR_ROAM_CONNECT_STATUS_UPDATE, eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED);
10096 }
10097 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010098 case eWNI_SME_SETCONTEXT_RSP:
10099 {
10100 tSirSmeSetContextRsp *pRsp = (tSirSmeSetContextRsp *)pSirMsg;
10101 tListElem *pEntry;
10102 tSmeCmd *pCommand;
10103
10104 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10105 if ( pEntry )
10106 {
10107 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10108 if ( eSmeCommandSetKey == pCommand->command )
10109 {
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010110 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010111 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010112
10113 if(!pSession)
10114 {
10115 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10116 return;
10117 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010118
10119#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10120 if(eCSR_ENCRYPT_TYPE_NONE != pSession->connectedProfile.EncryptionType)
10121 {
10122 WLAN_VOS_DIAG_EVENT_DEF(setKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010123 vos_mem_set(&setKeyEvent,
10124 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010125 if( pRsp->peerMacAddr[0] & 0x01 )
10126 {
10127 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_GTK_RSP;
10128 }
10129 else
10130 {
10131 setKeyEvent.eventId = WLAN_SECURITY_EVENT_SET_PTK_RSP;
10132 }
10133 setKeyEvent.encryptionModeMulticast =
10134 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10135 setKeyEvent.encryptionModeUnicast =
10136 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010137 vos_mem_copy(setKeyEvent.bssid,
10138 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010139 setKeyEvent.authMode =
10140 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010141 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010142 {
10143 setKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10144 }
10145 WLAN_VOS_DIAG_EVENT_REPORT(&setKeyEvent, EVENT_WLAN_SECURITY);
10146 }
10147#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
10148 if( CSR_IS_WAIT_FOR_KEY( pMac, sessionId) )
10149 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010150 csrRoamStopWaitForKeyTimer( pMac );
10151
Jeff Johnson295189b2012-06-20 16:38:30 -070010152 //We are done with authentication, whethere succeed or not
10153 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_NONE, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070010154 //We do it here because this linkup function is not called after association
10155 //when a key needs to be set.
10156 if( csrIsConnStateConnectedInfra(pMac, sessionId) )
10157 {
10158 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10159 }
10160 }
Jeff Johnson43971f52012-07-17 12:26:56 -070010161 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010162 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010163 vos_mem_copy(&roamInfo.peerMac,
10164 &pRsp->peerMacAddr, sizeof(tCsrBssid));
Jeff Johnsone7245742012-09-05 17:12:55 -070010165 //Make sure we install the GTK before indicating to HDD as authenticated
10166 //This is to prevent broadcast packets go out after PTK and before GTK.
Kiet Lam64c1b492013-07-12 13:56:44 +053010167 if ( vos_mem_compare( &Broadcastaddr, pRsp->peerMacAddr,
10168 sizeof(tSirMacAddr) ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070010169 {
Yathish9f22e662012-12-10 14:21:35 -080010170#ifdef WLAN_ACTIVEMODE_OFFLOAD_FEATURE
10171 if(IS_ACTIVEMODE_OFFLOAD_FEATURE_ENABLE)
10172 {
10173 tpSirSetActiveModeSetBncFilterReq pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053010174 pMsg = vos_mem_malloc(sizeof(tSirSetActiveModeSetBncFilterReq));
Yathish9f22e662012-12-10 14:21:35 -080010175 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_BCN_FILTER_REQ);
10176 pMsg->length = pal_cpu_to_be16(sizeof( tANI_U8));
10177 pMsg->seesionId = sessionId;
10178 status = palSendMBMessage(pMac->hHdd, pMsg );
10179 }
10180#endif
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010181 /* OBSS SCAN Indication will be sent to Firmware to start OBSS Scan */
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010182 if( CSR_IS_CHANNEL_24GHZ(pSession->connectedProfile.operationChannel)
10183 && IS_HT40_OBSS_SCAN_FEATURE_ENABLE )
10184 {
10185 tpSirSmeHT40OBSSScanInd pMsg;
10186 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSScanInd));
10187 pMsg->messageType =
10188 pal_cpu_to_be16((tANI_U16)eWNI_SME_HT40_OBSS_SCAN_IND);
10189 pMsg->length =
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010190 pal_cpu_to_be16(sizeof( tSirSmeHT40OBSSScanInd));
10191 vos_mem_copy(pMsg->peerMacAddr,
10192 pSession->connectedProfile.bssid,
10193 sizeof(tSirMacAddr));
Sandeep Puligilla332ea912014-02-04 00:16:24 +053010194 status = palSendMBMessage(pMac->hHdd,
10195 pMsg );
10196 }
10197 result = eCSR_ROAM_RESULT_AUTHENTICATED;
Jeff Johnsone7245742012-09-05 17:12:55 -070010198 }
10199 else
10200 {
10201 result = eCSR_ROAM_RESULT_NONE;
10202 }
Sandeep Puligilla9f384742014-04-11 02:27:04 +053010203 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010204 }
10205 else
10206 {
10207 result = eCSR_ROAM_RESULT_FAILURE;
Arif Hussaina7c8e412013-11-20 11:06:42 -080010208 smsLog(pMac, LOGE, "CSR: Roam Completion setkey "
10209 "command failed(%d) PeerMac "MAC_ADDRESS_STR,
10210 pRsp->statusCode, MAC_ADDR_ARRAY(pRsp->peerMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070010211 }
10212 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10213 eCSR_ROAM_SET_KEY_COMPLETE, result);
Jeff Johnson295189b2012-06-20 16:38:30 -070010214 // Indicate SME_QOS that the SET_KEY is completed, so that SME_QOS
10215 // can go ahead and initiate the TSPEC if any are pending
10216 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_SET_KEY_SUCCESS_IND, NULL);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010217#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070010218 //Send Adjacent AP repot to new AP.
10219 if (result == eCSR_ROAM_RESULT_AUTHENTICATED &&
10220 pSession->isPrevApInfoValid &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010221 pSession->connectedProfile.isESEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070010222 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010223#ifdef FEATURE_WLAN_ESE_UPLOAD
10224 csrSendEseAdjacentApRepInd(pMac, pSession);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010225#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010226 csrEseSendAdjacentApRepMsg(pMac, pSession);
Jeff Johnson295189b2012-06-20 16:38:30 -070010227#endif
10228 pSession->isPrevApInfoValid = FALSE;
10229 }
10230#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010231 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10232 {
10233 csrReleaseCommandSetKey( pMac, pCommand );
10234 }
10235 }
10236 else
10237 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010238 smsLog( pMac, LOGE, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010239 }
10240 }
10241 else
10242 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010243 smsLog( pMac, LOGE, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010244 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010245 smeProcessPendingQueue( pMac );
10246 }
10247 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010248 case eWNI_SME_REMOVEKEY_RSP:
10249 {
10250 tSirSmeRemoveKeyRsp *pRsp = (tSirSmeRemoveKeyRsp *)pSirMsg;
10251 tListElem *pEntry;
10252 tSmeCmd *pCommand;
10253
10254 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10255 if ( pEntry )
10256 {
10257 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10258 if ( eSmeCommandRemoveKey == pCommand->command )
10259 {
10260 sessionId = pCommand->sessionId;
10261 pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010262
10263 if(!pSession)
10264 {
10265 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10266 return;
10267 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010268#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
10269 {
10270 WLAN_VOS_DIAG_EVENT_DEF(removeKeyEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053010271 vos_mem_set(&removeKeyEvent,
10272 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010273 removeKeyEvent.eventId = WLAN_SECURITY_EVENT_REMOVE_KEY_RSP;
10274 removeKeyEvent.encryptionModeMulticast =
10275 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
10276 removeKeyEvent.encryptionModeUnicast =
10277 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053010278 vos_mem_copy( removeKeyEvent.bssid,
10279 pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070010280 removeKeyEvent.authMode =
10281 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
lukez3c809222013-05-03 10:23:02 -070010282 if( eSIR_SME_SUCCESS != pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010283 {
10284 removeKeyEvent.status = WLAN_SECURITY_STATUS_FAILURE;
10285 }
10286 WLAN_VOS_DIAG_EVENT_REPORT(&removeKeyEvent, EVENT_WLAN_SECURITY);
10287 }
10288#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson43971f52012-07-17 12:26:56 -070010289 if( eSIR_SME_SUCCESS == pRsp->statusCode )
Jeff Johnson295189b2012-06-20 16:38:30 -070010290 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010291 vos_mem_copy(&roamInfo.peerMac, &pRsp->peerMacAddr,
10292 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010293 result = eCSR_ROAM_RESULT_NONE;
10294 pRoamInfo = &roamInfo;
10295 }
10296 else
10297 {
10298 result = eCSR_ROAM_RESULT_FAILURE;
10299 }
10300 csrRoamCallCallback(pMac, sessionId, &roamInfo, pCommand->u.setKeyCmd.roamId,
10301 eCSR_ROAM_REMOVE_KEY_COMPLETE, result);
10302 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10303 {
10304 csrReleaseCommandRemoveKey( pMac, pCommand );
10305 }
10306 }
10307 else
10308 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010309 smsLog( pMac, LOGW, "CSR: Roam Completion called but setkey command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010310 }
10311 }
10312 else
10313 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010314 smsLog( pMac, LOGW, "CSR: SetKey Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010315 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010316 smeProcessPendingQueue( pMac );
10317 }
10318 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010319 case eWNI_SME_GET_STATISTICS_RSP:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010320 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010321 csrRoamStatsRspProcessor( pMac, pSirMsg );
10322 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010323#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080010324 case eWNI_SME_GET_ROAM_RSSI_RSP:
10325 smsLog( pMac, LOG2, FL("Stats rsp from PE"));
10326 csrRoamRssiRspProcessor( pMac, pSirMsg );
10327 break;
10328#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010329#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070010330 case eWNI_SME_GET_TSM_STATS_RSP:
10331 smsLog( pMac, LOG2, FL("TSM Stats rsp from PE"));
10332 csrTsmStatsRspProcessor( pMac, pSirMsg );
10333 break;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080010334#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -070010335 case eWNI_SME_GET_RSSI_REQ:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010336 smsLog( pMac, LOG2, FL("GetRssiReq from self"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010337 csrUpdateRssi( pMac, pSirMsg );
10338 break;
10339
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053010340 case eWNI_SME_GET_SNR_REQ:
10341 smsLog( pMac, LOG2, FL("GetSnrReq from self"));
10342 csrUpdateSnr(pMac, pSirMsg);
10343 break;
10344
Jeff Johnson295189b2012-06-20 16:38:30 -070010345#ifdef WLAN_FEATURE_VOWIFI_11R
10346 case eWNI_SME_FT_PRE_AUTH_RSP:
10347 csrRoamFTPreAuthRspProcessor( pMac, (tpSirFTPreAuthRsp)pSirMsg );
10348 break;
10349#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010350 case eWNI_SME_MAX_ASSOC_EXCEEDED:
10351 pSmeMaxAssocInd = (tSmeMaxAssocInd*)pSirMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010352 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 -070010353 sessionId = pSmeMaxAssocInd->sessionId;
10354 roamInfo.sessionId = sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053010355 vos_mem_copy(&roamInfo.peerMac, pSmeMaxAssocInd->peerMac,
10356 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070010357 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
10358 eCSR_ROAM_INFRA_IND, eCSR_ROAM_RESULT_MAX_ASSOC_EXCEEDED);
10359 break;
10360
10361 case eWNI_SME_BTAMP_LOG_LINK_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010362 smsLog( pMac, LOG1, FL("Establish logical link req from HCI serialized through MC thread"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010363 btampEstablishLogLinkHdlr( pSirMsg );
10364 break;
Jeff Johnsone7245742012-09-05 17:12:55 -070010365 case eWNI_SME_RSSI_IND:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010366 smsLog( pMac, LOG1, FL("RSSI indication from TL serialized through MC thread"));
Jeff Johnsone7245742012-09-05 17:12:55 -070010367 csrRoamRssiIndHdlr( pMac, pSirMsg );
10368 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010369#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
10370 case eWNI_SME_CANDIDATE_FOUND_IND:
10371 smsLog( pMac, LOG2, FL("Candidate found indication from PE"));
10372 csrNeighborRoamCandidateFoundIndHdlr( pMac, pSirMsg );
10373 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070010374 case eWNI_SME_HANDOFF_REQ:
10375 smsLog( pMac, LOG2, FL("Handoff Req from self"));
10376 csrNeighborRoamHandoffReqHdlr( pMac, pSirMsg );
10377 break;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070010378#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070010379
10380 default:
10381 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010382 } // end switch on message type
Jeff Johnson295189b2012-06-20 16:38:30 -070010383}
10384
Jeff Johnson295189b2012-06-20 16:38:30 -070010385void csrCallRoamingCompletionCallback(tpAniSirGlobal pMac, tCsrRoamSession *pSession,
10386 tCsrRoamInfo *pRoamInfo, tANI_U32 roamId, eCsrRoamResult roamResult)
10387{
10388 if(pSession)
10389 {
10390 if(pSession->bRefAssocStartCnt)
10391 {
10392 pSession->bRefAssocStartCnt--;
10393 VOS_ASSERT( pSession->bRefAssocStartCnt == 0);
10394 //Need to call association_completion because there is an assoc_start pending.
10395 csrRoamCallCallback(pMac, pSession->sessionId, NULL, roamId,
10396 eCSR_ROAM_ASSOCIATION_COMPLETION,
10397 eCSR_ROAM_RESULT_FAILURE);
10398 }
10399 csrRoamCallCallback(pMac, pSession->sessionId, pRoamInfo, roamId, eCSR_ROAM_ROAMING_COMPLETION, roamResult);
10400 }
10401 else
10402 {
10403 smsLog(pMac, LOGW, FL(" pSession is NULL"));
10404 }
10405}
10406
10407
10408eHalStatus csrRoamStartRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamingReason roamingReason)
10409{
10410 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010411 if(CSR_IS_LOSTLINK_ROAMING(roamingReason) &&
10412 (eANI_BOOLEAN_FALSE == pMac->roam.roamSession[sessionId].fCancelRoaming))
10413 {
10414 status = csrScanRequestLostLink1( pMac, sessionId );
10415 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010416 return(status);
10417}
10418
Jeff Johnson295189b2012-06-20 16:38:30 -070010419//return a boolean to indicate whether roaming completed or continue.
10420tANI_BOOLEAN csrRoamCompleteRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId,
10421 tANI_BOOLEAN fForce, eCsrRoamResult roamResult)
10422{
10423 tANI_BOOLEAN fCompleted = eANI_BOOLEAN_TRUE;
10424 tANI_TIMESTAMP roamTime = (tANI_TIMESTAMP)(pMac->roam.configParam.nRoamingTime * PAL_TICKS_PER_SECOND);
10425 tANI_TIMESTAMP curTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10426 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010427 if(!pSession)
10428 {
10429 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10430 return eANI_BOOLEAN_FALSE;
10431 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010432 //Check whether time is up
10433 if(pSession->fCancelRoaming || fForce ||
10434 ((curTime - pSession->roamingStartTime) > roamTime) ||
10435 eCsrReassocRoaming == pSession->roamingReason ||
10436 eCsrDynamicRoaming == pSession->roamingReason)
10437 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010438 smsLog(pMac, LOGW, FL(" indicates roaming completion"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010439 if(pSession->fCancelRoaming && CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason))
10440 {
10441 //roaming is cancelled, tell HDD to indicate disconnect
10442 //Because LIM overload deauth_ind for both deauth frame and missed beacon
10443 //we need to use this logic to detinguish it. For missed beacon, LIM set reason
10444 //to be eSIR_BEACON_MISSED
10445 if(eSIR_BEACON_MISSED == pSession->roamingStatusCode)
10446 {
10447 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10448 }
10449 else if(eCsrLostlinkRoamingDisassoc == pSession->roamingReason)
10450 {
10451 roamResult = eCSR_ROAM_RESULT_DISASSOC_IND;
10452 }
10453 else if(eCsrLostlinkRoamingDeauth == pSession->roamingReason)
10454 {
10455 roamResult = eCSR_ROAM_RESULT_DEAUTH_IND;
10456 }
10457 else
10458 {
10459 roamResult = eCSR_ROAM_RESULT_LOSTLINK;
10460 }
10461 }
10462 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10463 pSession->roamingReason = eCsrNotRoaming;
10464 }
10465 else
10466 {
10467 pSession->roamResult = roamResult;
10468 if(!HAL_STATUS_SUCCESS(csrRoamStartRoamingTimer(pMac, sessionId, PAL_TIMER_TO_SEC_UNIT)))
10469 {
10470 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, roamResult);
10471 pSession->roamingReason = eCsrNotRoaming;
10472 }
10473 else
10474 {
10475 fCompleted = eANI_BOOLEAN_FALSE;
10476 }
10477 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010478 return(fCompleted);
10479}
10480
Jeff Johnson295189b2012-06-20 16:38:30 -070010481void csrRoamCancelRoaming(tpAniSirGlobal pMac, tANI_U32 sessionId)
10482{
10483 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010484
10485 if(!pSession)
10486 {
10487 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10488 return;
10489 }
10490
Jeff Johnson295189b2012-06-20 16:38:30 -070010491 if(CSR_IS_ROAMING(pSession))
10492 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010493 smsLog(pMac, LOGW, " Cancelling roaming");
Jeff Johnson295189b2012-06-20 16:38:30 -070010494 pSession->fCancelRoaming = eANI_BOOLEAN_TRUE;
10495 if(CSR_IS_ROAM_JOINING(pMac, sessionId) && CSR_IS_ROAM_SUBSTATE_CONFIG(pMac, sessionId))
10496 {
10497 //No need to do anything in here because the handler takes care of it
10498 }
10499 else
10500 {
10501 eCsrRoamResult roamResult = CSR_IS_LOSTLINK_ROAMING(pSession->roamingReason) ?
10502 eCSR_ROAM_RESULT_LOSTLINK : eCSR_ROAM_RESULT_NONE;
10503 //Roaming is stopped after here
10504 csrRoamCompleteRoaming(pMac, sessionId, eANI_BOOLEAN_TRUE, roamResult);
10505 //Since CSR may be in lostlink roaming situation, abort all roaming related activities
Srinivas, Dasari138af4f2014-02-07 11:13:45 +053010506 csrScanAbortMacScan(pMac, sessionId, eCSR_SCAN_ABORT_DEFAULT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010507 csrRoamStopRoamingTimer(pMac, sessionId);
10508 }
10509 }
10510}
10511
Jeff Johnson295189b2012-06-20 16:38:30 -070010512void csrRoamRoamingTimerHandler(void *pv)
10513{
10514 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10515 tpAniSirGlobal pMac = pInfo->pMac;
10516 tANI_U32 sessionId = pInfo->sessionId;
10517 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010518
10519 if(!pSession)
10520 {
10521 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10522 return;
10523 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010524
10525 if(eANI_BOOLEAN_FALSE == pSession->fCancelRoaming)
10526 {
10527 if(!HAL_STATUS_SUCCESS(csrRoamStartRoaming(pMac, sessionId, pSession->roamingReason)))
10528 {
10529 csrCallRoamingCompletionCallback(pMac, pSession, NULL, 0, pSession->roamResult);
10530 pSession->roamingReason = eCsrNotRoaming;
10531 }
10532 }
10533}
10534
Jeff Johnson295189b2012-06-20 16:38:30 -070010535eHalStatus csrRoamStartRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
10536{
10537 eHalStatus status;
10538 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010539
10540 if(!pSession)
10541 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010542 smsLog(pMac, LOGE, FL(" session %d not found"), sessionId);
Jeff Johnson32d95a32012-09-10 13:15:23 -070010543 return eHAL_STATUS_FAILURE;
10544 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010545
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010546 smsLog(pMac, LOG1, " csrScanStartRoamingTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070010547 pSession->roamingTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010548 status = vos_timer_start(&pSession->hTimerRoaming, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010549
10550 return (status);
10551}
10552
Jeff Johnson295189b2012-06-20 16:38:30 -070010553eHalStatus csrRoamStopRoamingTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
10554{
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010555 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerRoaming));
Jeff Johnson295189b2012-06-20 16:38:30 -070010556}
10557
Jeff Johnson295189b2012-06-20 16:38:30 -070010558void csrRoamWaitForKeyTimeOutHandler(void *pv)
10559{
10560 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
10561 tpAniSirGlobal pMac = pInfo->pMac;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010562 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pInfo->sessionId );
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010563 eHalStatus status = eHAL_STATUS_FAILURE;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010564
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010565 smsLog(pMac, LOGW, FL("WaitForKey timer expired in state=%s sub-state=%s"),
10566 macTraceGetNeighbourRoamState(
10567 pMac->roam.neighborRoamInfo.neighborRoamState),
10568 macTraceGetcsrRoamSubState(
10569 pMac->roam.curSubState[pInfo->sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010570
Jeff Johnson295189b2012-06-20 16:38:30 -070010571 if( CSR_IS_WAIT_FOR_KEY( pMac, pInfo->sessionId ) )
10572 {
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010573#ifdef FEATURE_WLAN_LFR
10574 if (csrNeighborRoamIsHandoffInProgress(pMac))
10575 {
10576 /*
10577 * Enable heartbeat timer when hand-off is in progress
10578 * and Key Wait timer expired.
10579 */
10580 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey expiry"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010581 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010582 pMac->roam.configParam.HeartbeatThresh24);
10583 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10584 pMac->roam.configParam.HeartbeatThresh24,
10585 NULL, eANI_BOOLEAN_FALSE);
10586 }
10587#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010588 smsLog(pMac, LOGW, " SME pre-auth state timeout. ");
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010589
Jeff Johnson295189b2012-06-20 16:38:30 -070010590 //Change the substate so command queue is unblocked.
Praveen Kumar Sirisilla8bdfac42013-10-10 17:20:48 -070010591 if (CSR_ROAM_SESSION_MAX > pInfo->sessionId)
10592 {
10593 csrRoamSubstateChange(pMac, eCSR_ROAM_SUBSTATE_NONE,
10594 pInfo->sessionId);
10595 }
10596
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010597 if (pSession)
10598 {
10599 if( csrIsConnStateConnectedInfra(pMac, pInfo->sessionId) )
10600 {
10601 csrRoamLinkUp(pMac, pSession->connectedProfile.bssid);
10602 smeProcessPendingQueue(pMac);
Leela Venkata Kiran Kumar Reddy Chiralaecc44b92013-12-13 20:14:35 -080010603 if( (pSession->connectedProfile.AuthType ==
10604 eCSR_AUTH_TYPE_SHARED_KEY) &&
10605 ( (pSession->connectedProfile.EncryptionType ==
10606 eCSR_ENCRYPT_TYPE_WEP40) ||
10607 (pSession->connectedProfile.EncryptionType ==
10608 eCSR_ENCRYPT_TYPE_WEP104) ))
10609 {
10610 status = sme_AcquireGlobalLock( &pMac->sme );
10611 if ( HAL_STATUS_SUCCESS( status ) )
10612 {
10613 csrRoamDisconnect( pMac, pInfo->sessionId,
10614 eCSR_DISCONNECT_REASON_UNSPECIFIED );
10615 sme_ReleaseGlobalLock( &pMac->sme );
10616 }
10617 }
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010618 }
10619 else
10620 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010621 smsLog(pMac, LOGW, "%s: could not post link up",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010622 __func__);
10623 }
10624 }
10625 else
10626 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010627 smsLog(pMac, LOGW, "%s: session not found", __func__);
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010628 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010629 }
10630
10631}
10632
Jeff Johnson295189b2012-06-20 16:38:30 -070010633eHalStatus csrRoamStartWaitForKeyTimer(tpAniSirGlobal pMac, tANI_U32 interval)
10634{
10635 eHalStatus status;
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010636#ifdef FEATURE_WLAN_LFR
10637 if (csrNeighborRoamIsHandoffInProgress(pMac))
10638 {
10639 /* Disable heartbeat timer when hand-off is in progress */
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010640 smsLog(pMac, LOG2, FL("disabling HB timer in state=%s sub-state=%s"),
10641 macTraceGetNeighbourRoamState(
10642 pMac->roam.neighborRoamInfo.neighborRoamState),
10643 macTraceGetcsrRoamSubState(
10644 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]
10645 ));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010646 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD, 0, NULL, eANI_BOOLEAN_FALSE);
10647 }
10648#endif
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010649 smsLog(pMac, LOG1, " csrScanStartWaitForKeyTimer");
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010650 status = vos_timer_start(&pMac->roam.hTimerWaitForKey, interval/PAL_TIMER_TO_MS_UNIT);
Jeff Johnson295189b2012-06-20 16:38:30 -070010651
10652 return (status);
10653}
10654
Jeff Johnson295189b2012-06-20 16:38:30 -070010655eHalStatus csrRoamStopWaitForKeyTimer(tpAniSirGlobal pMac)
10656{
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053010657 smsLog(pMac, LOG2, FL("WaitForKey timer stopped in state=%s sub-state=%s"),
10658 macTraceGetNeighbourRoamState(
10659 pMac->roam.neighborRoamInfo.neighborRoamState),
10660 macTraceGetcsrRoamSubState(
10661 pMac->roam.curSubState[pMac->roam.WaitForKeyTimerInfo.sessionId]));
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010662#ifdef FEATURE_WLAN_LFR
10663 if (csrNeighborRoamIsHandoffInProgress(pMac))
10664 {
10665 /*
10666 * Enable heartbeat timer when hand-off is in progress
10667 * and Key Wait timer got stopped for some reason
10668 */
10669 smsLog(pMac, LOG2, "Enabling HB timer after WaitKey stop"
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010670 " (nHBCount=%d)",
Srikant Kuppae6812eb2012-12-27 17:34:52 -080010671 pMac->roam.configParam.HeartbeatThresh24);
10672 ccmCfgSetInt(pMac, WNI_CFG_HEART_BEAT_THRESHOLD,
10673 pMac->roam.configParam.HeartbeatThresh24,
10674 NULL, eANI_BOOLEAN_FALSE);
10675 }
10676#endif
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053010677 return (vos_timer_stop(&pMac->roam.hTimerWaitForKey));
Jeff Johnson295189b2012-06-20 16:38:30 -070010678}
10679
Jeff Johnson295189b2012-06-20 16:38:30 -070010680void csrRoamCompletion(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamInfo *pRoamInfo, tSmeCmd *pCommand,
10681 eCsrRoamResult roamResult, tANI_BOOLEAN fSuccess)
10682{
10683 eRoamCmdStatus roamStatus = csrGetRoamCompleteStatus(pMac, sessionId);
10684 tANI_U32 roamId = 0;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010685 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
10686 /* To silence the KW tool Null chaeck is added */
10687 if(!pSession)
10688 {
10689 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10690 return;
10691 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010692
10693 if(pCommand)
10694 {
10695 roamId = pCommand->u.roamCmd.roamId;
Jeff Johnson295189b2012-06-20 16:38:30 -070010696 VOS_ASSERT( sessionId == pCommand->sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070010697 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010698 if(eCSR_ROAM_ROAMING_COMPLETION == roamStatus)
10699 {
10700 //if success, force roaming completion
10701 csrRoamCompleteRoaming(pMac, sessionId, fSuccess, roamResult);
10702 }
10703 else
10704 {
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010705 VOS_ASSERT(pSession->bRefAssocStartCnt == 0);
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010706 smsLog(pMac, LOGW, FL(" indicates association completion. roamResult = %d"), roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -070010707 csrRoamCallCallback(pMac, sessionId, pRoamInfo, roamId, roamStatus, roamResult);
10708 }
10709}
10710
Jeff Johnson295189b2012-06-20 16:38:30 -070010711eHalStatus csrRoamLostLink( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 type, tSirSmeRsp *pSirMsg)
10712{
10713 eHalStatus status = eHAL_STATUS_SUCCESS;
10714 tSirSmeDeauthInd *pDeauthIndMsg = NULL;
10715 tSirSmeDisassocInd *pDisassocIndMsg = NULL;
10716 eCsrRoamResult result = eCSR_ROAM_RESULT_LOSTLINK;
10717 tCsrRoamInfo *pRoamInfo = NULL;
10718 tCsrRoamInfo roamInfo;
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010719 tANI_BOOLEAN fToRoam;
Jeff Johnson295189b2012-06-20 16:38:30 -070010720 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010721 /* To silence the KW tool Null chaeck is added */
10722 if(!pSession)
10723 {
10724 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10725 return eHAL_STATUS_FAILURE;
10726 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010727 //Only need to roam for infra station. In this case P2P client will roam as well
Madan Mohan Koyyalamudi33ef6a22012-10-30 17:44:43 -070010728 fToRoam = CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile);
Jeff Johnson295189b2012-06-20 16:38:30 -070010729 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
10730 if ( eWNI_SME_DISASSOC_IND == type )
10731 {
10732 result = eCSR_ROAM_RESULT_DISASSOC_IND;
10733 pDisassocIndMsg = (tSirSmeDisassocInd *)pSirMsg;
10734 pSession->roamingStatusCode = pDisassocIndMsg->statusCode;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010735 pSession->joinFailStatusCode.reasonCode = pDisassocIndMsg->reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010736 }
10737 else if ( eWNI_SME_DEAUTH_IND == type )
10738 {
10739 result = eCSR_ROAM_RESULT_DEAUTH_IND;
10740 pDeauthIndMsg = (tSirSmeDeauthInd *)pSirMsg;
10741 pSession->roamingStatusCode = pDeauthIndMsg->statusCode;
Madan Mohan Koyyalamudi6a808932012-11-06 16:05:54 -080010742 /* Convert into proper reason code */
10743 pSession->joinFailStatusCode.reasonCode =
10744 (pDeauthIndMsg->reasonCode == eSIR_BEACON_MISSED) ?
Agarwal Ashish838f1f32013-03-11 20:54:52 +053010745 0 : pDeauthIndMsg->reasonCode;
10746 /* cfg layer expects 0 as reason code if
10747 the driver dosent know the reason code
10748 eSIR_BEACON_MISSED is defined as locally */
Jeff Johnson295189b2012-06-20 16:38:30 -070010749 }
10750 else
10751 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010752 smsLog(pMac, LOGW, FL("gets an unknown type (%d)"), type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010753 result = eCSR_ROAM_RESULT_NONE;
Mohit Khanna99d5fd02012-09-11 14:51:20 -070010754 pSession->joinFailStatusCode.reasonCode = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -070010755 }
10756
10757 // call profile lost link routine here
Jeff Johnson295189b2012-06-20 16:38:30 -070010758 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Jeff Johnson295189b2012-06-20 16:38:30 -070010759 {
10760 csrRoamCallCallback(pMac, sessionId, NULL, 0, eCSR_ROAM_LOSTLINK_DETECTED, result);
10761 }
10762
10763 if ( eWNI_SME_DISASSOC_IND == type )
10764 {
10765 status = csrSendMBDisassocCnfMsg(pMac, pDisassocIndMsg);
10766 }
10767 else if ( eWNI_SME_DEAUTH_IND == type )
10768 {
10769 status = csrSendMBDeauthCnfMsg(pMac, pDeauthIndMsg);
10770 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010771 if(!HAL_STATUS_SUCCESS(status))
10772 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010773 //If fail to send confirmation to PE, not to trigger roaming
10774 fToRoam = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010775 }
10776
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010777 //prepare to tell HDD to disconnect
Kiet Lam64c1b492013-07-12 13:56:44 +053010778 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010779 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10780 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
Jeff Johnson295189b2012-06-20 16:38:30 -070010781 if( eWNI_SME_DISASSOC_IND == type)
10782 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010783 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010784 vos_mem_copy(roamInfo.peerMac, pDisassocIndMsg->peerMacAddr,
10785 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010786 roamInfo.staId = (tANI_U8)pDisassocIndMsg->staId;
10787 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010788 else if( eWNI_SME_DEAUTH_IND == type )
10789 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010790 //staMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053010791 vos_mem_copy(roamInfo.peerMac, pDeauthIndMsg->peerMacAddr,
10792 sizeof(tSirMacAddr));
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010793 roamInfo.staId = (tANI_U8)pDeauthIndMsg->staId;
10794 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010795 smsLog(pMac, LOGW, FL("roamInfo.staId (%d)"), roamInfo.staId);
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010796
10797 /* See if we can possibly roam. If so, start the roaming process and notify HDD
10798 that we are roaming. But if we cannot possibly roam, or if we are unable to
10799 currently roam, then notify HDD of the lost link */
Jeff Johnson295189b2012-06-20 16:38:30 -070010800 if(fToRoam)
10801 {
10802 //Only remove the connected BSS in infrastructure mode
10803 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10804 //Not to do anying for lostlink with WDS
10805 if( pMac->roam.configParam.nRoamingTime )
10806 {
10807 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac, sessionId,
10808 ( eWNI_SME_DEAUTH_IND == type ) ?
10809 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc)))
10810 {
Kiet Lam64c1b492013-07-12 13:56:44 +053010811 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070010812 //For IBSS, we need to give some more info to HDD
10813 if(csrIsBssTypeIBSS(pSession->connectedProfile.BSSType))
10814 {
10815 roamInfo.u.pConnectedProfile = &pSession->connectedProfile;
10816 roamInfo.statusCode = (tSirResultCodes)pSession->roamingStatusCode;
10817 roamInfo.reasonCode = pSession->joinFailStatusCode.reasonCode;
10818 }
10819 else
10820 {
10821 roamInfo.reasonCode = eCsrRoamReasonSmeIssuedForLostLink;
10822 }
Jeff Johnsone7245742012-09-05 17:12:55 -070010823 pRoamInfo = &roamInfo;
Jeff Johnson295189b2012-06-20 16:38:30 -070010824 pSession->roamingReason = ( eWNI_SME_DEAUTH_IND == type ) ?
10825 eCsrLostlinkRoamingDeauth : eCsrLostlinkRoamingDisassoc;
10826 pSession->roamingStartTime = (tANI_TIMESTAMP)palGetTickCount(pMac->hHdd);
10827 csrRoamCallCallback(pMac, sessionId, pRoamInfo, 0, eCSR_ROAM_ROAMING_START, eCSR_ROAM_RESULT_LOSTLINK);
10828 }
10829 else
10830 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -070010831 smsLog(pMac, LOGW, " %s Fail to start roaming, status = %d", __func__, status);
Jeff Johnson295189b2012-06-20 16:38:30 -070010832 fToRoam = eANI_BOOLEAN_FALSE;
10833 }
10834 }
10835 else
10836 {
10837 //We are told not to roam, indicate lostlink
10838 fToRoam = eANI_BOOLEAN_FALSE;
10839 }
10840 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010841 if(!fToRoam)
10842 {
Madan Mohan Koyyalamudiaf854cf2012-10-30 17:56:25 -070010843 //Tell HDD about the lost link
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010844 if(!CSR_IS_INFRA_AP(&pSession->connectedProfile))
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010845 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010846 /* Don't call csrRoamCallCallback for GO/SoftAp case as this indication
10847 * was already given as part of eWNI_SME_DISASSOC_IND msg handling in
10848 * csrRoamCheckForLinkStatusChange API.
10849 */
Madan Mohan Koyyalamudicd784992013-01-11 15:30:36 -080010850 csrRoamCallCallback(pMac, sessionId, &roamInfo, 0, eCSR_ROAM_LOSTLINK, result);
10851 }
10852
10853 /*No need to start idle scan in case of IBSS/SAP
Jeff Johnson295189b2012-06-20 16:38:30 -070010854 Still enable idle scan for polling in case concurrent sessions are running */
10855 if(CSR_IS_INFRASTRUCTURE(&pSession->connectedProfile))
10856 {
Jeff Johnsonfff4deb2013-02-17 10:32:30 -080010857 csrScanStartIdleScan(pMac);
Jeff Johnson295189b2012-06-20 16:38:30 -070010858 }
10859 }
10860
10861 return (status);
10862}
10863
Jeff Johnson295189b2012-06-20 16:38:30 -070010864eHalStatus csrRoamLostLinkAfterhandoffFailure( tpAniSirGlobal pMac,tANI_U32 sessionId)
10865{
10866 eHalStatus status = eHAL_STATUS_SUCCESS;
10867 tListElem *pEntry = NULL;
10868 tSmeCmd *pCommand = NULL;
10869 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010870
10871 if(!pSession)
10872 {
10873 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
10874 return eHAL_STATUS_FAILURE;
10875 }
10876
Jeff Johnson295189b2012-06-20 16:38:30 -070010877 pSession->fCancelRoaming = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070010878 //Only remove the connected BSS in infrastructure mode
10879 csrRoamRemoveConnectedBssFromScanCache(pMac, &pSession->connectedProfile);
10880 if(pMac->roam.configParam.nRoamingTime)
10881 {
10882 if(HAL_STATUS_SUCCESS(status = csrRoamStartRoaming(pMac,sessionId, pSession->roamingReason)))
10883 {
10884 //before starting the lost link logic release the roam command for handoff
10885 pEntry = csrLLPeekHead(&pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK);
10886 if(pEntry)
10887 {
10888 pCommand = GET_BASE_ADDR(pEntry, tSmeCmd, Link);
10889 }
10890 if(pCommand)
10891 {
10892 if (( eSmeCommandRoam == pCommand->command ) &&
10893 ( eCsrSmeIssuedAssocToSimilarAP == pCommand->u.roamCmd.roamReason))
10894 {
10895 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10896 {
10897 csrReleaseCommandRoam( pMac, pCommand );
10898 }
10899 }
10900 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010901 smsLog( pMac, LOGW, "Lost link roaming started ...");
Jeff Johnson295189b2012-06-20 16:38:30 -070010902 }
10903 }
10904 else
10905 {
10906 //We are told not to roam, indicate lostlink
10907 status = eHAL_STATUS_FAILURE;
10908 }
10909
10910 return (status);
10911}
Jeff Johnson295189b2012-06-20 16:38:30 -070010912void csrRoamWmStatusChangeComplete( tpAniSirGlobal pMac )
10913{
10914 tListElem *pEntry;
10915 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070010916 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
10917 if ( pEntry )
10918 {
10919 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
10920 if ( eSmeCommandWmStatusChange == pCommand->command )
10921 {
10922 // Nothing to process in a Lost Link completion.... It just kicks off a
10923 // roaming sequence.
10924 if( csrLLRemoveEntry( &pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK ) )
10925 {
10926 csrReleaseCommandWmStatusChange( pMac, pCommand );
10927 }
10928 else
10929 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010930 smsLog( pMac, LOGE, " ******csrRoamWmStatusChangeComplete fail to release command");
Jeff Johnson295189b2012-06-20 16:38:30 -070010931 }
10932
10933 }
10934 else
10935 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010936 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but LOST LINK command is not ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010937 }
10938 }
10939 else
10940 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010941 smsLog( pMac, LOGW, "CSR: WmStatusChange Completion called but NO commands are ACTIVE ..." );
Jeff Johnson295189b2012-06-20 16:38:30 -070010942 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010943 smeProcessPendingQueue( pMac );
10944}
10945
Jeff Johnson295189b2012-06-20 16:38:30 -070010946void csrRoamProcessWmStatusChangeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
10947{
10948 eHalStatus status = eHAL_STATUS_FAILURE;
10949 tSirSmeRsp *pSirSmeMsg;
10950 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, pCommand->sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070010951
10952 if(!pSession)
10953 {
10954 smsLog(pMac, LOGE, FL(" session %d not found "), pCommand->sessionId);
10955 return;
10956 }
10957
Jeff Johnson295189b2012-06-20 16:38:30 -070010958 switch ( pCommand->u.wmStatusChangeCmd.Type )
10959 {
10960 case eCsrDisassociated:
10961 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DisassocIndMsg;
10962 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DISASSOC_IND, pSirSmeMsg);
10963 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010964 case eCsrDeauthenticated:
10965 pSirSmeMsg = (tSirSmeRsp *)&pCommand->u.wmStatusChangeCmd.u.DeauthIndMsg;
10966 status = csrRoamLostLink(pMac, pCommand->sessionId, eWNI_SME_DEAUTH_IND, pSirSmeMsg);
10967 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070010968 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010969 smsLog(pMac, LOGW, FL("gets an unknown command %d"), pCommand->u.wmStatusChangeCmd.Type);
Jeff Johnson295189b2012-06-20 16:38:30 -070010970 break;
10971 }
10972 //For WDS, we want to stop BSS as well when it is indicated that it is disconnected.
10973 if( CSR_IS_CONN_WDS(&pSession->connectedProfile) )
10974 {
10975 if( !HAL_STATUS_SUCCESS(csrRoamIssueStopBssCmd( pMac, pCommand->sessionId, eANI_BOOLEAN_TRUE )) )
10976 {
10977 //This is not good
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080010978 smsLog(pMac, LOGE, FL(" failed to issue stopBSS command"));
Jeff Johnson295189b2012-06-20 16:38:30 -070010979 }
10980 }
Jeff Johnson295189b2012-06-20 16:38:30 -070010981 // Lost Link just triggers a roaming sequence. We can complte the Lost Link
10982 // command here since there is nothing else to do.
10983 csrRoamWmStatusChangeComplete( pMac );
10984}
10985
Jeff Johnson295189b2012-06-20 16:38:30 -070010986//This function returns band and mode information.
10987//The only tricky part is that if phyMode is set to 11abg, this function may return eCSR_CFG_DOT11_MODE_11B
10988//instead of eCSR_CFG_DOT11_MODE_11G if everything is set to auto-pick.
Jeff Johnson295189b2012-06-20 16:38:30 -070010989static eCsrCfgDot11Mode csrRoamGetPhyModeBandForBss( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
10990 tANI_U8 operationChn, eCsrBand *pBand )
Jeff Johnson295189b2012-06-20 16:38:30 -070010991{
Jeff Johnson295189b2012-06-20 16:38:30 -070010992 eCsrPhyMode phyModeIn = (eCsrPhyMode)pProfile->phyMode;
10993 eCsrCfgDot11Mode cfgDot11Mode = csrGetCfgDot11ModeFromCsrPhyMode(pProfile, phyModeIn,
10994 pMac->roam.configParam.ProprietaryRatesEnabled);
Jeff Johnson295189b2012-06-20 16:38:30 -070010995 eCsrBand eBand;
Madan Mohan Koyyalamudi4ff9cd62012-10-30 17:48:57 -070010996
Jeff Johnson295189b2012-06-20 16:38:30 -070010997 //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 -070010998 if( ((!CSR_IS_INFRA_AP(pProfile )&& !CSR_IS_WDS(pProfile )) &&
10999 ((eCSR_CFG_DOT11_MODE_AUTO == pMac->roam.configParam.uCfgDot11Mode) ||
11000 (eCSR_CFG_DOT11_MODE_ABG == pMac->roam.configParam.uCfgDot11Mode))) ||
11001 (eCSR_CFG_DOT11_MODE_AUTO == cfgDot11Mode) || (eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode) )
Jeff Johnson295189b2012-06-20 16:38:30 -070011002 {
11003 switch( pMac->roam.configParam.uCfgDot11Mode )
11004 {
11005 case eCSR_CFG_DOT11_MODE_11A:
11006 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11007 eBand = eCSR_BAND_5G;
11008 break;
11009 case eCSR_CFG_DOT11_MODE_11B:
11010 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11011 eBand = eCSR_BAND_24;
11012 break;
11013 case eCSR_CFG_DOT11_MODE_11G:
11014 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11015 eBand = eCSR_BAND_24;
11016 break;
11017 case eCSR_CFG_DOT11_MODE_11N:
11018 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011019 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11020 break;
11021#ifdef WLAN_FEATURE_11AC
11022 case eCSR_CFG_DOT11_MODE_11AC:
11023 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11024 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011025 /* If the operating channel is in 2.4 GHz band, check for
11026 * INI item to disable VHT operation in 2.4 GHz band
11027 */
11028 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11029 !pMac->roam.configParam.enableVhtFor24GHz)
11030 {
11031 /* Disable 11AC operation */
11032 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11033 }
11034 else
11035 {
11036 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11037 }
11038 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011039 }
11040 else
11041 {
11042 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11043 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11044 }
11045 break;
11046 case eCSR_CFG_DOT11_MODE_11AC_ONLY:
11047 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11048 {
Ravi Joshiacc81822013-10-10 15:30:41 -070011049 /* If the operating channel is in 2.4 GHz band, check for
11050 * INI item to disable VHT operation in 2.4 GHz band
11051 */
11052 if (CSR_IS_CHANNEL_24GHZ(operationChn) &&
11053 !pMac->roam.configParam.enableVhtFor24GHz)
11054 {
11055 /* Disable 11AC operation */
11056 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11057 }
11058 else
11059 {
11060 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC_ONLY;
11061 }
11062 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011063 }
11064 else
11065 {
11066 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11067 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11068 }
11069 break;
11070#endif
11071 case eCSR_CFG_DOT11_MODE_AUTO:
Ravi Joshia96ceb42013-05-20 18:52:39 -070011072#ifdef WLAN_FEATURE_11AC
Abhishek Singh03c39422014-09-24 10:52:30 +053011073 if (IS_FEATURE_SUPPORTED_BY_FW(DOT11AC))
11074 {
11075 /* 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)
Ravi Joshia96ceb42013-05-20 18:52:39 -070011080 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011081 /* Disable 11AC operation */
11082 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011083 }
11084 else
11085 {
Abhishek Singh03c39422014-09-24 10:52:30 +053011086 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11AC;
11087 }
11088 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11089 }
11090 else
11091 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011092 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11093 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
Ravi Joshia96ceb42013-05-20 18:52:39 -070011094 }
Abhishek Singh03c39422014-09-24 10:52:30 +053011095#else
11096 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11N;
11097 eBand = CSR_IS_CHANNEL_24GHZ(operationChn) ? eCSR_BAND_24 : eCSR_BAND_5G;
11098#endif
Ravi Joshia96ceb42013-05-20 18:52:39 -070011099 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011100 default:
11101 // Global dot11 Mode setting is 11a/b/g.
11102 // use the channel number to determine the Mode setting.
11103 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11104 {
11105 eBand = pMac->roam.configParam.eBand;
11106 if(eCSR_BAND_24 == eBand)
11107 {
11108 //See reason in else if ( CSR_IS_CHANNEL_24GHZ(operationChn) ) to pick 11B
11109 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11110 }
11111 else
11112 {
11113 //prefer 5GHz
11114 eBand = eCSR_BAND_5G;
11115 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11116 }
11117 }
11118 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11119 {
Ravi Joshia96ceb42013-05-20 18:52:39 -070011120 // WiFi tests require IBSS networks to start in 11b mode
11121 // without any change to the default parameter settings
11122 // on the adapter. We use ACU to start an IBSS through
11123 // creation of a startIBSS profile. This startIBSS profile
11124 // has Auto MACProtocol and the adapter property setting
11125 // for dot11Mode is also AUTO. So in this case, let's
11126 // start the IBSS network in 11b mode instead of 11g mode.
11127 // So this is for Auto=profile->MacProtocol && Auto=Global.
11128 // dot11Mode && profile->channel is < 14, then start the IBSS
11129 // in b mode.
Jeff Johnson295189b2012-06-20 16:38:30 -070011130 //
Ravi Joshia96ceb42013-05-20 18:52:39 -070011131 // Note: we used to have this start as an 11g IBSS for best
11132 // performance... now to specify that the user will have to
11133 // set the do11Mode in the property page to 11g to force it.
Jeff Johnson295189b2012-06-20 16:38:30 -070011134 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11135 eBand = eCSR_BAND_24;
11136 }
11137 else
11138 {
11139 // else, it's a 5.0GHz channel. Set mode to 11a.
11140 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11141 eBand = eCSR_BAND_5G;
11142 }
11143 break;
11144 }//switch
11145 }//if( eCSR_CFG_DOT11_MODE_ABG == cfgDot11Mode )
11146 else
11147 {
11148 //dot11 mode is set, lets pick the band
11149 if ( eCSR_OPERATING_CHANNEL_AUTO == operationChn )
11150 {
11151 // channel is Auto also.
11152 eBand = pMac->roam.configParam.eBand;
11153 if(eCSR_BAND_ALL == eBand)
11154 {
11155 //prefer 5GHz
11156 eBand = eCSR_BAND_5G;
11157 }
11158 }
11159 else if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11160 {
11161 eBand = eCSR_BAND_24;
11162 }
11163 else
11164 {
11165 eBand = eCSR_BAND_5G;
11166 }
Ravi Joshia96ceb42013-05-20 18:52:39 -070011167 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011168 if(pBand)
11169 {
11170 *pBand = eBand;
11171 }
11172
11173 if (operationChn == 14){
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011174 smsLog(pMac, LOGE, FL(" Switching to Dot11B mode "));
Jeff Johnson295189b2012-06-20 16:38:30 -070011175 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11B;
11176 }
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011177
Madan Mohan Koyyalamudi5ec4b182012-11-28 16:15:17 -080011178 /* Incase of WEP Security encryption type is coming as part of add key. So while STart BSS dont have information */
11179 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 -070011180 ((eCSR_CFG_DOT11_MODE_11N == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011181#ifdef WLAN_FEATURE_11AC
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011182 (eCSR_CFG_DOT11_MODE_11AC == cfgDot11Mode) ||
Madan Mohan Koyyalamudi91f8e9f2012-10-22 15:11:56 -070011183#endif
Madan Mohan Koyyalamudi84a8b2e2012-10-22 15:15:14 -070011184 (eCSR_CFG_DOT11_MODE_TAURUS == cfgDot11Mode)) )
11185 {
11186 //We cannot do 11n here
11187 if ( CSR_IS_CHANNEL_24GHZ(operationChn) )
11188 {
11189 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11G;
11190 }
11191 else
11192 {
11193 cfgDot11Mode = eCSR_CFG_DOT11_MODE_11A;
11194 }
11195 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011196 return( cfgDot11Mode );
11197}
11198
Jeff Johnson295189b2012-06-20 16:38:30 -070011199eHalStatus csrRoamIssueStopBss( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamSubState NewSubstate )
11200{
11201 eHalStatus status;
11202 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011203
11204 if(!pSession)
11205 {
11206 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11207 return eHAL_STATUS_FAILURE;
11208 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011209
11210#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11211 {
11212 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011213 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11214 if(pIbssLog)
11215 {
11216 pIbssLog->eventId = WLAN_IBSS_EVENT_STOP_REQ;
11217 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11218 }
11219 }
11220#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070011221 // Set the roaming substate to 'stop Bss request'...
11222 csrRoamSubstateChange( pMac, NewSubstate, sessionId );
11223
11224 // attempt to stop the Bss (reason code is ignored...)
11225 status = csrSendMBStopBssReqMsg( pMac, sessionId );
Gopichand Nakkala9b89a732012-12-31 16:31:46 -080011226 if(!HAL_STATUS_SUCCESS(status))
11227 {
11228 smsLog(pMac, LOGW, FL("csrSendMBStopBssReqMsg failed with status %d"), status);
11229 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011230 return (status);
11231}
11232
Jeff Johnson295189b2012-06-20 16:38:30 -070011233//pNumChan is a caller allocated space with the sizeof pChannels
11234eHalStatus csrGetCfgValidChannels(tpAniSirGlobal pMac, tANI_U8 *pChannels, tANI_U32 *pNumChan)
11235{
11236
11237 return (ccmCfgGetStr(pMac, WNI_CFG_VALID_CHANNEL_LIST,
11238 (tANI_U8 *)pChannels,
11239 pNumChan));
11240}
11241
Kiran4a17ebe2013-01-31 10:43:43 -080011242tPowerdBm csrGetCfgMaxTxPower (tpAniSirGlobal pMac, tANI_U8 channel)
11243{
11244 tANI_U32 cfgLength = 0;
11245 tANI_U16 cfgId = 0;
11246 tPowerdBm maxTxPwr = 0;
11247 tANI_U8 *pCountryInfo = NULL;
11248 eHalStatus status;
11249 tANI_U8 count = 0;
11250 tANI_U8 firstChannel;
11251 tANI_U8 maxChannels;
11252
11253 if (CSR_IS_CHANNEL_5GHZ(channel))
11254 {
11255 cfgId = WNI_CFG_MAX_TX_POWER_5;
11256 cfgLength = WNI_CFG_MAX_TX_POWER_5_LEN;
11257 }
11258 else if (CSR_IS_CHANNEL_24GHZ(channel))
11259 {
11260 cfgId = WNI_CFG_MAX_TX_POWER_2_4;
11261 cfgLength = WNI_CFG_MAX_TX_POWER_2_4_LEN;
11262 }
11263 else
11264 return maxTxPwr;
11265
Kiet Lam64c1b492013-07-12 13:56:44 +053011266 pCountryInfo = vos_mem_malloc(cfgLength);
11267 if ( NULL == pCountryInfo )
11268 status = eHAL_STATUS_FAILURE;
11269 else
11270 status = eHAL_STATUS_SUCCESS;
Kiran4a17ebe2013-01-31 10:43:43 -080011271 if (status != eHAL_STATUS_SUCCESS)
11272 {
11273 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Kiet Lam64c1b492013-07-12 13:56:44 +053011274 FL("%s: failed to allocate memory, status = %d"),
Kiran4a17ebe2013-01-31 10:43:43 -080011275 __FUNCTION__, status);
11276 goto error;
11277 }
11278 status = ccmCfgGetStr(pMac, cfgId, (tANI_U8 *)pCountryInfo, &cfgLength);
11279 if (status != eHAL_STATUS_SUCCESS)
11280 {
11281 goto error;
11282 }
11283 /* Identify the channel and maxtxpower */
11284 while (count <= (cfgLength - (sizeof(tSirMacChanInfo))))
11285 {
11286 firstChannel = pCountryInfo[count++];
11287 maxChannels = pCountryInfo[count++];
11288 maxTxPwr = pCountryInfo[count++];
11289
11290 if ((channel >= firstChannel) &&
11291 (channel < (firstChannel + maxChannels)))
11292 {
11293 break;
11294 }
11295 }
11296
11297error:
11298 if (NULL != pCountryInfo)
Kiet Lam64c1b492013-07-12 13:56:44 +053011299 vos_mem_free(pCountryInfo);
Kiran4a17ebe2013-01-31 10:43:43 -080011300
11301 return maxTxPwr;
11302}
11303
11304
Jeff Johnson295189b2012-06-20 16:38:30 -070011305tANI_BOOLEAN csrRoamIsChannelValid( tpAniSirGlobal pMac, tANI_U8 channel )
11306{
11307 tANI_BOOLEAN fValid = FALSE;
11308 tANI_U32 idxValidChannels;
11309 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11310
11311 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &len)))
11312 {
11313 for ( idxValidChannels = 0; ( idxValidChannels < len ); idxValidChannels++ )
11314 {
11315 if ( channel == pMac->roam.validChannelList[ idxValidChannels ] )
11316 {
11317 fValid = TRUE;
11318 break;
11319 }
11320 }
11321 }
11322 pMac->roam.numValidChannels = len;
11323 return fValid;
11324}
11325
Jeff Johnson295189b2012-06-20 16:38:30 -070011326tANI_BOOLEAN csrRoamIsValid40MhzChannel(tpAniSirGlobal pMac, tANI_U8 channel)
11327{
11328 tANI_BOOLEAN fValid = eANI_BOOLEAN_FALSE;
11329 tANI_U8 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011330 for(i = 0; i < pMac->scan.base40MHzChannels.numChannels; i++)
11331 {
11332 if(channel == pMac->scan.base40MHzChannels.channelList[i])
11333 {
11334 fValid = eANI_BOOLEAN_TRUE;
11335 break;
11336 }
11337 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011338 return (fValid);
11339}
11340
Jeff Johnson295189b2012-06-20 16:38:30 -070011341//This function check and validate whether the NIC can do CB (40MHz)
Jeff Johnsone7245742012-09-05 17:12:55 -070011342 static ePhyChanBondState csrGetCBModeFromIes(tpAniSirGlobal pMac, tANI_U8 primaryChn, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011343{
Jeff Johnsone7245742012-09-05 17:12:55 -070011344 ePhyChanBondState eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011345 tANI_U8 centerChn;
11346 tANI_U32 ChannelBondingMode;
Sandeep Puligilla60342762014-01-30 21:05:37 +053011347
Jeff Johnson295189b2012-06-20 16:38:30 -070011348 if(CSR_IS_CHANNEL_24GHZ(primaryChn))
11349 {
11350 ChannelBondingMode = pMac->roam.configParam.channelBondingMode24GHz;
11351 }
11352 else
11353 {
11354 ChannelBondingMode = pMac->roam.configParam.channelBondingMode5GHz;
11355 }
11356 //Figure what the other side's CB mode
11357 if(WNI_CFG_CHANNEL_BONDING_MODE_DISABLE != ChannelBondingMode)
11358 {
11359 if(pIes->HTCaps.present && (eHT_CHANNEL_WIDTH_40MHZ == pIes->HTCaps.supportedChannelWidthSet))
11360 {
Agrawal Ashishf187d512014-04-03 17:01:52 +053011361 // In Case WPA2 and TKIP is the only one cipher suite in Pairwise.
11362 if ((pIes->RSN.present && (pIes->RSN.pwise_cipher_suite_count == 1) &&
11363 !memcmp(&(pIes->RSN.pwise_cipher_suites[0][0]),
11364 "\x00\x0f\xac\x02",4))
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011365 //In Case only WPA1 is supported and TKIP is the only one cipher suite in Unicast.
11366 ||( !pIes->RSN.present && (pIes->WPA.present && (pIes->WPA.unicast_cipher_count == 1) &&
Agrawal Ashishf187d512014-04-03 17:01:52 +053011367 !memcmp(&(pIes->WPA.unicast_ciphers[0][0]),
Abhishek Singhfd8afeb2014-10-15 11:55:45 +053011368 "\x00\x50\xf2\x02",4))))
Agrawal Ashishf187d512014-04-03 17:01:52 +053011369
Leela Venkata Kiran Kumar Reddy Chirala10c5a2e2013-12-18 14:41:28 -080011370 {
11371 smsLog(pMac, LOGW, " No channel bonding in TKIP mode ");
11372 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11373 }
11374
11375 else if(pIes->HTInfo.present)
Jeff Johnson295189b2012-06-20 16:38:30 -070011376 {
Jeff Johnsone7245742012-09-05 17:12:55 -070011377 /* This is called during INFRA STA/CLIENT and should use the merged value of
11378 * supported channel width and recommended tx width as per standard
11379 */
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011380 smsLog(pMac, LOG1, "scws %u rtws %u sco %u",
Jeff Johnsone7245742012-09-05 17:12:55 -070011381 pIes->HTCaps.supportedChannelWidthSet,
11382 pIes->HTInfo.recommendedTxWidthSet,
11383 pIes->HTInfo.secondaryChannelOffset);
11384
11385 if (pIes->HTInfo.recommendedTxWidthSet == eHT_CHANNEL_WIDTH_40MHZ)
11386 eRet = (ePhyChanBondState)pIes->HTInfo.secondaryChannelOffset;
Jeff Johnson295189b2012-06-20 16:38:30 -070011387 else
Jeff Johnsone7245742012-09-05 17:12:55 -070011388 eRet = PHY_SINGLE_CHANNEL_CENTERED;
11389 switch (eRet) {
11390 case PHY_DOUBLE_CHANNEL_LOW_PRIMARY:
11391 centerChn = primaryChn + CSR_CB_CENTER_CHANNEL_OFFSET;
11392 break;
11393 case PHY_DOUBLE_CHANNEL_HIGH_PRIMARY:
11394 centerChn = primaryChn - CSR_CB_CENTER_CHANNEL_OFFSET;
11395 break;
11396 case PHY_SINGLE_CHANNEL_CENTERED:
11397 default:
11398 centerChn = primaryChn;
11399 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011400 }
Jeff Johnsone7245742012-09-05 17:12:55 -070011401 if((PHY_SINGLE_CHANNEL_CENTERED != eRet) && !csrRoamIsValid40MhzChannel(pMac, centerChn))
Jeff Johnson295189b2012-06-20 16:38:30 -070011402 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011403 smsLog(pMac, LOGE, " Invalid center channel (%d), disable 40MHz mode", centerChn);
Abhishek Singh25144bb2014-05-01 16:03:21 +053011404 eRet = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011405 }
11406 }
11407 }
11408 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011409 return eRet;
11410}
Jeff Johnson295189b2012-06-20 16:38:30 -070011411tANI_BOOLEAN csrIsEncryptionInList( tpAniSirGlobal pMac, tCsrEncryptionList *pCipherList, eCsrEncryptionType encryptionType )
11412{
11413 tANI_BOOLEAN fFound = FALSE;
11414 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011415 for( idx = 0; idx < pCipherList->numEntries; idx++ )
11416 {
11417 if( pCipherList->encryptionType[idx] == encryptionType )
11418 {
11419 fFound = TRUE;
11420 break;
11421 }
11422 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011423 return fFound;
11424}
Jeff Johnson295189b2012-06-20 16:38:30 -070011425tANI_BOOLEAN csrIsAuthInList( tpAniSirGlobal pMac, tCsrAuthList *pAuthList, eCsrAuthType authType )
11426{
11427 tANI_BOOLEAN fFound = FALSE;
11428 tANI_U32 idx;
Jeff Johnson295189b2012-06-20 16:38:30 -070011429 for( idx = 0; idx < pAuthList->numEntries; idx++ )
11430 {
11431 if( pAuthList->authType[idx] == authType )
11432 {
11433 fFound = TRUE;
11434 break;
11435 }
11436 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011437 return fFound;
11438}
Jeff Johnson295189b2012-06-20 16:38:30 -070011439tANI_BOOLEAN csrIsSameProfile(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pProfile1, tCsrRoamProfile *pProfile2)
11440{
11441 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11442 tCsrScanResultFilter *pScanFilter = NULL;
11443 eHalStatus status = eHAL_STATUS_SUCCESS;
11444
11445 if(pProfile1 && pProfile2)
11446 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011447 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
11448 if ( NULL == pScanFilter )
11449 status = eHAL_STATUS_FAILURE;
11450 else
11451 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070011452 if(HAL_STATUS_SUCCESS(status))
11453 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011454 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011455 status = csrRoamPrepareFilterFromProfile(pMac, pProfile2, pScanFilter);
11456 if(HAL_STATUS_SUCCESS(status))
11457 {
11458 fCheck = eANI_BOOLEAN_FALSE;
11459 do
11460 {
11461 tANI_U32 i;
11462 for(i = 0; i < pScanFilter->SSIDs.numOfSSIDs; i++)
11463 {
11464 fCheck = csrIsSsidMatch( pMac, pScanFilter->SSIDs.SSIDList[i].SSID.ssId,
11465 pScanFilter->SSIDs.SSIDList[i].SSID.length,
11466 pProfile1->SSID.ssId, pProfile1->SSID.length, eANI_BOOLEAN_FALSE );
11467 if ( fCheck ) break;
11468 }
11469 if(!fCheck)
11470 {
11471 break;
11472 }
11473 if( !csrIsAuthInList( pMac, &pProfile2->AuthType, pProfile1->AuthType)
11474 || pProfile2->BSSType != pProfile1->BSSType
11475 || !csrIsEncryptionInList( pMac, &pProfile2->EncryptionType, pProfile1->EncryptionType )
11476 )
11477 {
11478 fCheck = eANI_BOOLEAN_FALSE;
11479 break;
11480 }
11481#ifdef WLAN_FEATURE_VOWIFI_11R
11482 if (pProfile1->MDID.mdiePresent || pProfile2->MDID.mdiePresent)
11483 {
11484 if (pProfile1->MDID.mobilityDomain != pProfile2->MDID.mobilityDomain)
11485 {
11486 fCheck = eANI_BOOLEAN_FALSE;
11487 break;
11488 }
11489 }
11490#endif
11491 //Match found
11492 fCheck = eANI_BOOLEAN_TRUE;
11493 }while(0);
11494 csrFreeScanFilter(pMac, pScanFilter);
11495 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011496 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070011497 }
11498 }
11499
11500 return (fCheck);
11501}
11502
Jeff Johnson295189b2012-06-20 16:38:30 -070011503tANI_BOOLEAN csrRoamIsSameProfileKeys(tpAniSirGlobal pMac, tCsrRoamConnectedProfile *pConnProfile, tCsrRoamProfile *pProfile2)
11504{
11505 tANI_BOOLEAN fCheck = eANI_BOOLEAN_FALSE;
11506 int i;
Jeff Johnson295189b2012-06-20 16:38:30 -070011507 do
11508 {
11509 //Only check for static WEP
11510 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) &&
11511 !csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, eCSR_ENCRYPT_TYPE_WEP104_STATICKEY))
11512 {
11513 fCheck = eANI_BOOLEAN_TRUE;
11514 break;
11515 }
11516 if(!csrIsEncryptionInList(pMac, &pProfile2->EncryptionType, pConnProfile->EncryptionType)) break;
11517 if(pConnProfile->Keys.defaultIndex != pProfile2->Keys.defaultIndex) break;
11518 for(i = 0; i < CSR_MAX_NUM_KEY; i++)
11519 {
11520 if(pConnProfile->Keys.KeyLength[i] != pProfile2->Keys.KeyLength[i]) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053011521 if (!vos_mem_compare(&pConnProfile->Keys.KeyMaterial[i],
11522 &pProfile2->Keys.KeyMaterial[i], pProfile2->Keys.KeyLength[i]))
Jeff Johnson295189b2012-06-20 16:38:30 -070011523 {
11524 break;
11525 }
11526 }
11527 if( i == CSR_MAX_NUM_KEY)
11528 {
11529 fCheck = eANI_BOOLEAN_TRUE;
11530 }
11531 }while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011532 return (fCheck);
11533}
11534
Jeff Johnson295189b2012-06-20 16:38:30 -070011535//IBSS
11536
Jeff Johnson295189b2012-06-20 16:38:30 -070011537tANI_U8 csrRoamGetIbssStartChannelNumber50( tpAniSirGlobal pMac )
11538{
11539 tANI_U8 channel = 0;
11540 tANI_U32 idx;
11541 tANI_U32 idxValidChannels;
11542 tANI_BOOLEAN fFound = FALSE;
11543 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11544
11545 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel5G)
11546 {
11547 channel = pMac->roam.configParam.AdHocChannel5G;
11548 if(!csrRoamIsChannelValid(pMac, channel))
11549 {
11550 channel = 0;
11551 }
11552 }
11553 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11554 {
11555 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_50 ) && !fFound; idx++ )
11556 {
11557 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11558 {
11559 if ( csrStartIbssChannels50[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11560 {
11561 fFound = TRUE;
11562 channel = csrStartIbssChannels50[ idx ];
11563 }
11564 }
11565 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011566 // this is rare, but if it does happen, we find anyone in 11a bandwidth and return the first 11a channel found!
11567 if (!fFound)
11568 {
11569 for ( idxValidChannels = 0; idxValidChannels < len ; idxValidChannels++ )
11570 {
11571 if ( CSR_IS_CHANNEL_5GHZ(pMac->roam.validChannelList[ idx ]) ) // the max channel# in 11g is 14
11572 {
11573 channel = csrStartIbssChannels50[ idx ];
11574 break;
11575 }
11576 }
11577 }
11578 }//if
11579
11580 return( channel );
11581}
11582
Jeff Johnson295189b2012-06-20 16:38:30 -070011583tANI_U8 csrRoamGetIbssStartChannelNumber24( tpAniSirGlobal pMac )
11584{
11585 tANI_U8 channel = 1;
11586 tANI_U32 idx;
11587 tANI_U32 idxValidChannels;
11588 tANI_BOOLEAN fFound = FALSE;
11589 tANI_U32 len = sizeof(pMac->roam.validChannelList);
11590
11591 if(eCSR_OPERATING_CHANNEL_ANY != pMac->roam.configParam.AdHocChannel24)
11592 {
11593 channel = pMac->roam.configParam.AdHocChannel24;
11594 if(!csrRoamIsChannelValid(pMac, channel))
11595 {
11596 channel = 0;
11597 }
11598 }
11599
11600 if (0 == channel && HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &len)))
11601 {
11602 for ( idx = 0; ( idx < CSR_NUM_IBSS_START_CHANNELS_24 ) && !fFound; idx++ )
11603 {
11604 for ( idxValidChannels = 0; ( idxValidChannels < len ) && !fFound; idxValidChannels++ )
11605 {
11606 if ( csrStartIbssChannels24[ idx ] == pMac->roam.validChannelList[ idxValidChannels ] )
11607 {
11608 fFound = TRUE;
11609 channel = csrStartIbssChannels24[ idx ];
11610 }
11611 }
11612 }
11613 }
11614
11615 return( channel );
11616}
11617
Jeff Johnson295189b2012-06-20 16:38:30 -070011618static void csrRoamGetBssStartParms( tpAniSirGlobal pMac, tCsrRoamProfile *pProfile,
11619 tCsrRoamStartBssParams *pParam )
11620{
11621 eCsrCfgDot11Mode cfgDot11Mode;
11622 eCsrBand eBand;
11623 tANI_U8 channel = 0;
11624 tSirNwType nwType;
11625 tANI_U8 operationChannel = 0;
11626
11627 if(pProfile->ChannelInfo.numOfChannels && pProfile->ChannelInfo.ChannelList)
11628 {
11629 operationChannel = pProfile->ChannelInfo.ChannelList[0];
11630 }
11631
Jeff Johnson295189b2012-06-20 16:38:30 -070011632 cfgDot11Mode = csrRoamGetPhyModeBandForBss( pMac, pProfile, operationChannel, &eBand );
Jeff Johnson295189b2012-06-20 16:38:30 -070011633
Jeff Johnson295189b2012-06-20 16:38:30 -070011634 if( ( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11635 (pProfile->csrPersona == VOS_P2P_GO_MODE) )
11636 && ( cfgDot11Mode == eCSR_CFG_DOT11_MODE_11B)
11637 )
11638 {
11639 /* This should never happen */
11640 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_FATAL,
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011641 FL("For P2PClient/P2P-GO (persona %d) cfgDot11Mode is 11B"),
Jeff Johnson295189b2012-06-20 16:38:30 -070011642 pProfile->csrPersona);
11643 VOS_ASSERT(0);
11644 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011645 switch( cfgDot11Mode )
11646 {
11647 case eCSR_CFG_DOT11_MODE_11G:
11648 nwType = eSIR_11G_NW_TYPE;
11649 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011650 case eCSR_CFG_DOT11_MODE_11B:
11651 nwType = eSIR_11B_NW_TYPE;
11652 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011653 case eCSR_CFG_DOT11_MODE_11A:
11654 nwType = eSIR_11A_NW_TYPE;
11655 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011656 default:
11657 case eCSR_CFG_DOT11_MODE_11N:
11658 case eCSR_CFG_DOT11_MODE_TAURUS:
11659 //Because LIM only verifies it against 11a, 11b or 11g, set only 11g or 11a here
11660 if(eCSR_BAND_24 == eBand)
11661 {
11662 nwType = eSIR_11G_NW_TYPE;
11663 }
11664 else
11665 {
11666 nwType = eSIR_11A_NW_TYPE;
11667 }
11668 break;
11669 }
11670
11671 pParam->extendedRateSet.numRates = 0;
11672
11673 switch ( nwType )
11674 {
11675 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011676 smsLog(pMac, LOGE, FL("sees an unknown pSirNwType (%d)"), nwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070011677 case eSIR_11A_NW_TYPE:
11678
11679 pParam->operationalRateSet.numRates = 8;
11680
11681 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11682 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11683 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11684 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11685 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11686 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11687 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11688 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11689
11690 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11691 {
11692 channel = csrRoamGetIbssStartChannelNumber50( pMac );
11693 if( 0 == channel &&
11694 CSR_IS_PHY_MODE_DUAL_BAND(pProfile->phyMode) &&
11695 CSR_IS_PHY_MODE_DUAL_BAND(pMac->roam.configParam.phyMode)
11696 )
11697 {
11698 //We could not find a 5G channel by auto pick, let's try 2.4G channels
11699 //We only do this here because csrRoamGetPhyModeBandForBss always picks 11a for AUTO
11700 nwType = eSIR_11B_NW_TYPE;
11701 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11702 pParam->operationalRateSet.numRates = 4;
11703 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11704 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11705 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11706 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11707 }
11708 }
11709 else
11710 {
11711 channel = operationChannel;
11712 }
11713 break;
11714
11715 case eSIR_11B_NW_TYPE:
11716 pParam->operationalRateSet.numRates = 4;
11717 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11718 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11719 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11720 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
Jeff Johnson295189b2012-06-20 16:38:30 -070011721 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11722 {
11723 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11724 }
11725 else
11726 {
11727 channel = operationChannel;
11728 }
11729
11730 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070011731 case eSIR_11G_NW_TYPE:
Jeff Johnson295189b2012-06-20 16:38:30 -070011732 /* For P2P Client and P2P GO, disable 11b rates */
11733 if( (pProfile->csrPersona == VOS_P2P_CLIENT_MODE) ||
11734 (pProfile->csrPersona == VOS_P2P_GO_MODE)
11735 )
11736 {
11737 pParam->operationalRateSet.numRates = 8;
11738
11739 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_6 | CSR_DOT11_BASIC_RATE_MASK;
11740 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_9;
11741 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_12 | CSR_DOT11_BASIC_RATE_MASK;
11742 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_18;
11743 pParam->operationalRateSet.rate[4] = SIR_MAC_RATE_24 | CSR_DOT11_BASIC_RATE_MASK;
11744 pParam->operationalRateSet.rate[5] = SIR_MAC_RATE_36;
11745 pParam->operationalRateSet.rate[6] = SIR_MAC_RATE_48;
11746 pParam->operationalRateSet.rate[7] = SIR_MAC_RATE_54;
11747 }
11748 else
Jeff Johnson295189b2012-06-20 16:38:30 -070011749 {
11750 pParam->operationalRateSet.numRates = 4;
Jeff Johnson295189b2012-06-20 16:38:30 -070011751 pParam->operationalRateSet.rate[0] = SIR_MAC_RATE_1 | CSR_DOT11_BASIC_RATE_MASK;
11752 pParam->operationalRateSet.rate[1] = SIR_MAC_RATE_2 | CSR_DOT11_BASIC_RATE_MASK;
11753 pParam->operationalRateSet.rate[2] = SIR_MAC_RATE_5_5 | CSR_DOT11_BASIC_RATE_MASK;
11754 pParam->operationalRateSet.rate[3] = SIR_MAC_RATE_11 | CSR_DOT11_BASIC_RATE_MASK;
11755
11756 pParam->extendedRateSet.numRates = 8;
Jeff Johnson295189b2012-06-20 16:38:30 -070011757 pParam->extendedRateSet.rate[0] = SIR_MAC_RATE_6;
11758 pParam->extendedRateSet.rate[1] = SIR_MAC_RATE_9;
11759 pParam->extendedRateSet.rate[2] = SIR_MAC_RATE_12;
11760 pParam->extendedRateSet.rate[3] = SIR_MAC_RATE_18;
11761 pParam->extendedRateSet.rate[4] = SIR_MAC_RATE_24;
11762 pParam->extendedRateSet.rate[5] = SIR_MAC_RATE_36;
11763 pParam->extendedRateSet.rate[6] = SIR_MAC_RATE_48;
11764 pParam->extendedRateSet.rate[7] = SIR_MAC_RATE_54;
11765 }
11766
11767 if ( eCSR_OPERATING_CHANNEL_ANY == operationChannel )
11768 {
11769 channel = csrRoamGetIbssStartChannelNumber24( pMac );
11770 }
11771 else
11772 {
11773 channel = operationChannel;
11774 }
11775
11776 break;
11777 }
11778 pParam->operationChn = channel;
11779 pParam->sirNwType = nwType;
11780}
11781
Jeff Johnson295189b2012-06-20 16:38:30 -070011782static void csrRoamGetBssStartParmsFromBssDesc( tpAniSirGlobal pMac, tSirBssDescription *pBssDesc,
11783 tDot11fBeaconIEs *pIes, tCsrRoamStartBssParams *pParam )
11784{
11785
11786 if( pParam )
11787 {
11788 pParam->sirNwType = pBssDesc->nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070011789 pParam->cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011790 pParam->operationChn = pBssDesc->channelId;
Kiet Lam64c1b492013-07-12 13:56:44 +053011791 vos_mem_copy(&pParam->bssid, pBssDesc->bssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011792
11793 if( pIes )
11794 {
11795 if(pIes->SuppRates.present)
11796 {
11797 pParam->operationalRateSet.numRates = pIes->SuppRates.num_rates;
11798 if(pIes->SuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
11799 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080011800 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 -070011801 pIes->SuppRates.num_rates);
11802 pIes->SuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
11803 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011804 vos_mem_copy(pParam->operationalRateSet.rate, pIes->SuppRates.rates,
11805 sizeof(*pIes->SuppRates.rates) * pIes->SuppRates.num_rates);
Jeff Johnson295189b2012-06-20 16:38:30 -070011806 }
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011807 if (pIes->ExtSuppRates.present)
11808 {
11809 pParam->extendedRateSet.numRates = pIes->ExtSuppRates.num_rates;
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011810 if(pIes->ExtSuppRates.num_rates > SIR_MAC_RATESET_EID_MAX)
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011811 {
11812 smsLog(pMac, LOGE, FL("num_rates :%d is more than \
11813 SIR_MAC_RATESET_EID_MAX, resetting to \
11814 SIR_MAC_RATESET_EID_MAX"),
11815 pIes->ExtSuppRates.num_rates);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053011816 pIes->ExtSuppRates.num_rates = SIR_MAC_RATESET_EID_MAX;
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011817 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053011818 vos_mem_copy(pParam->extendedRateSet.rate,
Praveen Kumar Sirisilla1f6b6492013-10-15 18:25:06 -070011819 pIes->ExtSuppRates.rates,
11820 sizeof(*pIes->ExtSuppRates.rates) * pIes->ExtSuppRates.num_rates);
11821 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011822 if( pIes->SSID.present )
11823 {
11824 pParam->ssId.length = pIes->SSID.num_ssid;
Kiet Lam64c1b492013-07-12 13:56:44 +053011825 vos_mem_copy(pParam->ssId.ssId, pIes->SSID.ssid,
11826 pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011827 }
11828 pParam->cbMode = csrGetCBModeFromIes(pMac, pParam->operationChn, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070011829 }
11830 else
11831 {
11832 pParam->ssId.length = 0;
11833 pParam->operationalRateSet.numRates = 0;
11834 }
11835 }
11836}
11837
Jeff Johnson295189b2012-06-20 16:38:30 -070011838static void csrRoamDetermineMaxRateForAdHoc( tpAniSirGlobal pMac, tSirMacRateSet *pSirRateSet )
11839{
11840 tANI_U8 MaxRate = 0;
11841 tANI_U32 i;
11842 tANI_U8 *pRate;
11843
11844 pRate = pSirRateSet->rate;
11845 for ( i = 0; i < pSirRateSet->numRates; i++ )
11846 {
11847 MaxRate = CSR_MAX( MaxRate, ( pRate[ i ] & (~CSR_DOT11_BASIC_RATE_MASK) ) );
11848 }
11849
11850 // Save the max rate in the connected state information...
11851
11852 // modify LastRates variable as well
11853
11854 return;
11855}
11856
Jeff Johnson295189b2012-06-20 16:38:30 -070011857eHalStatus csrRoamIssueStartBss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamStartBssParams *pParam,
11858 tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc, tANI_U32 roamId )
11859{
11860 eHalStatus status = eHAL_STATUS_SUCCESS;
11861 eCsrBand eBand;
Jeff Johnson295189b2012-06-20 16:38:30 -070011862 // Set the roaming substate to 'Start BSS attempt'...
11863 csrRoamSubstateChange( pMac, eCSR_ROAM_SUBSTATE_START_BSS_REQ, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070011864#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
11865 //Need to figure out whether we need to log WDS???
11866 if( CSR_IS_IBSS( pProfile ) )
11867 {
11868 vos_log_ibss_pkt_type *pIbssLog;
Jeff Johnson295189b2012-06-20 16:38:30 -070011869 WLAN_VOS_DIAG_LOG_ALLOC(pIbssLog, vos_log_ibss_pkt_type, LOG_WLAN_IBSS_C);
11870 if(pIbssLog)
11871 {
11872 if(pBssDesc)
11873 {
11874 pIbssLog->eventId = WLAN_IBSS_EVENT_JOIN_IBSS_REQ;
Kiet Lam64c1b492013-07-12 13:56:44 +053011875 vos_mem_copy(pIbssLog->bssid, pBssDesc->bssId, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070011876 }
11877 else
11878 {
11879 pIbssLog->eventId = WLAN_IBSS_EVENT_START_IBSS_REQ;
11880 }
Kiet Lam64c1b492013-07-12 13:56:44 +053011881 vos_mem_copy(pIbssLog->ssid, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070011882 if(pProfile->ChannelInfo.numOfChannels == 0)
11883 {
11884 pIbssLog->channelSetting = AUTO_PICK;
11885 }
11886 else
11887 {
11888 pIbssLog->channelSetting = SPECIFIED;
11889 }
11890 pIbssLog->operatingChannel = pParam->operationChn;
11891 WLAN_VOS_DIAG_LOG_REPORT(pIbssLog);
11892 }
11893 }
11894#endif //FEATURE_WLAN_DIAG_SUPPORT_CSR
11895 //Put RSN information in for Starting BSS
Abhishek Singh3f9cbb72014-06-04 15:16:27 +053011896 if (pProfile->nRSNReqIELength && pProfile->pRSNReqIE) {
11897 pParam->nRSNIELength = (tANI_U16)pProfile->nRSNReqIELength;
11898 pParam->pRSNIE = pProfile->pRSNReqIE;
11899 } else if (pProfile->nWPAReqIELength && pProfile->pWPAReqIE) {
11900 pParam->nRSNIELength = (tANI_U16)pProfile->nWPAReqIELength;
11901 pParam->pRSNIE = pProfile->pWPAReqIE;
11902 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011903
Jeff Johnson295189b2012-06-20 16:38:30 -070011904 pParam->privacy = pProfile->privacy;
11905 pParam->fwdWPSPBCProbeReq = pProfile->fwdWPSPBCProbeReq;
11906 pParam->authType = pProfile->csr80211AuthType;
11907 pParam->beaconInterval = pProfile->beaconInterval;
11908 pParam->dtimPeriod = pProfile->dtimPeriod;
11909 pParam->ApUapsdEnable = pProfile->ApUapsdEnable;
11910 pParam->ssidHidden = pProfile->SSIDs.SSIDList[0].ssidHidden;
11911 if (CSR_IS_INFRA_AP(pProfile)&& (pParam->operationChn != 0))
11912 {
11913 if (csrIsValidChannel(pMac, pParam->operationChn) != eHAL_STATUS_SUCCESS)
11914 {
11915 pParam->operationChn = INFRA_AP_DEFAULT_CHANNEL;
11916 }
11917 }
Jeff Johnson295189b2012-06-20 16:38:30 -070011918 pParam->protEnabled = pProfile->protEnabled;
11919 pParam->obssProtEnabled = pProfile->obssProtEnabled;
11920 pParam->ht_protection = pProfile->cfg_protection;
11921 pParam->wps_state = pProfile->wps_state;
Jeff Johnson96fbeeb2013-02-26 21:23:00 -080011922
Jeff Johnson295189b2012-06-20 16:38:30 -070011923 pParam->uCfgDot11Mode = csrRoamGetPhyModeBandForBss(pMac, pProfile, pParam->operationChn /* pProfile->operationChannel*/,
11924 &eBand);
Jeff Johnson295189b2012-06-20 16:38:30 -070011925 pParam->bssPersona = pProfile->csrPersona;
Chet Lanctot8cecea22014-02-11 19:09:36 -080011926
11927#ifdef WLAN_FEATURE_11W
11928 pParam->mfpCapable = (0 != pProfile->MFPCapable);
11929 pParam->mfpRequired = (0 != pProfile->MFPRequired);
11930#endif
11931
Jeff Johnson295189b2012-06-20 16:38:30 -070011932 // When starting an IBSS, start on the channel from the Profile.
11933 status = csrSendMBStartBssReqMsg( pMac, sessionId, pProfile->BSSType, pParam, pBssDesc );
Jeff Johnson295189b2012-06-20 16:38:30 -070011934 return (status);
11935}
11936
Jeff Johnson295189b2012-06-20 16:38:30 -070011937static void csrRoamPrepareBssParams(tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
Jeff Johnsone7245742012-09-05 17:12:55 -070011938 tSirBssDescription *pBssDesc, tBssConfigParam *pBssConfig, tDot11fBeaconIEs *pIes)
Jeff Johnson295189b2012-06-20 16:38:30 -070011939{
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070011940 tANI_U8 Channel;
Jeff Johnsone7245742012-09-05 17:12:55 -070011941 ePhyChanBondState cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnson295189b2012-06-20 16:38:30 -070011942 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070011943
11944 if(!pSession)
11945 {
11946 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
11947 return;
11948 }
11949
Jeff Johnson295189b2012-06-20 16:38:30 -070011950 if( pBssDesc )
11951 {
11952 csrRoamGetBssStartParmsFromBssDesc( pMac, pBssDesc, pIes, &pSession->bssParams );
11953 //Since csrRoamGetBssStartParmsFromBssDesc fills in the bssid for pSession->bssParams
11954 //The following code has to be do after that.
11955 //For WDS station, use selfMac as the self BSSID
11956 if( CSR_IS_WDS_STA( pProfile ) )
11957 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011958 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11959 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011960 }
11961 }
11962 else
11963 {
11964 csrRoamGetBssStartParms(pMac, pProfile, &pSession->bssParams);
Jeff Johnson295189b2012-06-20 16:38:30 -070011965 //Use the first SSID
11966 if(pProfile->SSIDs.numOfSSIDs)
11967 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011968 vos_mem_copy(&pSession->bssParams.ssId, pProfile->SSIDs.SSIDList,
11969 sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011970 }
11971 //For WDS station, use selfMac as the self BSSID
11972 if( CSR_IS_WDS_STA( pProfile ) )
11973 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011974 vos_mem_copy(&pSession->bssParams.bssid, &pSession->selfMacAddr,
11975 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011976 }
11977 //Use the first BSSID
11978 else if( pProfile->BSSIDs.numOfBSSIDs )
11979 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011980 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid,
11981 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070011982 }
11983 else
11984 {
Kiet Lam64c1b492013-07-12 13:56:44 +053011985 vos_mem_set(&pSession->bssParams.bssid, sizeof(tCsrBssid), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070011986 }
11987 }
11988 Channel = pSession->bssParams.operationChn;
Jeff Johnson295189b2012-06-20 16:38:30 -070011989 //Set operating channel in pProfile which will be used
11990 //in csrRoamSetBssConfigCfg() to determine channel bonding
11991 //mode and will be configured in CFG later
11992 pProfile->operationChannel = Channel;
11993
11994 if(Channel == 0)
11995 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053011996 smsLog(pMac, LOGE, " CSR cannot find a channel to start IBSS");
Jeff Johnson295189b2012-06-20 16:38:30 -070011997 }
11998 else
11999 {
12000
12001 csrRoamDetermineMaxRateForAdHoc( pMac, &pSession->bssParams.operationalRateSet );
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012002 if (CSR_IS_INFRA_AP(pProfile) || CSR_IS_START_IBSS( pProfile ) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012003 {
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012004 if(CSR_IS_CHANNEL_24GHZ(Channel) )
Jeff Johnsone7245742012-09-05 17:12:55 -070012005 {
Sandeep Puligillae3f239f2014-04-17 02:11:46 +053012006 /* TODO- SAP: HT40 Support in SAP 2.4Ghz mode is not enabled.
12007 so channel bonding in 2.4Ghz is configured as 20MHZ
12008 irrespective of the 'channelBondingMode24GHz' Parameter */
12009 cbMode = PHY_SINGLE_CHANNEL_CENTERED;
Jeff Johnsone7245742012-09-05 17:12:55 -070012010 }
12011 else
12012 {
12013 cbMode = pMac->roam.configParam.channelBondingMode5GHz;
12014 }
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -070012015 smsLog(pMac, LOG1, "## cbMode %d", cbMode);
Jeff Johnsone7245742012-09-05 17:12:55 -070012016 pBssConfig->cbMode = cbMode;
12017 pSession->bssParams.cbMode = cbMode;
12018 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012019 }
12020}
12021
Jeff Johnson295189b2012-06-20 16:38:30 -070012022static eHalStatus csrRoamStartIbss( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile,
12023 tANI_BOOLEAN *pfSameIbss )
12024{
12025 eHalStatus status = eHAL_STATUS_SUCCESS;
12026 tANI_BOOLEAN fSameIbss = FALSE;
12027
12028 if ( csrIsConnStateIbss( pMac, sessionId ) )
12029 {
12030 // Check if any profile parameter has changed ? If any profile parameter
12031 // has changed then stop old BSS and start a new one with new parameters
12032 if ( csrIsSameProfile( pMac, &pMac->roam.roamSession[sessionId].connectedProfile, pProfile ) )
12033 {
12034 fSameIbss = TRUE;
12035 }
12036 else
12037 {
12038 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12039 }
12040 }
12041 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12042 {
12043 // Disassociate from the connected Infrastructure network...
12044 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12045 }
12046 else
12047 {
12048 tBssConfigParam *pBssConfig;
12049
Kiet Lam64c1b492013-07-12 13:56:44 +053012050 pBssConfig = vos_mem_malloc(sizeof(tBssConfigParam));
12051 if ( NULL == pBssConfig )
12052 status = eHAL_STATUS_FAILURE;
12053 else
12054 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012055 if(HAL_STATUS_SUCCESS(status))
12056 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012057 vos_mem_set(pBssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012058 // there is no Bss description before we start an IBSS so we need to adopt
12059 // all Bss configuration parameters from the Profile.
12060 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, pBssConfig, NULL);
12061 if(HAL_STATUS_SUCCESS(status))
12062 {
12063 //save dotMode
12064 pMac->roam.roamSession[sessionId].bssParams.uCfgDot11Mode = pBssConfig->uCfgDot11Mode;
12065 //Prepare some more parameters for this IBSS
Jeff Johnsone7245742012-09-05 17:12:55 -070012066 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, pBssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012067 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12068 NULL, pBssConfig,
12069 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012070 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012071
12072 vos_mem_free(pBssConfig);
Jeff Johnson295189b2012-06-20 16:38:30 -070012073 }//Allocate memory
12074 }
12075
12076 if(pfSameIbss)
12077 {
12078 *pfSameIbss = fSameIbss;
12079 }
12080 return( status );
12081}
12082
Jeff Johnson295189b2012-06-20 16:38:30 -070012083static void csrRoamUpdateConnectedProfileFromNewBss( tpAniSirGlobal pMac, tANI_U32 sessionId,
12084 tSirSmeNewBssInfo *pNewBss )
12085{
12086 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012087
12088 if(!pSession)
12089 {
12090 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12091 return;
12092 }
12093
Jeff Johnson295189b2012-06-20 16:38:30 -070012094 if( pNewBss )
12095 {
12096 // Set the operating channel.
12097 pSession->connectedProfile.operationChannel = pNewBss->channelNumber;
12098 // move the BSSId from the BSS description into the connected state information.
Kiet Lam64c1b492013-07-12 13:56:44 +053012099 vos_mem_copy(&pSession->connectedProfile.bssid, &(pNewBss->bssId),
12100 sizeof( tCsrBssid ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012101 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012102 return;
12103}
12104
Jeff Johnson295189b2012-06-20 16:38:30 -070012105#ifdef FEATURE_WLAN_WAPI
12106eHalStatus csrRoamSetBKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId, tBkidCacheInfo *pBKIDCache,
12107 tANI_U32 numItems )
12108{
12109 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12110 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012111 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12112 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012113 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012114 return status;
12115 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012116 smsLog(pMac, LOGW, "csrRoamSetBKIDCache called, numItems = %d", numItems);
Jeff Johnson295189b2012-06-20 16:38:30 -070012117 pSession = CSR_GET_SESSION( pMac, sessionId );
12118 if(numItems <= CSR_MAX_BKID_ALLOWED)
12119 {
12120 status = eHAL_STATUS_SUCCESS;
12121 //numItems may be 0 to clear the cache
12122 pSession->NumBkidCache = (tANI_U16)numItems;
12123 if(numItems && pBKIDCache)
12124 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012125 vos_mem_copy(pSession->BkidCacheInfo, pBKIDCache,
12126 sizeof(tBkidCacheInfo) * numItems);
12127 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012128 }
12129 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012130 return (status);
12131}
Jeff Johnson295189b2012-06-20 16:38:30 -070012132eHalStatus csrRoamGetBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum,
12133 tBkidCacheInfo *pBkidCache)
12134{
12135 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12136 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070012137 if(!CSR_IS_SESSION_VALID( pMac, sessionId ))
12138 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012139 smsLog(pMac, LOGE, FL(" Invalid session ID"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012140 return status;
12141 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012142 pSession = CSR_GET_SESSION( pMac, sessionId );
12143 if(pNum && pBkidCache)
12144 {
12145 if(pSession->NumBkidCache == 0)
12146 {
12147 *pNum = 0;
12148 status = eHAL_STATUS_SUCCESS;
12149 }
12150 else if(*pNum >= pSession->NumBkidCache)
12151 {
12152 if(pSession->NumBkidCache > CSR_MAX_PMKID_ALLOWED)
12153 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012154 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 -070012155 pSession->NumBkidCache);
12156 pSession->NumBkidCache = CSR_MAX_PMKID_ALLOWED;
12157 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012158 vos_mem_copy(pBkidCache, pSession->BkidCacheInfo,
12159 sizeof(tBkidCacheInfo) * pSession->NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012160 *pNum = pSession->NumBkidCache;
12161 status = eHAL_STATUS_SUCCESS;
12162 }
12163 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012164 return (status);
Jeff Johnson295189b2012-06-20 16:38:30 -070012165}
Jeff Johnson295189b2012-06-20 16:38:30 -070012166tANI_U32 csrRoamGetNumBKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12167{
12168 return (pMac->roam.roamSession[sessionId].NumBkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012169}
12170#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012171eHalStatus csrRoamSetPMKIDCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012172 tPmkidCacheInfo *pPMKIDCache,
12173 tANI_U32 numItems,
12174 tANI_BOOLEAN update_entire_cache )
Jeff Johnson295189b2012-06-20 16:38:30 -070012175{
12176 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12177 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012178
12179 if (!pSession)
Jeff Johnson32d95a32012-09-10 13:15:23 -070012180 {
12181 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12182 return eHAL_STATUS_FAILURE;
12183 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012184
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012185 smsLog(pMac, LOGW, "csrRoamSetPMKIDCache called, numItems = %d", numItems);
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012186
12187 if (numItems <= CSR_MAX_PMKID_ALLOWED)
Jeff Johnson295189b2012-06-20 16:38:30 -070012188 {
12189#ifdef FEATURE_WLAN_DIAG_SUPPORT_CSR
12190 {
12191 WLAN_VOS_DIAG_EVENT_DEF(secEvent, vos_event_wlan_security_payload_type);
Kiet Lam64c1b492013-07-12 13:56:44 +053012192 vos_mem_set(&secEvent,
12193 sizeof(vos_event_wlan_security_payload_type), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012194 secEvent.eventId = WLAN_SECURITY_EVENT_PMKID_UPDATE;
12195 secEvent.encryptionModeMulticast =
12196 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.mcEncryptionType);
12197 secEvent.encryptionModeUnicast =
12198 (v_U8_t)diagEncTypeFromCSRType(pSession->connectedProfile.EncryptionType);
Kiet Lam64c1b492013-07-12 13:56:44 +053012199 vos_mem_copy(secEvent.bssid, pSession->connectedProfile.bssid, 6);
Jeff Johnson295189b2012-06-20 16:38:30 -070012200 secEvent.authMode =
12201 (v_U8_t)diagAuthTypeFromCSRType(pSession->connectedProfile.AuthType);
12202 WLAN_VOS_DIAG_EVENT_REPORT(&secEvent, EVENT_WLAN_SECURITY);
12203 }
12204#endif//FEATURE_WLAN_DIAG_SUPPORT_CSR
Jeff Johnson295189b2012-06-20 16:38:30 -070012205 status = eHAL_STATUS_SUCCESS;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012206 if (update_entire_cache) {
12207 pSession->NumPmkidCache = (tANI_U16)numItems;
12208 if (numItems && pPMKIDCache)
12209 {
12210 vos_mem_copy(pSession->PmkidCacheInfo, pPMKIDCache,
12211 sizeof(tPmkidCacheInfo) * numItems);
12212 }
12213 } else {
12214 tANI_U32 i = 0, j = 0;
12215 tANI_U8 BSSIDMatched = 0;
12216 tPmkidCacheInfo *pmksa;
12217
12218 for (i = 0; i < numItems; i++) {
12219 pmksa = &pPMKIDCache[i];
12220 for (j = 0; j < CSR_MAX_PMKID_ALLOWED; j++) {
12221 if (vos_mem_compare(pSession->PmkidCacheInfo[j].BSSID,
12222 pmksa->BSSID, VOS_MAC_ADDR_SIZE)) {
12223 /* If a matching BSSID found, update it */
12224 BSSIDMatched = 1;
12225 vos_mem_copy(pSession->PmkidCacheInfo[j].PMKID,
12226 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12227 break;
12228 }
12229 }
12230
12231 if (!BSSIDMatched) {
12232 vos_mem_copy(
12233 pSession->PmkidCacheInfo[pSession->NumPmkidCache].BSSID,
12234 pmksa->BSSID, VOS_MAC_ADDR_SIZE);
12235 vos_mem_copy(
12236 pSession->PmkidCacheInfo[pSession->NumPmkidCache].PMKID,
12237 pmksa->PMKID, CSR_RSN_PMKID_SIZE);
12238 /* Increment the CSR local cache index */
12239 if (pSession->NumPmkidCache < (CSR_MAX_PMKID_ALLOWED - 1))
12240 pSession->NumPmkidCache++;
12241 else
12242 pSession->NumPmkidCache = 0;
12243 }
12244 BSSIDMatched = 0;
12245 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012246 }
12247 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012248 return (status);
12249}
12250
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012251eHalStatus csrRoamDelPMKIDfromCache( tpAniSirGlobal pMac, tANI_U32 sessionId,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012252 tANI_U8 *pBSSId,
12253 tANI_BOOLEAN flush_cache )
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012254{
12255 eHalStatus status = eHAL_STATUS_FAILURE;
12256 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12257 tANI_BOOLEAN fMatchFound = FALSE;
12258 tANI_U32 Index;
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012259
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012260 if(!pSession)
12261 {
12262 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12263 return eHAL_STATUS_FAILURE;
12264 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012265
12266 /* Check if there are no entries to delete */
12267 if (0 == pSession->NumPmkidCache) {
12268 smsLog(pMac, LOG1, FL("No entries to delete/Flush"));
12269 return eHAL_STATUS_SUCCESS;
12270 }
12271
12272 if (!flush_cache) {
12273 for (Index = 0; Index < CSR_MAX_PMKID_ALLOWED; Index++) {
12274 if (vos_mem_compare(pSession->PmkidCacheInfo[Index].BSSID,
12275 pBSSId, VOS_MAC_ADDR_SIZE)) {
12276 fMatchFound = 1;
12277
12278 /* Clear this - the matched entry */
12279 vos_mem_zero(&pSession->PmkidCacheInfo[Index],
12280 sizeof(tPmkidCacheInfo));
12281 status = eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012282 break;
12283 }
12284 }
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012285
12286 if (Index == CSR_MAX_PMKID_ALLOWED && !fMatchFound) {
12287 smsLog(pMac, LOG1, FL("No such PMKSA entry exists "MAC_ADDRESS_STR),
12288 MAC_ADDR_ARRAY(pBSSId));
12289 return status;
12290 }
12291
12292 return status;
12293 } else {
12294 /* Flush the entire cache */
12295 vos_mem_zero(pSession->PmkidCacheInfo,
12296 sizeof(tPmkidCacheInfo) * CSR_MAX_PMKID_ALLOWED);
12297 pSession->NumPmkidCache = 0;
12298 return eHAL_STATUS_SUCCESS;
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012299 }
Leela Venkata Kiran Kumar Reddy Chiralaede10652013-09-11 18:48:46 -070012300}
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +053012301
Jeff Johnson295189b2012-06-20 16:38:30 -070012302tANI_U32 csrRoamGetNumPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId)
12303{
12304 return (pMac->roam.roamSession[sessionId].NumPmkidCache);
12305}
12306
Jeff Johnson295189b2012-06-20 16:38:30 -070012307eHalStatus csrRoamGetPMKIDCache(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pNum, tPmkidCacheInfo *pPmkidCache)
12308{
12309 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12310 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012311
12312 if(!pSession)
12313 {
12314 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12315 return eHAL_STATUS_FAILURE;
12316 }
12317
Jeff Johnson295189b2012-06-20 16:38:30 -070012318 if(pNum && pPmkidCache)
12319 {
12320 if(pSession->NumPmkidCache == 0)
12321 {
12322 *pNum = 0;
12323 status = eHAL_STATUS_SUCCESS;
12324 }
12325 else if(*pNum >= pSession->NumPmkidCache)
12326 {
12327 if(pSession->NumPmkidCache > CSR_MAX_PMKID_ALLOWED)
12328 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012329 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 -070012330 pSession->NumPmkidCache);
12331 pSession->NumPmkidCache = CSR_MAX_PMKID_ALLOWED;
12332 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012333 vos_mem_copy(pPmkidCache, pSession->PmkidCacheInfo,
12334 sizeof(tPmkidCacheInfo) * pSession->NumPmkidCache);
Jeff Johnson295189b2012-06-20 16:38:30 -070012335 *pNum = pSession->NumPmkidCache;
12336 status = eHAL_STATUS_SUCCESS;
12337 }
12338 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012339 return (status);
12340}
12341
Jeff Johnson295189b2012-06-20 16:38:30 -070012342eHalStatus csrRoamGetWpaRsnReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12343{
12344 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12345 tANI_U32 len;
12346 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012347
12348 if(!pSession)
12349 {
12350 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12351 return eHAL_STATUS_FAILURE;
12352 }
12353
Jeff Johnson295189b2012-06-20 16:38:30 -070012354 if(pLen)
12355 {
12356 len = *pLen;
12357 *pLen = pSession->nWpaRsnReqIeLength;
12358 if(pBuf)
12359 {
12360 if(len >= pSession->nWpaRsnReqIeLength)
12361 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012362 vos_mem_copy(pBuf, pSession->pWpaRsnReqIE,
12363 pSession->nWpaRsnReqIeLength);
12364 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012365 }
12366 }
12367 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012368 return (status);
12369}
12370
Jeff Johnson295189b2012-06-20 16:38:30 -070012371eHalStatus csrRoamGetWpaRsnRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12372{
12373 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12374 tANI_U32 len;
12375 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012376
12377 if(!pSession)
12378 {
12379 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12380 return eHAL_STATUS_FAILURE;
12381 }
12382
Jeff Johnson295189b2012-06-20 16:38:30 -070012383 if(pLen)
12384 {
12385 len = *pLen;
12386 *pLen = pSession->nWpaRsnRspIeLength;
12387 if(pBuf)
12388 {
12389 if(len >= pSession->nWpaRsnRspIeLength)
12390 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012391 vos_mem_copy(pBuf, pSession->pWpaRsnRspIE,
12392 pSession->nWpaRsnRspIeLength);
12393 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012394 }
12395 }
12396 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012397 return (status);
12398}
Jeff Johnson295189b2012-06-20 16:38:30 -070012399#ifdef FEATURE_WLAN_WAPI
12400eHalStatus csrRoamGetWapiReqIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12401{
12402 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12403 tANI_U32 len;
12404 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012405
12406 if(!pSession)
12407 {
12408 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12409 return eHAL_STATUS_FAILURE;
12410 }
12411
Jeff Johnson295189b2012-06-20 16:38:30 -070012412 if(pLen)
12413 {
12414 len = *pLen;
12415 *pLen = pSession->nWapiReqIeLength;
12416 if(pBuf)
12417 {
12418 if(len >= pSession->nWapiReqIeLength)
12419 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012420 vos_mem_copy(pBuf, pSession->pWapiReqIE,
12421 pSession->nWapiReqIeLength);
12422 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012423 }
12424 }
12425 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012426 return (status);
12427}
Jeff Johnson295189b2012-06-20 16:38:30 -070012428eHalStatus csrRoamGetWapiRspIE(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 *pLen, tANI_U8 *pBuf)
12429{
12430 eHalStatus status = eHAL_STATUS_INVALID_PARAMETER;
12431 tANI_U32 len;
12432 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012433
12434 if(!pSession)
12435 {
12436 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12437 return eHAL_STATUS_FAILURE;
12438 }
12439
Jeff Johnson295189b2012-06-20 16:38:30 -070012440 if(pLen)
12441 {
12442 len = *pLen;
12443 *pLen = pSession->nWapiRspIeLength;
12444 if(pBuf)
12445 {
12446 if(len >= pSession->nWapiRspIeLength)
12447 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012448 vos_mem_copy(pBuf, pSession->pWapiRspIE,
12449 pSession->nWapiRspIeLength);
12450 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012451 }
12452 }
12453 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012454 return (status);
12455}
12456#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012457eRoamCmdStatus csrGetRoamCompleteStatus(tpAniSirGlobal pMac, tANI_U32 sessionId)
12458{
12459 eRoamCmdStatus retStatus = eCSR_ROAM_CONNECT_COMPLETION;
12460 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070012461
12462 if(!pSession)
12463 {
12464 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12465 return (retStatus);
12466 }
12467
Jeff Johnson295189b2012-06-20 16:38:30 -070012468 if(CSR_IS_ROAMING(pSession))
12469 {
12470 retStatus = eCSR_ROAM_ROAMING_COMPLETION;
12471 pSession->fRoaming = eANI_BOOLEAN_FALSE;
12472 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012473 return (retStatus);
12474}
12475
Jeff Johnson295189b2012-06-20 16:38:30 -070012476//This function remove the connected BSS from te cached scan result
12477eHalStatus csrRoamRemoveConnectedBssFromScanCache(tpAniSirGlobal pMac,
12478 tCsrRoamConnectedProfile *pConnProfile)
12479{
12480 eHalStatus status = eHAL_STATUS_FAILURE;
12481 tCsrScanResultFilter *pScanFilter = NULL;
12482 tListElem *pEntry;
12483 tCsrScanResult *pResult;
12484 tDot11fBeaconIEs *pIes;
12485 tANI_BOOLEAN fMatch;
Jeff Johnson295189b2012-06-20 16:38:30 -070012486 if(!(csrIsMacAddressZero(pMac, &pConnProfile->bssid) ||
12487 csrIsMacAddressBroadcast(pMac, &pConnProfile->bssid)))
12488 {
12489 do
12490 {
12491 //Prepare the filter. Only fill in the necessary fields. Not all fields are needed
Kiet Lam64c1b492013-07-12 13:56:44 +053012492 pScanFilter = vos_mem_malloc(sizeof(tCsrScanResultFilter));
12493 if ( NULL == pScanFilter )
12494 status = eHAL_STATUS_FAILURE;
12495 else
12496 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012497 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012498 vos_mem_set(pScanFilter, sizeof(tCsrScanResultFilter), 0);
12499 pScanFilter->BSSIDs.bssid = vos_mem_malloc(sizeof(tCsrBssid));
12500 if ( NULL == pScanFilter->BSSIDs.bssid )
12501 status = eHAL_STATUS_FAILURE;
12502 else
12503 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012504 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012505 vos_mem_copy(pScanFilter->BSSIDs.bssid, &pConnProfile->bssid,
12506 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012507 pScanFilter->BSSIDs.numOfBSSIDs = 1;
12508 if(!csrIsNULLSSID(pConnProfile->SSID.ssId, pConnProfile->SSID.length))
12509 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012510 pScanFilter->SSIDs.SSIDList = vos_mem_malloc(sizeof(tCsrSSIDInfo));
12511 if ( NULL == pScanFilter->SSIDs.SSIDList )
12512 status = eHAL_STATUS_FAILURE;
12513 else
12514 status = eHAL_STATUS_SUCCESS;
12515 if (!HAL_STATUS_SUCCESS(status)) break;
12516 vos_mem_copy(&pScanFilter->SSIDs.SSIDList[0].SSID,
12517 &pConnProfile->SSID, sizeof(tSirMacSSid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012518 }
12519 pScanFilter->authType.numEntries = 1;
12520 pScanFilter->authType.authType[0] = pConnProfile->AuthType;
12521 pScanFilter->BSSType = pConnProfile->BSSType;
12522 pScanFilter->EncryptionType.numEntries = 1;
12523 pScanFilter->EncryptionType.encryptionType[0] = pConnProfile->EncryptionType;
12524 pScanFilter->mcEncryptionType.numEntries = 1;
12525 pScanFilter->mcEncryptionType.encryptionType[0] = pConnProfile->mcEncryptionType;
12526 //We ignore the channel for now, BSSID should be enough
12527 pScanFilter->ChannelInfo.numOfChannels = 0;
12528 //Also ignore the following fields
12529 pScanFilter->uapsd_mask = 0;
12530 pScanFilter->bWPSAssociation = eANI_BOOLEAN_FALSE;
Leela Venkata Kiran Kumar Reddy Chiralaf257bef2014-04-11 18:48:12 -070012531 pScanFilter->bOSENAssociation = eANI_BOOLEAN_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -070012532 pScanFilter->countryCode[0] = 0;
12533 pScanFilter->phyMode = eCSR_DOT11_MODE_TAURUS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012534 csrLLLock(&pMac->scan.scanResultList);
12535 pEntry = csrLLPeekHead( &pMac->scan.scanResultList, LL_ACCESS_NOLOCK );
12536 while( pEntry )
12537 {
12538 pResult = GET_BASE_ADDR( pEntry, tCsrScanResult, Link );
12539 pIes = (tDot11fBeaconIEs *)( pResult->Result.pvIes );
12540 fMatch = csrMatchBSS(pMac, &pResult->Result.BssDescriptor,
12541 pScanFilter, NULL, NULL, NULL, &pIes);
12542 //Release the IEs allocated by csrMatchBSS is needed
12543 if( !pResult->Result.pvIes )
12544 {
12545 //need to free the IEs since it is allocated by csrMatchBSS
Kiet Lam64c1b492013-07-12 13:56:44 +053012546 vos_mem_free(pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070012547 }
12548 if(fMatch)
12549 {
12550 //We found the one
12551 if( csrLLRemoveEntry(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK) )
12552 {
12553 //Free the memory
12554 csrFreeScanResultEntry( pMac, pResult );
12555 }
12556 break;
12557 }
12558 pEntry = csrLLNext(&pMac->scan.scanResultList, pEntry, LL_ACCESS_NOLOCK);
12559 }//while
12560 csrLLUnlock(&pMac->scan.scanResultList);
12561 }while(0);
12562 if(pScanFilter)
12563 {
12564 csrFreeScanFilter(pMac, pScanFilter);
Kiet Lam64c1b492013-07-12 13:56:44 +053012565 vos_mem_free(pScanFilter);
Jeff Johnson295189b2012-06-20 16:38:30 -070012566 }
12567 }
12568 return (status);
12569}
12570
Jeff Johnson295189b2012-06-20 16:38:30 -070012571//BT-AMP
Jeff Johnson295189b2012-06-20 16:38:30 -070012572eHalStatus csrIsBTAMPAllowed( tpAniSirGlobal pMac, tANI_U32 chnId )
12573{
12574 eHalStatus status = eHAL_STATUS_SUCCESS;
12575 tANI_U32 sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012576 for( sessionId = 0; sessionId < CSR_ROAM_SESSION_MAX; sessionId++ )
12577 {
12578 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
12579 {
12580 if( csrIsConnStateIbss( pMac, sessionId ) || csrIsBTAMP( pMac, sessionId ) )
12581 {
12582 //co-exist with IBSS or BT-AMP is not supported
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012583 smsLog( pMac, LOGW, " BTAMP is not allowed due to IBSS/BT-AMP exist in session %d", sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070012584 status = eHAL_STATUS_CSR_WRONG_STATE;
12585 break;
12586 }
12587 if( csrIsConnStateInfra( pMac, sessionId ) )
12588 {
12589 if( chnId &&
12590 ( (tANI_U8)chnId != pMac->roam.roamSession[sessionId].connectedProfile.operationChannel ) )
12591 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012592 smsLog( pMac, LOGW, " BTAMP is not allowed due to channel (%d) diff than infr channel (%d)",
Jeff Johnson295189b2012-06-20 16:38:30 -070012593 chnId, pMac->roam.roamSession[sessionId].connectedProfile.operationChannel );
12594 status = eHAL_STATUS_CSR_WRONG_STATE;
12595 break;
12596 }
12597 }
12598 }
12599 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012600 return ( status );
12601}
12602
Jeff Johnson295189b2012-06-20 16:38:30 -070012603static eHalStatus csrRoamStartWds( tpAniSirGlobal pMac, tANI_U32 sessionId, tCsrRoamProfile *pProfile, tSirBssDescription *pBssDesc )
12604{
12605 eHalStatus status = eHAL_STATUS_SUCCESS;
12606 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12607 tBssConfigParam bssConfig;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012608
12609 if(!pSession)
12610 {
12611 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12612 return eHAL_STATUS_FAILURE;
12613 }
12614
Jeff Johnson295189b2012-06-20 16:38:30 -070012615 if ( csrIsConnStateIbss( pMac, sessionId ) )
12616 {
12617 status = csrRoamIssueStopBss( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING );
12618 }
12619 else if ( csrIsConnStateConnectedInfra( pMac, sessionId ) )
12620 {
12621 // Disassociate from the connected Infrastructure network...
12622 status = csrRoamIssueDisassociate( pMac, sessionId, eCSR_ROAM_SUBSTATE_DISCONNECT_CONTINUE_ROAMING, FALSE );
12623 }
12624 else
12625 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012626 //We don't expect Bt-AMP HDD not to disconnect the last connection first at this time.
12627 //Otherwise we need to add code to handle the
12628 //situation just like IBSS. Though for WDS station, we need to send disassoc to PE first then
12629 //send stop_bss to PE, before we can continue.
12630 VOS_ASSERT( !csrIsConnStateWds( pMac, sessionId ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053012631 vos_mem_set(&bssConfig, sizeof(tBssConfigParam), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012632 /* Assume HDD provide bssid in profile */
Kiet Lam64c1b492013-07-12 13:56:44 +053012633 vos_mem_copy(&pSession->bssParams.bssid, pProfile->BSSIDs.bssid[0],
12634 sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070012635 // there is no Bss description before we start an WDS so we need
12636 // to adopt all Bss configuration parameters from the Profile.
12637 status = csrRoamPrepareBssConfigFromProfile(pMac, pProfile, &bssConfig, pBssDesc);
12638 if(HAL_STATUS_SUCCESS(status))
12639 {
12640 //Save profile for late use
12641 csrFreeRoamProfile( pMac, sessionId );
Kiet Lam64c1b492013-07-12 13:56:44 +053012642 pSession->pCurRoamProfile = vos_mem_malloc(sizeof(tCsrRoamProfile));
12643 if (pSession->pCurRoamProfile != NULL )
Jeff Johnson295189b2012-06-20 16:38:30 -070012644 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012645 vos_mem_set(pSession->pCurRoamProfile,
12646 sizeof(tCsrRoamProfile), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070012647 csrRoamCopyProfile(pMac, pSession->pCurRoamProfile, pProfile);
12648 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012649 //Prepare some more parameters for this WDS
Jeff Johnsone7245742012-09-05 17:12:55 -070012650 csrRoamPrepareBssParams(pMac, sessionId, pProfile, NULL, &bssConfig, NULL);
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012651 status = csrRoamSetBssConfigCfg(pMac, sessionId, pProfile,
12652 NULL, &bssConfig,
12653 NULL, eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012654 }
12655 }
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012656
Jeff Johnson295189b2012-06-20 16:38:30 -070012657 return( status );
12658}
12659
Jeff Johnson295189b2012-06-20 16:38:30 -070012660////////////////////Mail box
12661
Jeff Johnson295189b2012-06-20 16:38:30 -070012662//pBuf is caller allocated memory point to &(tSirSmeJoinReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
12663//or &(tSirSmeReassocReq->rsnIE.rsnIEdata[ 0 ]) + pMsg->rsnIE.length;
Madan Mohan Koyyalamudibd4fa9b2013-08-09 02:12:34 +053012664static void csrPrepareJoinReassocReqBuffer( tpAniSirGlobal pMac,
12665 tSirBssDescription *pBssDescription,
Jeff Johnson295189b2012-06-20 16:38:30 -070012666 tANI_U8 *pBuf, tANI_U8 uapsdMask)
12667{
12668 tCsrChannelSet channelGroup;
12669 tSirMacCapabilityInfo *pAP_capabilityInfo;
12670 tAniBool fTmp;
12671 tANI_BOOLEAN found = FALSE;
12672 tANI_U32 size = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012673 tANI_S8 pwrLimit = 0;
12674 tANI_U16 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070012675 // plug in neighborhood occupancy info (i.e. BSSes on primary or secondary channels)
12676 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundPri
12677 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecDown
12678 *pBuf++ = (tANI_U8)FALSE; //tAniTitanCBNeighborInfo->cbBssFoundSecUp
Jeff Johnson295189b2012-06-20 16:38:30 -070012679 // 802.11h
12680 //We can do this because it is in HOST CPU order for now.
12681 pAP_capabilityInfo = (tSirMacCapabilityInfo *)&pBssDescription->capabilityInfo;
Kiran4a17ebe2013-01-31 10:43:43 -080012682 //tell the target AP my 11H capability only if both AP and STA support 11H and the channel being used is 11a
12683 if ( csrIs11hSupported( pMac ) && pAP_capabilityInfo->spectrumMgt && eSIR_11A_NW_TYPE == pBssDescription->nwType )
12684 {
Jeff Johnson295189b2012-06-20 16:38:30 -070012685 fTmp = (tAniBool)pal_cpu_to_be32(1);
12686 }
12687 else
12688 fTmp = (tAniBool)0;
12689
12690 // corresponds to --- pMsg->spectrumMgtIndicator = ON;
Kiet Lam64c1b492013-07-12 13:56:44 +053012691 vos_mem_copy(pBuf, (tANI_U8 *)&fTmp, sizeof(tAniBool));
Jeff Johnson295189b2012-06-20 16:38:30 -070012692 pBuf += sizeof(tAniBool);
12693 *pBuf++ = MIN_STA_PWR_CAP_DBM; // it is for pMsg->powerCap.minTxPower = 0;
Kiran4a17ebe2013-01-31 10:43:43 -080012694 found = csrSearchChannelListForTxPower(pMac, pBssDescription, &channelGroup);
Jeff Johnson295189b2012-06-20 16:38:30 -070012695 // This is required for 11k test VoWiFi Ent: Test 2.
12696 // We need the power capabilities for Assoc Req.
12697 // This macro is provided by the halPhyCfg.h. We pick our
12698 // max and min capability by the halPhy provided macros
Kiran4a17ebe2013-01-31 10:43:43 -080012699 pwrLimit = csrGetCfgMaxTxPower (pMac, pBssDescription->channelId);
12700 if (0 != pwrLimit)
12701 {
12702 *pBuf++ = pwrLimit;
12703 }
12704 else
12705 {
12706 *pBuf++ = MAX_STA_PWR_CAP_DBM;
12707 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012708 size = sizeof(pMac->roam.validChannelList);
12709 if(HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, (tANI_U8 *)pMac->roam.validChannelList, &size)))
12710 {
12711 *pBuf++ = (tANI_U8)size; //tSirSupChnl->numChnl
12712 for ( i = 0; i < size; i++)
12713 {
12714 *pBuf++ = pMac->roam.validChannelList[ i ]; //tSirSupChnl->channelList[ i ]
12715
12716 }
12717 }
12718 else
12719 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012720 smsLog(pMac, LOGE, FL("can not find any valid channel"));
Jeff Johnson295189b2012-06-20 16:38:30 -070012721 *pBuf++ = 0; //tSirSupChnl->numChnl
12722 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012723 //Check whether it is ok to enter UAPSD
12724#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12725 if( btcIsReadyForUapsd(pMac) )
12726#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12727 {
12728 *pBuf++ = uapsdMask;
12729 }
12730#ifndef WLAN_MDM_CODE_REDUCTION_OPT
12731 else
12732 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012733 smsLog(pMac, LOGE, FL(" BTC doesn't allow UAPSD for uapsd_mask(0x%X)"), uapsdMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070012734 *pBuf++ = 0;
12735 }
12736#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
12737
Jeff Johnson295189b2012-06-20 16:38:30 -070012738 // move the entire BssDescription into the join request.
Kiet Lam64c1b492013-07-12 13:56:44 +053012739 vos_mem_copy(pBuf, pBssDescription,
12740 pBssDescription->length + sizeof( pBssDescription->length ));
Jeff Johnson295189b2012-06-20 16:38:30 -070012741 pBuf += pBssDescription->length + sizeof( pBssDescription->length ); // update to new location
12742}
12743
Jeff Johnson295189b2012-06-20 16:38:30 -070012744/*
12745 * The communication between HDD and LIM is thru mailbox (MB).
12746 * Both sides will access the data structure "tSirSmeJoinReq".
12747 * The rule is, while the components of "tSirSmeJoinReq" can be accessed in the regular way like tSirSmeJoinReq.assocType, this guideline
12748 * stops at component tSirRSNie; any acces to the components after tSirRSNie is forbidden because the space from tSirRSNie is quueezed
12749 * with the component "tSirBssDescription". And since the size of actual 'tSirBssDescription' varies, the receiving side (which is the routine
12750 * limJoinReqSerDes() of limSerDesUtils.cc) should keep in mind not to access the components DIRECTLY after tSirRSNie.
12751 */
12752eHalStatus csrSendJoinReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirBssDescription *pBssDescription,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012753 tCsrRoamProfile *pProfile, tDot11fBeaconIEs *pIes, tANI_U16 messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012754{
12755 eHalStatus status = eHAL_STATUS_SUCCESS;
12756 tSirSmeJoinReq *pMsg;
12757 tANI_U8 *pBuf;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012758 v_U8_t acm_mask = 0, uapsd_mask;
Jeff Johnson295189b2012-06-20 16:38:30 -070012759 tANI_U16 msgLen, wTmp, ieLen;
12760 tSirMacRateSet OpRateSet;
12761 tSirMacRateSet ExRateSet;
12762 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
12763 tANI_U32 dwTmp;
12764 tANI_U8 wpaRsnIE[DOT11F_IE_RSN_MAX_LEN]; //RSN MAX is bigger than WPA MAX
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012765 tANI_U32 ucDot11Mode = 0;
Jeff Johnson32d95a32012-09-10 13:15:23 -070012766
12767 if(!pSession)
12768 {
12769 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
12770 return eHAL_STATUS_FAILURE;
12771 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012772 /* To satisfy klockworks */
12773 if (NULL == pBssDescription)
12774 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012775 smsLog(pMac, LOGE, FL(" pBssDescription is NULL"));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012776 return eHAL_STATUS_FAILURE;
12777 }
12778
Jeff Johnson295189b2012-06-20 16:38:30 -070012779 do {
12780 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
12781 pSession->joinFailStatusCode.reasonCode = 0;
Rajesh Babu Prathipati20cdffa2014-07-01 22:24:59 +053012782 vos_mem_copy (&pSession->joinFailStatusCode.bssId, &pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012783 // There are a number of variable length fields to consider. First, the tSirSmeJoinReq
12784 // includes a single bssDescription. bssDescription includes a single tANI_U32 for the
12785 // IE fields, but the length field in the bssDescription needs to be interpreted to
12786 // determine length of the IE fields.
12787 //
12788 // So, take the size of the JoinReq, subtract the size of the bssDescription and
12789 // add in the length from the bssDescription (then add the size of the 'length' field
12790 // itself because that is NOT included in the length field).
12791 msgLen = sizeof( tSirSmeJoinReq ) - sizeof( *pBssDescription ) +
12792 pBssDescription->length + sizeof( pBssDescription->length ) +
12793 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 +053012794 pMsg = vos_mem_malloc(msgLen);
12795 if (NULL == pMsg)
12796 status = eHAL_STATUS_FAILURE;
12797 else
12798 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012799 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053012800 vos_mem_set(pMsg, msgLen , 0);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012801 pMsg->messageType = pal_cpu_to_be16((tANI_U16)messageType);
Jeff Johnson295189b2012-06-20 16:38:30 -070012802 pMsg->length = pal_cpu_to_be16(msgLen);
12803 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070012804 // sessionId
12805 *pBuf = (tANI_U8)sessionId;
12806 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012807 // transactionId
12808 *pBuf = 0;
12809 *( pBuf + 1 ) = 0;
12810 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070012811 // ssId
12812 if( pIes->SSID.present && pIes->SSID.num_ssid )
12813 {
12814 // ssId len
12815 *pBuf = pIes->SSID.num_ssid;
12816 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053012817 vos_mem_copy(pBuf, pIes->SSID.ssid, pIes->SSID.num_ssid);
Jeff Johnson295189b2012-06-20 16:38:30 -070012818 pBuf += pIes->SSID.num_ssid;
12819 }
12820 else
12821 {
12822 *pBuf = 0;
12823 pBuf++;
12824 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012825 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053012826 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
12827 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070012828 pBuf += sizeof(tSirMacAddr);
12829 // bsstype
12830 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( pProfile->BSSType ) );
12831 if (dwTmp == eSIR_BTAMP_STA_MODE) dwTmp = eSIR_BTAMP_AP_MODE; // Override BssType for BTAMP
Kiet Lam64c1b492013-07-12 13:56:44 +053012832 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070012833 pBuf += sizeof(tSirBssType);
12834 // dot11mode
Ravi Joshi83bfaa12013-05-28 22:12:08 -070012835 ucDot11Mode = csrTranslateToWNICfgDot11Mode( pMac, pSession->bssParams.uCfgDot11Mode );
12836 if (pBssDescription->channelId <= 14 &&
12837 FALSE == pMac->roam.configParam.enableVhtFor24GHz &&
12838 WNI_CFG_DOT11_MODE_11AC == ucDot11Mode)
12839 {
12840 //Need to disable VHT operation in 2.4 GHz band
12841 ucDot11Mode = WNI_CFG_DOT11_MODE_11N;
12842 }
12843 *pBuf = (tANI_U8)ucDot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -070012844 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012845 //Persona
12846 *pBuf = (tANI_U8)pProfile->csrPersona;
12847 pBuf++;
Jeff Johnsone7245742012-09-05 17:12:55 -070012848 //CBMode
12849 *pBuf = (tANI_U8)pSession->bssParams.cbMode;
12850 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070012851
12852 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
Jeff Johnsone7245742012-09-05 17:12:55 -070012853 FL("CSR PERSONA=%d CSR CbMode %d"), pProfile->csrPersona, pSession->bssParams.cbMode);
12854
Jeff Johnson295189b2012-06-20 16:38:30 -070012855 // uapsdPerAcBitmask
12856 *pBuf = pProfile->uapsd_mask;
12857 pBuf++;
12858
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012859
12860
Jeff Johnson295189b2012-06-20 16:38:30 -070012861 status = csrGetRateSet(pMac, pProfile, (eCsrPhyMode)pProfile->phyMode, pBssDescription, pIes, &OpRateSet, &ExRateSet);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012862 if (HAL_STATUS_SUCCESS(status) )
Jeff Johnson295189b2012-06-20 16:38:30 -070012863 {
12864 // OperationalRateSet
12865 if (OpRateSet.numRates) {
12866 *pBuf++ = OpRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012867 vos_mem_copy(pBuf, OpRateSet.rate, OpRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012868 pBuf += OpRateSet.numRates;
12869 } else *pBuf++ = 0;
12870 // ExtendedRateSet
12871 if (ExRateSet.numRates) {
12872 *pBuf++ = ExRateSet.numRates;
Kiet Lam64c1b492013-07-12 13:56:44 +053012873 vos_mem_copy(pBuf, ExRateSet.rate, ExRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070012874 pBuf += ExRateSet.numRates;
12875 } else *pBuf++ = 0;
12876 }
12877 else
12878 {
12879 *pBuf++ = 0;
12880 *pBuf++ = 0;
12881 }
Jeff Johnson295189b2012-06-20 16:38:30 -070012882 // rsnIE
12883 if ( csrIsProfileWpa( pProfile ) )
12884 {
12885 // Insert the Wpa IE into the join request
12886 ieLen = csrRetrieveWpaIe( pMac, pProfile, pBssDescription, pIes,
12887 (tCsrWpaIe *)( wpaRsnIE ) );
12888 }
12889 else if( csrIsProfileRSN( pProfile ) )
12890 {
12891 // Insert the RSN IE into the join request
12892 ieLen = csrRetrieveRsnIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12893 (tCsrRSNIe *)( wpaRsnIE ) );
12894 }
12895#ifdef FEATURE_WLAN_WAPI
12896 else if( csrIsProfileWapi( pProfile ) )
12897 {
12898 // Insert the WAPI IE into the join request
12899 ieLen = csrRetrieveWapiIe( pMac, sessionId, pProfile, pBssDescription, pIes,
12900 (tCsrWapiIe *)( wpaRsnIE ) );
12901 }
12902#endif /* FEATURE_WLAN_WAPI */
Jeff Johnson295189b2012-06-20 16:38:30 -070012903 else
12904 {
12905 ieLen = 0;
12906 }
12907 //remember the IE for future use
12908 if( ieLen )
12909 {
12910 if(ieLen > DOT11F_IE_RSN_MAX_LEN)
12911 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080012912 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 -070012913 ieLen = DOT11F_IE_RSN_MAX_LEN;
12914 }
12915#ifdef FEATURE_WLAN_WAPI
12916 if( csrIsProfileWapi( pProfile ) )
12917 {
12918 //Check whether we need to allocate more memory
12919 if(ieLen > pSession->nWapiReqIeLength)
12920 {
12921 if(pSession->pWapiReqIE && pSession->nWapiReqIeLength)
12922 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012923 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012924 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012925 pSession->pWapiReqIE = vos_mem_malloc(ieLen);
12926 if (NULL == pSession->pWapiReqIE)
12927 status = eHAL_STATUS_FAILURE;
12928 else
12929 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012930 if(!HAL_STATUS_SUCCESS(status)) break;
12931 }
12932 pSession->nWapiReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012933 vos_mem_copy(pSession->pWapiReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012934 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012935 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012936 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012937 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012938 pBuf += ieLen;
12939 }
12940 else//should be WPA/WPA2 otherwise
12941#endif /* FEATURE_WLAN_WAPI */
12942 {
12943 //Check whether we need to allocate more memory
12944 if(ieLen > pSession->nWpaRsnReqIeLength)
12945 {
12946 if(pSession->pWpaRsnReqIE && pSession->nWpaRsnReqIeLength)
12947 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012948 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012949 }
Kiet Lam64c1b492013-07-12 13:56:44 +053012950 pSession->pWpaRsnReqIE = vos_mem_malloc(ieLen);
12951 if (NULL == pSession->pWpaRsnReqIE)
12952 status = eHAL_STATUS_FAILURE;
12953 else
12954 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070012955 if(!HAL_STATUS_SUCCESS(status)) break;
12956 }
12957 pSession->nWpaRsnReqIeLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053012958 vos_mem_copy(pSession->pWpaRsnReqIE, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012959 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053012960 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070012961 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053012962 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070012963 pBuf += ieLen;
12964 }
12965 }
12966 else
12967 {
12968 //free whatever old info
12969 pSession->nWpaRsnReqIeLength = 0;
12970 if(pSession->pWpaRsnReqIE)
12971 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012972 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012973 pSession->pWpaRsnReqIE = NULL;
12974 }
12975#ifdef FEATURE_WLAN_WAPI
12976 pSession->nWapiReqIeLength = 0;
12977 if(pSession->pWapiReqIE)
12978 {
Kiet Lam64c1b492013-07-12 13:56:44 +053012979 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070012980 pSession->pWapiReqIE = NULL;
12981 }
12982#endif /* FEATURE_WLAN_WAPI */
12983 //length is two bytes
12984 *pBuf = 0;
12985 *(pBuf + 1) = 0;
12986 pBuf += 2;
12987 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080012988#ifdef FEATURE_WLAN_ESE
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012989 if( eWNI_SME_JOIN_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012990 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012991 // Never include the cckmIE in an Join Request
Jeff Johnson295189b2012-06-20 16:38:30 -070012992 //length is two bytes
12993 *pBuf = 0;
12994 *(pBuf + 1) = 0;
12995 pBuf += 2;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012996 }
12997 else if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070012998 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080012999 // cckmIE
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013000 if( csrIsProfileESE( pProfile ) )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013001 {
13002 // Insert the CCKM IE into the join request
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013003#ifdef FEATURE_WLAN_ESE_UPLOAD
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013004 ieLen = pSession->suppCckmIeInfo.cckmIeLen;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080013005 vos_mem_copy((void *) (wpaRsnIE),
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070013006 pSession->suppCckmIeInfo.cckmIe, ieLen);
13007#else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013008 ieLen = csrConstructEseCckmIe( pMac,
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013009 pSession,
13010 pProfile,
13011 pBssDescription,
13012 pSession->pWpaRsnReqIE,
Jeff Johnson295189b2012-06-20 16:38:30 -070013013 pSession->nWpaRsnReqIeLength,
13014 (void *)( wpaRsnIE ) );
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013015#endif /* FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013016 }
13017 else
13018 {
13019 ieLen = 0;
13020 }
13021 //If present, copy the IE into the eWNI_SME_REASSOC_REQ message buffer
13022 if( ieLen )
13023 {
13024 //Copy the CCKM IE over from the temp buffer (wpaRsnIE)
13025 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013026 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013027 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013028 vos_mem_copy(pBuf, wpaRsnIE, ieLen);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013029 pBuf += ieLen;
13030 }
13031 else
13032 {
13033 //Indicate you have no CCKM IE
13034 //length is two bytes
13035 *pBuf = 0;
13036 *(pBuf + 1) = 0;
13037 pBuf += 2;
13038 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013039 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013040#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070013041 // addIEScan
Agarwal Ashish4f616132013-12-30 23:32:50 +053013042 if (pProfile->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070013043 {
13044 ieLen = pProfile->nAddIEScanLength;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013045 memset(pSession->addIEScan, 0 , pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013046 pSession->nAddIEScanLength = ieLen;
Agarwal Ashish4f616132013-12-30 23:32:50 +053013047 vos_mem_copy(pSession->addIEScan, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013048 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013049 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013050 pBuf += sizeof(tANI_U16);
Agarwal Ashish4f616132013-12-30 23:32:50 +053013051 vos_mem_copy(pBuf, pProfile->addIEScan, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013052 pBuf += ieLen;
13053 }
13054 else
13055 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053013056 memset(pSession->addIEScan, 0, pSession->nAddIEScanLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013057 pSession->nAddIEScanLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013058 *pBuf = 0;
13059 *(pBuf + 1) = 0;
13060 pBuf += 2;
13061 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013062 // addIEAssoc
13063 if(pProfile->nAddIEAssocLength && pProfile->pAddIEAssoc)
13064 {
13065 ieLen = pProfile->nAddIEAssocLength;
Jeff Johnson295189b2012-06-20 16:38:30 -070013066 if(ieLen > pSession->nAddIEAssocLength)
13067 {
13068 if(pSession->pAddIEAssoc && pSession->nAddIEAssocLength)
Kiet Lam64c1b492013-07-12 13:56:44 +053013069 {
13070 vos_mem_free(pSession->pAddIEAssoc);
13071 }
13072 pSession->pAddIEAssoc = vos_mem_malloc(ieLen);
13073 if (NULL == pSession->pAddIEAssoc)
13074 status = eHAL_STATUS_FAILURE;
13075 else
13076 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013077 if(!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013078 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013079 pSession->nAddIEAssocLength = ieLen;
Kiet Lam64c1b492013-07-12 13:56:44 +053013080 vos_mem_copy(pSession->pAddIEAssoc, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013081 wTmp = pal_cpu_to_be16( ieLen );
Kiet Lam64c1b492013-07-12 13:56:44 +053013082 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013083 pBuf += sizeof(tANI_U16);
Kiet Lam64c1b492013-07-12 13:56:44 +053013084 vos_mem_copy(pBuf, pProfile->pAddIEAssoc, ieLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013085 pBuf += ieLen;
13086 }
13087 else
13088 {
13089 pSession->nAddIEAssocLength = 0;
13090 if(pSession->pAddIEAssoc)
13091 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013092 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070013093 pSession->pAddIEAssoc = NULL;
13094 }
13095 *pBuf = 0;
13096 *(pBuf + 1) = 0;
13097 pBuf += 2;
13098 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013099
13100 if(eWNI_SME_REASSOC_REQ == messageType )
Jeff Johnson295189b2012-06-20 16:38:30 -070013101 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013102 //Unmask any AC in reassoc that is ACM-set
13103 uapsd_mask = (v_U8_t)pProfile->uapsd_mask;
13104 if( uapsd_mask && ( NULL != pBssDescription ) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013105 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013106 if( CSR_IS_QOS_BSS(pIes) && CSR_IS_UAPSD_BSS(pIes) )
13107 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013108#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013109 acm_mask = sme_QosGetACMMask(pMac, pBssDescription, pIes);
Jeff Johnson295189b2012-06-20 16:38:30 -070013110#endif /* WLAN_MDM_CODE_REDUCTION_OPT*/
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013111 }
13112 else
13113 {
13114 uapsd_mask = 0;
13115 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013116 }
13117 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013118
Jeff Johnson295189b2012-06-20 16:38:30 -070013119 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedUCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013120 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013121 pBuf += sizeof(tANI_U32);
13122
Jeff Johnson295189b2012-06-20 16:38:30 -070013123 dwTmp = pal_cpu_to_be32( csrTranslateEncryptTypeToEdType( pProfile->negotiatedMCEncryptionType) );
Kiet Lam64c1b492013-07-12 13:56:44 +053013124 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013125 pBuf += sizeof(tANI_U32);
Chet Lanctot186b5732013-03-18 10:26:30 -070013126#ifdef WLAN_FEATURE_11W
13127 //MgmtEncryption
13128 if (pProfile->MFPEnabled)
13129 {
13130 dwTmp = pal_cpu_to_be32(eSIR_ED_AES_128_CMAC);
13131 }
13132 else
13133 {
13134 dwTmp = pal_cpu_to_be32(eSIR_ED_NONE);
13135 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013136 vos_mem_copy(pBuf, &dwTmp, sizeof(tANI_U32));
Chet Lanctot186b5732013-03-18 10:26:30 -070013137 pBuf += sizeof(tANI_U32);
13138#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070013139#ifdef WLAN_FEATURE_VOWIFI_11R
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013140 pProfile->MDID.mdiePresent = pBssDescription->mdiePresent;
Saurabh Gupta775073c2013-02-14 13:31:36 +053013141 if (csrIsProfile11r( pProfile )
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013142#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala09dd66b2013-04-01 17:13:01 +053013143 && !((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM) &&
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013144 (pIes->ESEVersion.present) && (pMac->roam.configParam.isEseIniFeatureEnabled))
Saurabh Gupta775073c2013-02-14 13:31:36 +053013145#endif
13146 )
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013147 {
13148 // is11Rconnection;
13149 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013150 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool)) ;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013151 pBuf += sizeof(tAniBool);
13152 }
13153 else
13154 {
13155 // is11Rconnection;
13156 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013157 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013158 pBuf += sizeof(tAniBool);
13159 }
13160#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013161#ifdef FEATURE_WLAN_ESE
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013162
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013163 // isESEFeatureIniEnabled
13164 if (TRUE == pMac->roam.configParam.isEseIniFeatureEnabled)
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013165 {
13166 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013167 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013168 pBuf += sizeof(tAniBool);
13169 }
13170 else
13171 {
13172 dwTmp = pal_cpu_to_be32(FALSE);
Srinivas Girigowda18112782013-11-27 12:21:19 -080013173 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Gopichand Nakkala0ae39db2013-06-10 20:35:49 +053013174 pBuf += sizeof(tAniBool);
13175 }
13176
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013177 /* A profile can not be both ESE and 11R. But an 802.11R AP
13178 * may be advertising support for ESE as well. So if we are
13179 * associating Open or explicitly ESE then we will get ESE.
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013180 * If we are associating explictly 11R only then we will get
13181 * 11R.
13182 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013183 if ((csrIsProfileESE(pProfile) ||
13184 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013185 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13186 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13187 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13188 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13189#ifdef WLAN_FEATURE_11W
13190 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
13191#endif
13192 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013193 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013194 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013195 // isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013196 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013197 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013198 pBuf += sizeof(tAniBool);
13199 }
13200 else
13201 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013202 //isESEconnection;
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013203 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013204 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013205 pBuf += sizeof(tAniBool);
13206 }
13207
13208 if (eWNI_SME_JOIN_REQ == messageType)
13209 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013210 tESETspecInfo eseTspec;
13211 // ESE-Tspec IEs in the ASSOC request is presently not supported
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013212 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013213 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13214 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13215 pBuf += sizeof(tESETspecInfo);
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013216 }
13217 else if (eWNI_SME_REASSOC_REQ == messageType)
13218 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013219 if ((csrIsProfileESE(pProfile) ||
13220 ((pIes->ESEVersion.present)
Sachin Ahuja23ff1192014-10-06 22:02:45 +053013221 && ((pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_OPEN_SYSTEM)
13222 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA)
13223 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_WPA_PSK)
13224 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN)
13225#ifdef WLAN_FEATURE_11W
13226 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256)
13227#endif
13228 || (pProfile->negotiatedAuthType == eCSR_AUTH_TYPE_RSN_PSK))))
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013229 && (pMac->roam.configParam.isEseIniFeatureEnabled))
Jeff Johnson295189b2012-06-20 16:38:30 -070013230 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013231 tESETspecInfo eseTspec;
13232 // ESE Tspec information
13233 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13234 eseTspec.numTspecs = sme_QosESERetrieveTspecInfo(pMac, sessionId, (tTspecInfo *) &eseTspec.tspec[0]);
13235 *pBuf = eseTspec.numTspecs;
Jeff Johnson295189b2012-06-20 16:38:30 -070013236 pBuf += sizeof(tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013237 // Copy the TSPEC information only if present
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013238 if (eseTspec.numTspecs) {
13239 vos_mem_copy(pBuf, (void*)&eseTspec.tspec[0],
13240 (eseTspec.numTspecs*sizeof(tTspecInfo)));
Jeff Johnson295189b2012-06-20 16:38:30 -070013241 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013242 pBuf += sizeof(eseTspec.tspec);
Jeff Johnson295189b2012-06-20 16:38:30 -070013243 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013244 else
Jeff Johnson295189b2012-06-20 16:38:30 -070013245 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013246 tESETspecInfo eseTspec;
13247 // ESE-Tspec IEs in the ASSOC request is presently not supported
Jeff Johnson295189b2012-06-20 16:38:30 -070013248 // so nullify the TSPEC parameters
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013249 vos_mem_set(&eseTspec, sizeof(tESETspecInfo), 0);
13250 vos_mem_copy(pBuf, &eseTspec, sizeof(tESETspecInfo));
13251 pBuf += sizeof(tESETspecInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070013252 }
13253 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080013254#endif // FEATURE_WLAN_ESE
13255#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -070013256 // Fill in isFastTransitionEnabled
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013257 if (pMac->roam.configParam.isFastTransitionEnabled
13258#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013259 || csrRoamIsFastRoamEnabled(pMac, sessionId)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070013260#endif
13261 )
Jeff Johnson295189b2012-06-20 16:38:30 -070013262 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013263 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013264 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013265 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013266 }
13267 else
13268 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013269 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013270 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013271 pBuf += sizeof(tAniBool);
Jeff Johnson295189b2012-06-20 16:38:30 -070013272 }
13273#endif
Jeff Johnson43971f52012-07-17 12:26:56 -070013274#ifdef FEATURE_WLAN_LFR
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053013275 if(csrRoamIsFastRoamEnabled(pMac, sessionId))
Jeff Johnson43971f52012-07-17 12:26:56 -070013276 {
13277 //legacy fast roaming enabled
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013278 dwTmp = pal_cpu_to_be32(TRUE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013279 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013280 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013281 }
13282 else
13283 {
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013284 dwTmp = pal_cpu_to_be32(FALSE);
Kiet Lam64c1b492013-07-12 13:56:44 +053013285 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013286 pBuf += sizeof(tAniBool);
Jeff Johnson43971f52012-07-17 12:26:56 -070013287 }
13288#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013289
13290 // txLdpcIniFeatureEnabled
13291 *pBuf = (tANI_U8)pMac->roam.configParam.txLdpcEnable;
13292 pBuf++;
13293
Kiran4a17ebe2013-01-31 10:43:43 -080013294 if ((csrIs11hSupported (pMac)) && (CSR_IS_CHANNEL_5GHZ(pBssDescription->channelId)) &&
13295 (pIes->Country.present) && (!pMac->roam.configParam.fSupplicantCountryCodeHasPriority))
13296 {
13297 csrSaveToChannelPower2G_5G( pMac, pIes->Country.num_triplets * sizeof(tSirMacChanInfo),
13298 (tSirMacChanInfo *)(&pIes->Country.triplets[0]) );
13299 csrApplyPower2Current(pMac);
13300 }
13301
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013302#ifdef WLAN_FEATURE_11AC
Kiran4a17ebe2013-01-31 10:43:43 -080013303 // txBFIniFeatureEnabled
13304 *pBuf = (tANI_U8)pMac->roam.configParam.txBFEnable;
13305 pBuf++;
Shailender Karmuchicc3fe442013-02-16 18:18:33 -080013306
13307 // txBFCsnValue
13308 *pBuf = (tANI_U8)pMac->roam.configParam.txBFCsnValue;
13309 pBuf++;
Abhishek Singh6d5d29c2014-07-03 14:25:22 +053013310
13311 /* Only enable MuBf if no other MuBF session exist
13312 * and FW and HOST is MuBF capable.
13313 */
13314 if ( IS_MUMIMO_BFORMEE_CAPABLE && (FALSE == pMac->isMuBfsessionexist) )
13315 {
13316 *pBuf = (tANI_U8)pMac->roam.configParam.txMuBformee;
13317 pBuf++;
13318 }
13319 else
13320 {
13321 *pBuf = 0;
13322 pBuf++;
13323 }
Shailender Karmuchi08f87c22013-01-17 12:51:24 -080013324#endif
krunal soni5afa96c2013-09-06 22:19:02 -070013325 *pBuf = (tANI_U8)pMac->roam.configParam.isAmsduSupportInAMPDU;
13326 pBuf++;
13327
Sandeep Puligillaaea98a22013-12-04 13:36:32 +053013328 // WME
13329 if(pMac->roam.roamSession[sessionId].fWMMConnection)
13330 {
13331 //WME enabled
13332 dwTmp = pal_cpu_to_be32(TRUE);
13333 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13334 pBuf += sizeof(tAniBool);
13335 }
13336 else
13337 {
13338 dwTmp = pal_cpu_to_be32(FALSE);
13339 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13340 pBuf += sizeof(tAniBool);
13341 }
13342
13343 // QOS
13344 if(pMac->roam.roamSession[sessionId].fQOSConnection)
13345 {
13346 //QOS enabled
13347 dwTmp = pal_cpu_to_be32(TRUE);
13348 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13349 pBuf += sizeof(tAniBool);
13350 }
13351 else
13352 {
13353 dwTmp = pal_cpu_to_be32(FALSE);
13354 vos_mem_copy(pBuf, &dwTmp, sizeof(tAniBool));
13355 pBuf += sizeof(tAniBool);
13356 }
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013357 //BssDesc
13358 csrPrepareJoinReassocReqBuffer( pMac, pBssDescription, pBuf,
13359 (tANI_U8)pProfile->uapsd_mask);
krunal soni5afa96c2013-09-06 22:19:02 -070013360
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013361 status = palSendMBMessage(pMac->hHdd, pMsg );
Girish Gowlicc337b12014-07-31 19:10:35 +053013362 /* Memory allocated to pMsg will get free'd in palSendMBMessage */
13363 pMsg = NULL;
13364
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013365 if(!HAL_STATUS_SUCCESS(status))
13366 {
13367 break;
13368 }
13369 else
13370 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013371#ifndef WLAN_MDM_CODE_REDUCTION_OPT
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013372 if (eWNI_SME_JOIN_REQ == messageType)
13373 {
13374 //Tush-QoS: notify QoS module that join happening
13375 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_JOIN_REQ, NULL);
13376 }
13377 else if (eWNI_SME_REASSOC_REQ == messageType)
13378 {
13379 //Tush-QoS: notify QoS module that reassoc happening
13380 sme_QosCsrEventInd(pMac, (v_U8_t)sessionId, SME_QOS_CSR_REASSOC_REQ, NULL);
13381 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013382#endif
Srinivas Girigowdac16730e2013-01-16 13:39:39 -080013383 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013384 } while( 0 );
Girish Gowlicc337b12014-07-31 19:10:35 +053013385
13386 if (pMsg != NULL)
13387 {
13388 vos_mem_free( pMsg );
13389 }
13390
Jeff Johnson295189b2012-06-20 16:38:30 -070013391 return( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070013392}
13393
Jeff Johnson295189b2012-06-20 16:38:30 -070013394//
13395eHalStatus csrSendMBDisassocReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13396{
13397 eHalStatus status = eHAL_STATUS_SUCCESS;
13398 tSirSmeDisassocReq *pMsg;
13399 tANI_U8 *pBuf;
13400 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013401 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13402 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13403 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013404 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013405 pMsg = vos_mem_malloc(sizeof(tSirSmeDisassocReq));
13406 if (NULL == pMsg)
13407 status = eHAL_STATUS_FAILURE;
13408 else
13409 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013410 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013411 vos_mem_set(pMsg, sizeof( tSirSmeDisassocReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013412 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_REQ);
13413 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013414 pBuf = &pMsg->sessionId;
13415 // sessionId
13416 *pBuf++ = (tANI_U8)sessionId;
13417 // transactionId
13418 *pBuf = 0;
13419 *( pBuf + 1 ) = 0;
13420 pBuf += sizeof(tANI_U16);
13421
Gopichand Nakkala06a7b3f2013-03-05 17:56:50 +053013422 if ( (pSession->pCurRoamProfile != NULL) &&
13423 ((CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
13424 (CSR_IS_WDS_AP(pSession->pCurRoamProfile))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070013425 {
13426 // Set the bssid address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013427 vos_mem_copy((tSirMacAddr *)pBuf, pSession->selfMacAddr,
13428 sizeof( tSirMacAddr ));
13429 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013430 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013431 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013432 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13433 //perMacAddr is passed as bssId for softAP
13434 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013435 pBuf = pBuf + sizeof ( tSirMacAddr );
13436 }
13437 else
13438 {
Jeff Johnson295189b2012-06-20 16:38:30 -070013439 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013440 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( tSirMacAddr ));
13441 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013442 pBuf = pBuf + sizeof ( tSirMacAddr );
Kiet Lam64c1b492013-07-12 13:56:44 +053013443 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof( pMsg->bssId ));
13444 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013445 pBuf = pBuf + sizeof ( tSirMacAddr );
Jeff Johnson295189b2012-06-20 16:38:30 -070013446 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013447 if(!HAL_STATUS_SUCCESS(status))
13448 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013449 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013450 break;
13451 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013452 // reasonCode
13453 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013454 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
13455 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013456 if(!HAL_STATUS_SUCCESS(status))
13457 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013458 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013459 break;
13460 }
13461 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013462 /* The state will be DISASSOC_HANDOFF only when we are doing handoff.
13463 Here we should not send the disassoc over the air to the AP */
13464 if ( CSR_IS_ROAM_SUBSTATE_DISASSOC_HO(pMac, sessionId)
13465#ifdef WLAN_FEATURE_VOWIFI_11R
13466 && csrRoamIs11rAssoc(pMac)
13467#endif
13468 )
13469 {
13470 *pBuf = CSR_DONT_SEND_DISASSOC_OVER_THE_AIR; /* Set DoNotSendOverTheAir flag to 1 only for handoff case */
13471 }
13472 pBuf += sizeof(tANI_U8);
13473 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013474 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013475 return( status );
13476}
Jeff Johnson295189b2012-06-20 16:38:30 -070013477eHalStatus csrSendMBTkipCounterMeasuresReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_BOOLEAN bEnable, tSirMacAddr bssId )
13478{
13479 eHalStatus status = eHAL_STATUS_SUCCESS;
13480 tSirSmeTkipCntrMeasReq *pMsg;
13481 tANI_U8 *pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013482 do
13483 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013484 pMsg = vos_mem_malloc(sizeof( tSirSmeTkipCntrMeasReq ));
13485 if ( NULL == pMsg )
13486 status = eHAL_STATUS_FAILURE;
13487 else
13488 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013489 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013490 vos_mem_set(pMsg, sizeof( tSirSmeTkipCntrMeasReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013491 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_TKIP_CNTR_MEAS_REQ);
13492 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeTkipCntrMeasReq ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013493 pBuf = &pMsg->sessionId;
13494 // sessionId
13495 *pBuf++ = (tANI_U8)sessionId;
13496 // transactionId
13497 *pBuf = 0;
13498 *( pBuf + 1 ) = 0;
13499 pBuf += sizeof(tANI_U16);
13500 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053013501 vos_mem_copy(pMsg->bssId, bssId, sizeof( tSirMacAddr ));
13502 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013503 pBuf = pBuf + sizeof ( tSirMacAddr );
13504 // bEnable
13505 *pBuf = (tANI_BOOLEAN)bEnable;
13506 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 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013512 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013513 return( status );
13514}
Jeff Johnson295189b2012-06-20 16:38:30 -070013515eHalStatus
13516csrSendMBGetAssociatedStasReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
13517 VOS_MODULE_ID modId, tSirMacAddr bssId,
13518 void *pUsrContext, void *pfnSapEventCallback,
13519 tANI_U8 *pAssocStasBuf )
13520{
13521 eHalStatus status = eHAL_STATUS_SUCCESS;
13522 tSirSmeGetAssocSTAsReq *pMsg;
13523 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
13524 tANI_U32 dwTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013525 do
13526 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013527 pMsg = vos_mem_malloc(sizeof( tSirSmeGetAssocSTAsReq ));
13528 if ( NULL == pMsg )
13529 status = eHAL_STATUS_FAILURE;
13530 else
13531 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013532 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013533 vos_mem_set(pMsg, sizeof( tSirSmeGetAssocSTAsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013534 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ASSOC_STAS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013535 pBuf = (tANI_U8 *)&pMsg->bssId;
13536 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013537 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013538 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013539 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013540 // modId
13541 dwTmp = pal_cpu_to_be16((tANI_U16)modId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013542 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013543 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013544 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013545 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void *));
13546 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013547 // pfnSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013548 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void*));
13549 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013550 // pAssocStasBuf
krunal soni4f802b22014-02-11 17:01:13 -080013551 vos_mem_copy(pBuf, pAssocStasBuf, sizeof(void*));
13552 pBuf += sizeof(void*);
Jeff Johnson295189b2012-06-20 16:38:30 -070013553 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013554 status = palSendMBMessage( pMac->hHdd, pMsg );
13555 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013556 return( status );
13557 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013558eHalStatus
13559csrSendMBGetWPSPBCSessions( tpAniSirGlobal pMac, tANI_U32 sessionId,
13560 tSirMacAddr bssId, void *pUsrContext, void *pfnSapEventCallback,v_MACADDR_t pRemoveMac)
13561 {
13562 eHalStatus status = eHAL_STATUS_SUCCESS;
13563 tSirSmeGetWPSPBCSessionsReq *pMsg;
13564 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
krunal soni4f802b22014-02-11 17:01:13 -080013565
Jeff Johnson295189b2012-06-20 16:38:30 -070013566 do
13567 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013568 pMsg = vos_mem_malloc(sizeof(tSirSmeGetWPSPBCSessionsReq));
13569 if ( NULL == pMsg )
13570 status = eHAL_STATUS_FAILURE;
13571 else
13572 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013573 if (!HAL_STATUS_SUCCESS(status)) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013574 vos_mem_set(pMsg, sizeof( tSirSmeGetWPSPBCSessionsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013575 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_WPSPBC_SESSION_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013576 pBuf = (tANI_U8 *)&pMsg->pUsrContext;
lukez3c809222013-05-03 10:23:02 -070013577 VOS_ASSERT(pBuf);
13578
Jeff Johnson295189b2012-06-20 16:38:30 -070013579 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013580 // pUsrContext
krunal soni4f802b22014-02-11 17:01:13 -080013581 vos_mem_copy(pBuf, (tANI_U8 *)pUsrContext, sizeof(void*));
13582 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013583 // pSapEventCallback
krunal soni4f802b22014-02-11 17:01:13 -080013584 vos_mem_copy(pBuf, (tANI_U8 *)pfnSapEventCallback, sizeof(void *));
13585 pBuf += sizeof(void *);
Jeff Johnson295189b2012-06-20 16:38:30 -070013586 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013587 vos_mem_copy((tSirMacAddr *)pBuf, bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013588 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013589 // MAC Address of STA in WPS session
Kiet Lam64c1b492013-07-12 13:56:44 +053013590 vos_mem_copy((tSirMacAddr *)pBuf, pRemoveMac.bytes, sizeof(v_MACADDR_t));
Jeff Johnson295189b2012-06-20 16:38:30 -070013591 pBuf += sizeof(v_MACADDR_t);
Jeff Johnson295189b2012-06-20 16:38:30 -070013592 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)));//msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070013593 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013594 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013595 return( status );
13596}
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013597
13598eHalStatus
13599csrSendChngMCCBeaconInterval(tpAniSirGlobal pMac, tANI_U32 sessionId)
13600{
13601 tpSirChangeBIParams pMsg;
13602 tANI_U16 len = 0;
13603 eHalStatus status = eHAL_STATUS_SUCCESS;
13604 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13605
13606 if(!pSession)
13607 {
13608 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
13609 return eHAL_STATUS_FAILURE;
13610 }
13611
13612 //NO need to update the Beacon Params if update beacon parameter flag is not set
13613 if(!pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval )
13614 return eHAL_STATUS_SUCCESS;
13615
13616 pMac->roam.roamSession[sessionId].bssParams.updatebeaconInterval = eANI_BOOLEAN_FALSE;
13617
13618 /* Create the message and send to lim */
13619 len = sizeof(tSirChangeBIParams);
Kiet Lam64c1b492013-07-12 13:56:44 +053013620 pMsg = vos_mem_malloc(len);
13621 if ( NULL == pMsg )
13622 status = eHAL_STATUS_FAILURE;
13623 else
13624 status = eHAL_STATUS_SUCCESS;
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013625 if(HAL_STATUS_SUCCESS(status))
13626 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013627 vos_mem_set(pMsg, sizeof(tSirChangeBIParams), 0);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013628 pMsg->messageType = eWNI_SME_CHNG_MCC_BEACON_INTERVAL;
13629 pMsg->length = len;
13630
13631 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013632 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
13633 sizeof(tSirMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -080013634 smsLog( pMac, LOG1, FL("CSR Attempting to change BI for Bssid= "MAC_ADDRESS_STR),
13635 MAC_ADDR_ARRAY(pMsg->bssId));
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013636 pMsg->sessionId = sessionId;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013637 smsLog(pMac, LOG1, FL(" session %d BeaconInterval %d"), sessionId, pMac->roam.roamSession[sessionId].bssParams.beaconInterval);
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080013638 pMsg->beaconInterval = pMac->roam.roamSession[sessionId].bssParams.beaconInterval;
13639 status = palSendMBMessage(pMac->hHdd, pMsg);
13640 }
13641 return status;
13642}
13643
Jeff Johnson295189b2012-06-20 16:38:30 -070013644eHalStatus csrSendMBDeauthReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirMacAddr bssId, tANI_U16 reasonCode )
13645{
13646 eHalStatus status = eHAL_STATUS_SUCCESS;
13647 tSirSmeDeauthReq *pMsg;
13648 tANI_U8 *pBuf;
13649 tANI_U16 wTmp;
13650 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
13651 if (!CSR_IS_SESSION_VALID( pMac, sessionId ))
13652 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070013653 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013654 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthReq ));
13655 if ( NULL == pMsg )
13656 status = eHAL_STATUS_FAILURE;
13657 else
13658 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013659 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013660 vos_mem_set(pMsg, sizeof( tSirSmeDeauthReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013661 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_REQ);
13662 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthReq ));
13663 //sessionId
13664 pBuf = &pMsg->sessionId;
13665 *pBuf++ = (tANI_U8)sessionId;
13666
13667 //tansactionId
13668 *pBuf = 0;
13669 *(pBuf + 1 ) = 0;
13670 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070013671 if ((pSession->pCurRoamProfile != NULL) && (
Jeff Johnson295189b2012-06-20 16:38:30 -070013672 (CSR_IS_INFRA_AP(pSession->pCurRoamProfile)) ||
Jeff Johnson295189b2012-06-20 16:38:30 -070013673 (CSR_IS_WDS_AP(pSession->pCurRoamProfile)))){
13674 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013675 vos_mem_copy( (tSirMacAddr *)pBuf, pSession->selfMacAddr,
13676 sizeof( pMsg->peerMacAddr ) );
13677 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013678 pBuf = pBuf + sizeof(tSirMacAddr);
13679 }
13680 else
13681 {
13682 // Set the BSSID before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013683 vos_mem_copy( (tSirMacAddr *)pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13684 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013685 pBuf = pBuf + sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070013686 }
13687 if(!HAL_STATUS_SUCCESS(status))
13688 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013689 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013690 break;
13691 }
13692 // Set the peer MAC address before sending the message to LIM
Kiet Lam64c1b492013-07-12 13:56:44 +053013693 vos_mem_copy( (tSirMacAddr *) pBuf, bssId, sizeof( pMsg->peerMacAddr ) );
13694 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013695 pBuf = pBuf + sizeof(tSirMacAddr);
13696 if(!HAL_STATUS_SUCCESS(status))
13697 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013698 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013699 break;
13700 }
13701 wTmp = pal_cpu_to_be16(reasonCode);
Kiet Lam64c1b492013-07-12 13:56:44 +053013702 vos_mem_copy( pBuf, &wTmp,sizeof( tANI_U16 ) );
13703 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013704 if(!HAL_STATUS_SUCCESS(status))
13705 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013706 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013707 break;
13708 }
13709 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013710 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013711 return( status );
13712}
13713
Jeff Johnson295189b2012-06-20 16:38:30 -070013714eHalStatus csrSendMBDisassocCnfMsg( tpAniSirGlobal pMac, tpSirSmeDisassocInd pDisassocInd )
13715{
13716 eHalStatus status = eHAL_STATUS_SUCCESS;
13717 tSirSmeDisassocCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013718 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013719 pMsg = vos_mem_malloc(sizeof( tSirSmeDisassocCnf ));
13720 if ( NULL == pMsg )
13721 status = eHAL_STATUS_FAILURE;
13722 else
13723 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013724 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013725 vos_mem_set(pMsg, sizeof( tSirSmeDisassocCnf), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013726 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DISASSOC_CNF);
13727 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13728 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDisassocCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013729 vos_mem_copy(pMsg->peerMacAddr, pDisassocInd->peerMacAddr,
13730 sizeof(pMsg->peerMacAddr));
13731 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013732 if(!HAL_STATUS_SUCCESS(status))
13733 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013734 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013735 break;
13736 }
13737//To test reconn
Kiet Lam64c1b492013-07-12 13:56:44 +053013738 vos_mem_copy(pMsg->bssId, pDisassocInd->bssId, sizeof(pMsg->peerMacAddr));
13739 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013740 if(!HAL_STATUS_SUCCESS(status))
13741 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013742 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013743 break;
13744 }
13745//To test reconn ends
Jeff Johnson295189b2012-06-20 16:38:30 -070013746 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013747 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013748 return( status );
13749}
13750
Jeff Johnson295189b2012-06-20 16:38:30 -070013751eHalStatus csrSendMBDeauthCnfMsg( tpAniSirGlobal pMac, tpSirSmeDeauthInd pDeauthInd )
13752{
13753 eHalStatus status = eHAL_STATUS_SUCCESS;
13754 tSirSmeDeauthCnf *pMsg;
Jeff Johnson295189b2012-06-20 16:38:30 -070013755 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013756 pMsg = vos_mem_malloc(sizeof( tSirSmeDeauthCnf ));
13757 if ( NULL == pMsg )
13758 status = eHAL_STATUS_FAILURE;
13759 else
13760 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013761 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013762 vos_mem_set(pMsg, sizeof( tSirSmeDeauthCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013763 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEAUTH_CNF);
13764 pMsg->statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13765 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeDeauthCnf ));
Kiet Lam64c1b492013-07-12 13:56:44 +053013766 vos_mem_copy(pMsg->bssId, pDeauthInd->bssId, sizeof(pMsg->bssId));
13767 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013768 if(!HAL_STATUS_SUCCESS(status))
13769 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013770 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013771 break;
13772 }
Kiet Lam64c1b492013-07-12 13:56:44 +053013773 vos_mem_copy(pMsg->peerMacAddr, pDeauthInd->peerMacAddr,
13774 sizeof(pMsg->peerMacAddr));
13775 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013776 if(!HAL_STATUS_SUCCESS(status))
13777 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013778 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013779 break;
13780 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013781 status = palSendMBMessage( pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070013782 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013783 return( status );
13784}
Jeff Johnson295189b2012-06-20 16:38:30 -070013785eHalStatus csrSendAssocCnfMsg( tpAniSirGlobal pMac, tpSirSmeAssocInd pAssocInd, eHalStatus Halstatus )
13786{
13787 eHalStatus status = eHAL_STATUS_SUCCESS;
13788 tSirSmeAssocCnf *pMsg;
13789 tANI_U8 *pBuf;
13790 tSirResultCodes statusCode;
13791 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013792 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013793 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocCnf ));
13794 if ( NULL == pMsg )
13795 status = eHAL_STATUS_FAILURE;
13796 else
13797 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013798 if ( !HAL_STATUS_SUCCESS(status) ) break;
Kiet Lam64c1b492013-07-12 13:56:44 +053013799 vos_mem_set(pMsg, sizeof( tSirSmeAssocCnf ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013800 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ASSOC_CNF);
13801 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocCnf ));
Jeff Johnson295189b2012-06-20 16:38:30 -070013802 pBuf = (tANI_U8 *)&pMsg->statusCode;
13803 if(HAL_STATUS_SUCCESS(Halstatus))
13804 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13805 else
13806 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013807 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes));
Jeff Johnson295189b2012-06-20 16:38:30 -070013808 pBuf += sizeof(tSirResultCodes);
13809 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013810 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13811 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013812 pBuf += sizeof (tSirMacAddr);
13813 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013814 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13815 sizeof(tSirMacAddr));
13816 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013817 pBuf += sizeof (tSirMacAddr);
13818 // aid
13819 wTmp = pal_cpu_to_be16(pAssocInd->aid);
Kiet Lam64c1b492013-07-12 13:56:44 +053013820 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013821 pBuf += sizeof (tANI_U16);
13822 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013823 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
13824 status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070013825 pBuf += sizeof (tSirMacAddr);
13826 // alternateChannelId
13827 *pBuf = 11;
Jeff Johnson295189b2012-06-20 16:38:30 -070013828 status = palSendMBMessage( pMac->hHdd, pMsg );
13829 if(!HAL_STATUS_SUCCESS(status))
13830 {
13831 //pMsg is freed by palSendMBMessage
13832 break;
13833 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013834 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013835 return( status );
13836}
Jeff Johnson295189b2012-06-20 16:38:30 -070013837eHalStatus csrSendAssocIndToUpperLayerCnfMsg( tpAniSirGlobal pMac,
13838 tpSirSmeAssocInd pAssocInd,
13839 eHalStatus Halstatus,
13840 tANI_U8 sessionId)
13841{
13842 tSirMsgQ msgQ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013843 tSirSmeAssocIndToUpperLayerCnf *pMsg;
13844 tANI_U8 *pBuf;
13845 tSirResultCodes statusCode;
13846 tANI_U16 wTmp;
Jeff Johnson295189b2012-06-20 16:38:30 -070013847 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053013848 pMsg = vos_mem_malloc(sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13849 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13850 vos_mem_set(pMsg, sizeof( tSirSmeAssocIndToUpperLayerCnf ), 0);
Jeff Johnsone7245742012-09-05 17:12:55 -070013851
Jeff Johnson295189b2012-06-20 16:38:30 -070013852 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPPER_LAYER_ASSOC_CNF);
13853 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeAssocIndToUpperLayerCnf ));
13854
13855 pMsg->sessionId = sessionId;
13856
13857 pBuf = (tANI_U8 *)&pMsg->statusCode;
13858 if(HAL_STATUS_SUCCESS(Halstatus))
13859 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_SUCCESS);
13860 else
13861 statusCode = (tSirResultCodes)pal_cpu_to_be32(eSIR_SME_ASSOC_REFUSED);
Kiet Lam64c1b492013-07-12 13:56:44 +053013862 vos_mem_copy(pBuf, &statusCode, sizeof(tSirResultCodes)) ;
Jeff Johnson295189b2012-06-20 16:38:30 -070013863 pBuf += sizeof(tSirResultCodes);
13864 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013865 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013866 pBuf += sizeof (tSirMacAddr);
13867 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013868 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->peerMacAddr,
13869 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013870 pBuf += sizeof (tSirMacAddr);
13871 // StaId
13872 wTmp = pal_cpu_to_be16(pAssocInd->staId);
Kiet Lam64c1b492013-07-12 13:56:44 +053013873 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070013874 pBuf += sizeof (tANI_U16);
13875 // alternateBssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013876 vos_mem_copy((tSirMacAddr *)pBuf, pAssocInd->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013877 pBuf += sizeof (tSirMacAddr);
13878 // alternateChannelId
13879 *pBuf = 11;
13880 pBuf += sizeof (tANI_U8);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013881 // Instead of copying roam Info, we just copy only WmmEnabled, RsnIE information
Jeff Johnson295189b2012-06-20 16:38:30 -070013882 //Wmm
13883 *pBuf = pAssocInd->wmmEnabledSta;
13884 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013885 //RSN IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013886 vos_mem_copy((tSirRSNie *)pBuf, &pAssocInd->rsnIE, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013887 pBuf += sizeof (tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013888 //Additional IE
Kiet Lam64c1b492013-07-12 13:56:44 +053013889 vos_mem_copy((void *)pBuf, &pAssocInd->addIE, sizeof(tSirAddie));
Jeff Johnson295189b2012-06-20 16:38:30 -070013890 pBuf += sizeof (tSirAddie);
Jeff Johnson295189b2012-06-20 16:38:30 -070013891 //reassocReq
13892 *pBuf = pAssocInd->reassocReq;
13893 pBuf += sizeof (tANI_U8);
Jeff Johnson295189b2012-06-20 16:38:30 -070013894 msgQ.type = eWNI_SME_UPPER_LAYER_ASSOC_CNF;
13895 msgQ.bodyptr = pMsg;
13896 msgQ.bodyval = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070013897 SysProcessMmhMsg(pMac, &msgQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070013898 } while( 0 );
Kiet Lam64c1b492013-07-12 13:56:44 +053013899 return( eHAL_STATUS_SUCCESS );
Jeff Johnson295189b2012-06-20 16:38:30 -070013900}
Jeff Johnson295189b2012-06-20 16:38:30 -070013901
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053013902eHalStatus csrSendMBSetContextReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId,
Jeff Johnson295189b2012-06-20 16:38:30 -070013903 tSirMacAddr peerMacAddr, tANI_U8 numKeys, tAniEdType edType,
13904 tANI_BOOLEAN fUnicast, tAniKeyDirection aniKeyDirection,
13905 tANI_U8 keyId, tANI_U8 keyLength, tANI_U8 *pKey, tANI_U8 paeRole,
13906 tANI_U8 *pKeyRsc )
13907{
13908 tSirSmeSetContextReq *pMsg;
13909 tANI_U16 msgLen;
13910 eHalStatus status = eHAL_STATUS_FAILURE;
13911 tAniEdType tmpEdType;
13912 tAniKeyDirection tmpDirection;
Gopichand Nakkalad5a904e2013-03-29 01:07:54 +053013913 tANI_U8 *pBuf = NULL;
13914 tANI_U8 *p = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070013915 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Sushant Kaushike7de85f2014-06-16 17:13:30 +053013916 smsLog( pMac, LOG1, FL("keylength is %d, Encry type is : %d"),
13917 keyLength, edType);
Jeff Johnson295189b2012-06-20 16:38:30 -070013918 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070013919 if( ( 1 != numKeys ) && ( 0 != numKeys ) ) break;
Jeff Johnson295189b2012-06-20 16:38:30 -070013920 // all of these fields appear in every SET_CONTEXT message. Below we'll add in the size for each
13921 // key set. Since we only support upto one key, we always allocate memory for 1 key
13922 msgLen = sizeof( tANI_U16) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) +
13923 sizeof( tSirMacAddr ) + 1 + sizeof(tANI_U16) +
13924 sizeof( pMsg->keyMaterial.length ) + sizeof( pMsg->keyMaterial.edType ) + sizeof( pMsg->keyMaterial.numKeys ) +
13925 ( sizeof( pMsg->keyMaterial.key ) );
13926
Kiet Lam64c1b492013-07-12 13:56:44 +053013927 pMsg = vos_mem_malloc(msgLen);
13928 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
13929 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070013930 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SETCONTEXT_REQ);
13931 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070013932 //sessionId
13933 pBuf = &pMsg->sessionId;
13934 *pBuf = (tANI_U8)sessionId;
13935 pBuf++;
13936 // transactionId
13937 *pBuf = 0;
13938 *(pBuf + 1) = 0;
13939 pBuf += sizeof(tANI_U16);
13940 // peerMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053013941 vos_mem_copy(pBuf, (tANI_U8 *)peerMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013942
13943 pBuf += sizeof(tSirMacAddr);
13944
13945 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053013946 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
13947 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070013948
13949 pBuf += sizeof(tSirMacAddr);
13950
13951 p = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070013952 // Set the pMsg->keyMaterial.length field (this length is defined as all data that follows the edType field
13953 // in the tSirKeyMaterial keyMaterial; field).
13954 //
13955 // !!NOTE: This keyMaterial.length contains the length of a MAX size key, though the keyLength can be
13956 // shorter than this max size. Is LIM interpreting this ok ?
13957 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 -070013958 // set pMsg->keyMaterial.edType
13959 tmpEdType = (tAniEdType)pal_cpu_to_be32(edType);
Kiet Lam64c1b492013-07-12 13:56:44 +053013960 vos_mem_copy(p, (tANI_U8 *)&tmpEdType, sizeof(tAniEdType));
Jeff Johnson295189b2012-06-20 16:38:30 -070013961 p += sizeof( pMsg->keyMaterial.edType );
Jeff Johnson295189b2012-06-20 16:38:30 -070013962 // set the pMsg->keyMaterial.numKeys field
13963 *p = numKeys;
13964 p += sizeof( pMsg->keyMaterial.numKeys );
Jeff Johnson295189b2012-06-20 16:38:30 -070013965 // set pSirKey->keyId = keyId;
13966 *p = keyId;
13967 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyId );
Jeff Johnson295189b2012-06-20 16:38:30 -070013968 // set pSirKey->unicast = (tANI_U8)fUnicast;
13969 *p = (tANI_U8)fUnicast;
13970 p += sizeof( pMsg->keyMaterial.key[ 0 ].unicast );
Jeff Johnson295189b2012-06-20 16:38:30 -070013971 // set pSirKey->keyDirection = aniKeyDirection;
13972 tmpDirection = (tAniKeyDirection)pal_cpu_to_be32(aniKeyDirection);
Kiet Lam64c1b492013-07-12 13:56:44 +053013973 vos_mem_copy(p, (tANI_U8 *)&tmpDirection, sizeof(tAniKeyDirection));
Jeff Johnson295189b2012-06-20 16:38:30 -070013974 p += sizeof(tAniKeyDirection);
13975 // pSirKey->keyRsc = ;;
Kiet Lam64c1b492013-07-12 13:56:44 +053013976 vos_mem_copy(p, pKeyRsc, CSR_MAX_RSC_LEN);
Jeff Johnson295189b2012-06-20 16:38:30 -070013977 p += sizeof( pMsg->keyMaterial.key[ 0 ].keyRsc );
Jeff Johnson295189b2012-06-20 16:38:30 -070013978 // set pSirKey->paeRole
13979 *p = paeRole; // 0 is Supplicant
13980 p++;
Jeff Johnson295189b2012-06-20 16:38:30 -070013981 // set pSirKey->keyLength = keyLength;
13982 p = pal_set_U16( p, pal_cpu_to_be16(keyLength) );
Jeff Johnson295189b2012-06-20 16:38:30 -070013983 if ( keyLength && pKey )
13984 {
Kiet Lam64c1b492013-07-12 13:56:44 +053013985 vos_mem_copy(p, pKey, keyLength);
Jeff Johnson295189b2012-06-20 16:38:30 -070013986 if(keyLength == 16)
13987 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080013988 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 -070013989 keyId, edType, pKey[0], pKey[1], pKey[2], pKey[3], pKey[4],
13990 pKey[5], pKey[6], pKey[7], pKey[8],
13991 pKey[9], pKey[10], pKey[11], pKey[12], pKey[13], pKey[14], pKey[15]);
13992 }
13993 }
Jeff Johnson295189b2012-06-20 16:38:30 -070013994 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070013995 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070013996 return( status );
13997}
13998
Jeff Johnson295189b2012-06-20 16:38:30 -070013999eHalStatus csrSendMBStartBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId, eCsrRoamBssType bssType,
14000 tCsrRoamStartBssParams *pParam, tSirBssDescription *pBssDesc )
14001{
14002 eHalStatus status;
14003 tSirSmeStartBssReq *pMsg;
14004 tANI_U8 *pBuf = NULL;
14005 tANI_U8 *wTmpBuf = NULL;
14006 tANI_U16 msgLen, wTmp;
14007 tANI_U32 dwTmp;
14008 tSirNwType nwType;
Jeff Johnsone7245742012-09-05 17:12:55 -070014009 ePhyChanBondState cbMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014010 tANI_U32 authType;
Jeff Johnson295189b2012-06-20 16:38:30 -070014011 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014012
14013 if(!pSession)
14014 {
14015 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14016 return eHAL_STATUS_FAILURE;
14017 }
14018
Jeff Johnson295189b2012-06-20 16:38:30 -070014019 do {
14020 pSession->joinFailStatusCode.statusCode = eSIR_SME_SUCCESS;
14021 pSession->joinFailStatusCode.reasonCode = 0;
14022 msgLen = sizeof(tSirSmeStartBssReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014023 pMsg = vos_mem_malloc(msgLen);
14024 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14025 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014026 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_START_BSS_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070014027 pBuf = &pMsg->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014028 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070014029 //sessionId
14030 *pBuf = (tANI_U8)sessionId;
14031 pBuf++;
14032 // transactionId
14033 *pBuf = 0;
14034 *(pBuf + 1) = 0;
14035 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014036 // bssid
Kiet Lam64c1b492013-07-12 13:56:44 +053014037 vos_mem_copy(pBuf, pParam->bssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014038 pBuf += sizeof(tSirMacAddr);
14039 // selfMacAddr
Kiet Lam64c1b492013-07-12 13:56:44 +053014040 vos_mem_copy(pBuf, pSession->selfMacAddr, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014041 pBuf += sizeof(tSirMacAddr);
14042 // beaconInterval
14043 if( pBssDesc && pBssDesc->beaconInterval )
14044 {
14045 wTmp = pal_cpu_to_be16( pBssDesc->beaconInterval );
14046 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014047 else if(pParam->beaconInterval)
14048 {
14049 wTmp = pal_cpu_to_be16( pParam->beaconInterval );
14050 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014051 else
14052 {
14053 wTmp = pal_cpu_to_be16( WNI_CFG_BEACON_INTERVAL_STADEF );
14054 }
Sudhir Sattayappa Kohallid9a4df62013-04-04 14:47:54 -070014055 if(csrIsconcurrentsessionValid (pMac, sessionId,
14056 pParam->bssPersona)
Jeff Johnsone7245742012-09-05 17:12:55 -070014057 == eHAL_STATUS_SUCCESS )
14058 {
Madan Mohan Koyyalamudi167b95e2012-11-27 15:53:38 -080014059 csrValidateMCCBeaconInterval(pMac, pParam->operationChn, &wTmp, sessionId,
Jeff Johnsone7245742012-09-05 17:12:55 -070014060 pParam->bssPersona);
14061 //Update the beacon Interval
14062 pParam->beaconInterval = wTmp;
14063 }
14064 else
14065 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014066 smsLog( pMac,LOGE, FL("****Start BSS failed persona already exists***"));
Jeff Johnsone7245742012-09-05 17:12:55 -070014067 status = eHAL_STATUS_FAILURE;
Kiet Lam64c1b492013-07-12 13:56:44 +053014068 vos_mem_free(pMsg);
Jeff Johnsone7245742012-09-05 17:12:55 -070014069 return status;
14070 }
14071
Kiet Lam64c1b492013-07-12 13:56:44 +053014072 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014073 pBuf += sizeof(tANI_U16);
14074 // dot11mode
14075 *pBuf = (tANI_U8)csrTranslateToWNICfgDot11Mode( pMac, pParam->uCfgDot11Mode );
14076 pBuf += 1;
14077 // bssType
14078 dwTmp = pal_cpu_to_be32( csrTranslateBsstypeToMacType( bssType ) );
Kiet Lam64c1b492013-07-12 13:56:44 +053014079 vos_mem_copy(pBuf, &dwTmp, sizeof(tSirBssType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014080 pBuf += sizeof(tSirBssType);
14081 // ssId
14082 if( pParam->ssId.length )
14083 {
14084 // ssId len
14085 *pBuf = pParam->ssId.length;
14086 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014087 vos_mem_copy(pBuf, pParam->ssId.ssId, pParam->ssId.length);
Jeff Johnson295189b2012-06-20 16:38:30 -070014088 pBuf += pParam->ssId.length;
14089 }
14090 else
14091 {
14092 *pBuf = 0;
14093 pBuf++;
14094 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014095 // set the channel Id
14096 *pBuf = pParam->operationChn;
14097 pBuf++;
14098 //What should we really do for the cbmode.
Jeff Johnsone7245742012-09-05 17:12:55 -070014099 cbMode = (ePhyChanBondState)pal_cpu_to_be32(pParam->cbMode);
Kiet Lam64c1b492013-07-12 13:56:44 +053014100 vos_mem_copy(pBuf, (tANI_U8 *)&cbMode, sizeof(ePhyChanBondState));
Jeff Johnsone7245742012-09-05 17:12:55 -070014101 pBuf += sizeof(ePhyChanBondState);
Jeff Johnson295189b2012-06-20 16:38:30 -070014102
Jeff Johnson295189b2012-06-20 16:38:30 -070014103 // Set privacy
14104 *pBuf = pParam->privacy;
14105 pBuf++;
14106
14107 //Set Uapsd
14108 *pBuf = pParam->ApUapsdEnable;
14109 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014110 //Set SSID hidden
14111 *pBuf = pParam->ssidHidden;
14112 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014113 *pBuf = (tANI_U8)pParam->fwdWPSPBCProbeReq;
14114 pBuf++;
14115
14116 //Ht protection Enable/Disable
14117 *pBuf = (tANI_U8)pParam->protEnabled;
14118 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014119 //Enable Beacons to Receive for OBSS protection Enable/Disable
14120 *pBuf = (tANI_U8)pParam->obssProtEnabled;
14121 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014122 //set cfg related to protection
14123 wTmp = pal_cpu_to_be16( pParam->ht_protection );
Kiet Lam64c1b492013-07-12 13:56:44 +053014124 vos_mem_copy(pBuf, &wTmp, sizeof( tANI_U16 ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014125 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070014126 // Set Auth type
14127 authType = pal_cpu_to_be32(pParam->authType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014128 vos_mem_copy(pBuf, (tANI_U8 *)&authType, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014129 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014130 // Set DTIM
14131 dwTmp = pal_cpu_to_be32(pParam->dtimPeriod);
Kiet Lam64c1b492013-07-12 13:56:44 +053014132 vos_mem_copy(pBuf, (tANI_U8 *)&dwTmp, sizeof(tANI_U32));
Jeff Johnson295189b2012-06-20 16:38:30 -070014133 pBuf += sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070014134 // Set wps_state
14135 *pBuf = pParam->wps_state;
14136 pBuf++;
krunal sonie9002db2013-11-25 14:24:17 -080014137 // set isCoalesingInIBSSAllowed
14138 *pBuf = pMac->isCoalesingInIBSSAllowed;
14139 pBuf++;
Jeff Johnson295189b2012-06-20 16:38:30 -070014140 //Persona
14141 *pBuf = (tANI_U8)pParam->bssPersona;
14142 pBuf++;
14143
Gopichand Nakkalab2d2c312013-01-04 11:41:02 -080014144 //txLdpcIniFeatureEnabled
14145 *pBuf = (tANI_U8)(tANI_U8)pMac->roam.configParam.txLdpcEnable;
14146 pBuf++;
krunal soni4f087d22013-07-29 16:32:26 -070014147
Chet Lanctot8cecea22014-02-11 19:09:36 -080014148#ifdef WLAN_FEATURE_11W
14149 // Set MFP capable/required
14150 *pBuf = (tANI_U8)pParam->mfpCapable;
14151 pBuf++;
14152 *pBuf = (tANI_U8)pParam->mfpRequired;
14153 pBuf++;
14154#endif
14155
krunal soni4f087d22013-07-29 16:32:26 -070014156 // set RSN IE
Jeff Johnson295189b2012-06-20 16:38:30 -070014157 if( pParam->nRSNIELength > sizeof(pMsg->rsnIE.rsnIEdata) )
14158 {
14159 status = eHAL_STATUS_INVALID_PARAMETER;
Kiet Lam64c1b492013-07-12 13:56:44 +053014160 vos_mem_free(pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014161 break;
14162 }
14163 wTmp = pal_cpu_to_be16( pParam->nRSNIELength );
Kiet Lam64c1b492013-07-12 13:56:44 +053014164 vos_mem_copy(pBuf, &wTmp, sizeof(tANI_U16));
Jeff Johnson295189b2012-06-20 16:38:30 -070014165 pBuf += sizeof(tANI_U16);
14166 if( wTmp )
14167 {
14168 wTmp = pParam->nRSNIELength;
Kiet Lam64c1b492013-07-12 13:56:44 +053014169 vos_mem_copy(pBuf, pParam->pRSNIE, wTmp);
Jeff Johnson295189b2012-06-20 16:38:30 -070014170 pBuf += wTmp;
14171 }
14172 nwType = (tSirNwType)pal_cpu_to_be32(pParam->sirNwType);
Kiet Lam64c1b492013-07-12 13:56:44 +053014173 vos_mem_copy(pBuf, (tANI_U8 *)&nwType, sizeof(tSirNwType));
Jeff Johnson295189b2012-06-20 16:38:30 -070014174 pBuf += sizeof(tSirNwType);
Jeff Johnson295189b2012-06-20 16:38:30 -070014175 *pBuf = pParam->operationalRateSet.numRates; //tSirMacRateSet->numRates
14176 pBuf++;
Kiet Lam64c1b492013-07-12 13:56:44 +053014177 vos_mem_copy(pBuf, pParam->operationalRateSet.rate,
14178 pParam->operationalRateSet.numRates );
Jeff Johnson295189b2012-06-20 16:38:30 -070014179 pBuf += pParam->operationalRateSet.numRates ;
14180 *pBuf++ = pParam->extendedRateSet.numRates;
14181 if(0 != pParam->extendedRateSet.numRates)
14182 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014183 vos_mem_copy(pBuf, pParam->extendedRateSet.rate,
14184 pParam->extendedRateSet.numRates);
Jeff Johnson295189b2012-06-20 16:38:30 -070014185 pBuf += pParam->extendedRateSet.numRates;
14186 }
krunal sonie9002db2013-11-25 14:24:17 -080014187
Jeff Johnson295189b2012-06-20 16:38:30 -070014188 msgLen = (tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf)); //msg_header + msg
14189 pMsg->length = pal_cpu_to_be16(msgLen);
14190
14191 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014192 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014193 return( status );
14194}
14195
Jeff Johnson295189b2012-06-20 16:38:30 -070014196eHalStatus csrSendMBStopBssReqMsg( tpAniSirGlobal pMac, tANI_U32 sessionId )
14197{
14198 eHalStatus status = eHAL_STATUS_FAILURE;
14199 tSirSmeStopBssReq *pMsg;
14200 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14201 tANI_U8 *pBuf;
14202 tANI_U16 msgLen;
Jeff Johnson32d95a32012-09-10 13:15:23 -070014203
14204 if(!pSession)
14205 {
14206 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14207 return eHAL_STATUS_FAILURE;
14208 }
14209
Jeff Johnson295189b2012-06-20 16:38:30 -070014210 do {
Kiet Lam64c1b492013-07-12 13:56:44 +053014211 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14212 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14213 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014214 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14215 pBuf = &pMsg->sessionId;
14216 //sessionId
14217 *pBuf = (tANI_U8)sessionId;
14218 pBuf++;
14219 // transactionId
14220 *pBuf = 0;
14221 pBuf += sizeof(tANI_U16);
14222 //reason code
14223 *pBuf = 0;
14224 pBuf += sizeof(tSirResultCodes);
14225 // bssid
14226 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14227 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14228 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014229 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->selfMacAddr,
14230 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014231 }
14232 else
14233 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014234 vos_mem_copy(pBuf, (tANI_U8 *)&pSession->connectedProfile.bssid,
14235 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014236 }
14237 pBuf += sizeof(tSirMacAddr);
14238 msgLen = sizeof(tANI_U16) + sizeof(tANI_U16) + 1 + sizeof(tANI_U16) + sizeof(tSirResultCodes) + sizeof(tSirMacAddr);
14239 pMsg->length = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014240 status = palSendMBMessage( pMac->hHdd, pMsg );
14241#if 0
Kiet Lam64c1b492013-07-12 13:56:44 +053014242 pMsg = vos_mem_malloc(sizeof(tSirSmeStopBssReq));
14243 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14244 vos_mem_set(pMsg, sizeof( tSirSmeStopBssReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014245 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_STOP_BSS_REQ);
14246 pMsg->reasonCode = 0;
14247 // bssid
14248 // if BSSType is WDS sta, use selfmacAddr as bssid, else use bssid in connectedProfile
14249 if( CSR_IS_CONN_WDS_STA(&pSession->connectedProfile) )
14250 {
14251 pbBssid = (tANI_U8 *)&pSession->selfMacAddr;
14252 }
14253 else
14254 {
14255 pbBssid = (tANI_U8 *)&pSession->connectedProfile.bssid;
14256 }
Kiet Lam64c1b492013-07-12 13:56:44 +053014257 vos_mem_copy(&pMsg->bssId, pbBssid, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014258 pMsg->transactionId = 0;
14259 pMsg->sessionId = (tANI_U8)sessionId;
14260 pMsg->length = pal_cpu_to_be16((tANI_U16)sizeof( tSirSmeStopBssReq ));
14261 status = palSendMBMessage( pMac->hHdd, pMsg );
14262#endif
14263 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014264 return( status );
14265}
14266
Jeff Johnson295189b2012-06-20 16:38:30 -070014267eHalStatus csrReassoc(tpAniSirGlobal pMac, tANI_U32 sessionId,
14268 tCsrRoamModifyProfileFields *pModProfileFields,
14269 tANI_U32 *pRoamId, v_BOOL_t fForce)
14270{
Jeff Johnson295189b2012-06-20 16:38:30 -070014271 eHalStatus status = eHAL_STATUS_FAILURE;
14272 tANI_U32 roamId = 0;
14273 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014274 if((csrIsConnStateConnected(pMac, sessionId)) &&
Kiet Lam64c1b492013-07-12 13:56:44 +053014275 (fForce || (!vos_mem_compare( &pModProfileFields,
14276 &pSession->connectedProfile.modifyProfileFields,
14277 sizeof(tCsrRoamModifyProfileFields)))) )
Jeff Johnson295189b2012-06-20 16:38:30 -070014278 {
14279 roamId = GET_NEXT_ROAM_ID(&pMac->roam);
14280 if(pRoamId)
14281 {
14282 *pRoamId = roamId;
14283 }
14284
Jeff Johnson295189b2012-06-20 16:38:30 -070014285 status = csrRoamIssueReassoc(pMac, sessionId, NULL, pModProfileFields,
14286 eCsrSmeIssuedReassocToSameAP, roamId,
14287 eANI_BOOLEAN_FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014288 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014289 return status;
14290}
Jeff Johnson295189b2012-06-20 16:38:30 -070014291static eHalStatus csrRoamSessionOpened(tpAniSirGlobal pMac, tANI_U32 sessionId)
14292{
14293 eHalStatus status = eHAL_STATUS_SUCCESS;
14294 tCsrRoamInfo roamInfo;
Kiet Lam64c1b492013-07-12 13:56:44 +053014295 vos_mem_set(&roamInfo, sizeof(tCsrRoamInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014296 status = csrRoamCallCallback(pMac, sessionId, &roamInfo, 0,
14297 eCSR_ROAM_SESSION_OPENED, eCSR_ROAM_RESULT_NONE);
14298 return (status);
14299}
Jeff Johnson295189b2012-06-20 16:38:30 -070014300eHalStatus csrProcessAddStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14301{
14302 eHalStatus status = eHAL_STATUS_SUCCESS;
14303 tListElem *pEntry = NULL;
14304 tSmeCmd *pCommand = NULL;
14305 tSirSmeAddStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014306 do
14307 {
14308 if(pMsg == NULL)
14309 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014310 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014311 status = eHAL_STATUS_FAILURE;
14312 break;
14313 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014314 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14315 if(pEntry)
14316 {
14317 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14318 if(eSmeCommandAddStaSession == pCommand->command)
14319 {
14320 pRsp = (tSirSmeAddStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014321 smsLog( pMac, LOG1, "Add Sta rsp status = %d", pRsp->status );
Siddharth Bhal85f99b12014-05-09 08:09:07 +053014322 if (pRsp->status == eSIR_FAILURE) {
14323 VOS_ASSERT( 0 );
14324 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014325 //Nothing to be done. May be indicate the self sta addition success by calling session callback (TODO).
Jeff Johnson295189b2012-06-20 16:38:30 -070014326 csrRoamSessionOpened(pMac, pCommand->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014327 //Remove this command out of the active list
14328 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14329 {
14330 //Now put this command back on the avilable command list
14331 csrReleaseCommand(pMac, pCommand);
14332 }
14333 smeProcessPendingQueue( pMac );
14334 }
14335 else
14336 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014337 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 -070014338 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014339 status = eHAL_STATUS_FAILURE;
14340 break;
14341 }
14342 }
14343 else
14344 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014345 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 -070014346 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014347 status = eHAL_STATUS_FAILURE;
14348 break;
14349 }
14350 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014351 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014352}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014353eHalStatus csrSendMBAddSelfStaReqMsg(tpAniSirGlobal pMac,
14354 tAddStaForSessionCmd *pAddStaReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070014355{
14356 tSirSmeAddStaSelfReq *pMsg;
14357 tANI_U16 msgLen;
14358 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014359 do {
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014360 msgLen = sizeof(tSirSmeAddStaSelfReq);
Kiet Lam64c1b492013-07-12 13:56:44 +053014361 pMsg = vos_mem_malloc(msgLen);
14362 if ( NULL == pMsg ) break;
14363 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014364 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_ADD_STA_SELF_REQ);
14365 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014366 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014367 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr,
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014368 (tANI_U8 *)&pAddStaReq->selfMacAddr, sizeof(tSirMacAddr));
14369
14370 pMsg->currDeviceMode = pAddStaReq->currDeviceMode;
14371
Arif Hussain24bafea2013-11-15 15:10:03 -080014372 smsLog( pMac, LOG1, FL("selfMac="MAC_ADDRESS_STR),
14373 MAC_ADDR_ARRAY(pMsg->selfMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014374 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014375 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014376 return( status );
14377}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014378eHalStatus csrIssueAddStaForSessionReq(tpAniSirGlobal pMac,
14379 tANI_U32 sessionId,
14380 tSirMacAddr sessionMacAddr)
Jeff Johnson295189b2012-06-20 16:38:30 -070014381{
14382 eHalStatus status = eHAL_STATUS_SUCCESS;
14383 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014384 pCommand = csrGetCommandBuffer(pMac);
14385 if(NULL == pCommand)
14386 {
14387 status = eHAL_STATUS_RESOURCES;
14388 }
14389 else
14390 {
14391 pCommand->command = eSmeCommandAddStaSession;
14392 pCommand->sessionId = (tANI_U8)sessionId;
Kiet Lam64c1b492013-07-12 13:56:44 +053014393 vos_mem_copy(pCommand->u.addStaSessionCmd.selfMacAddr, sessionMacAddr,
14394 sizeof( tSirMacAddr ) );
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014395 pCommand->u.addStaSessionCmd.currDeviceMode = pMac->sme.currDeviceMode;
Jeff Johnson295189b2012-06-20 16:38:30 -070014396 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14397 if( !HAL_STATUS_SUCCESS( status ) )
14398 {
14399 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014400 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014401 }
14402 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014403 return (status);
14404}
Jeff Johnson295189b2012-06-20 16:38:30 -070014405eHalStatus csrProcessAddStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14406{
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014407 return csrSendMBAddSelfStaReqMsg(pMac, &pCommand->u.addStaSessionCmd);
Jeff Johnson295189b2012-06-20 16:38:30 -070014408}
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014409eHalStatus csrRoamOpenSession(tpAniSirGlobal pMac,
14410 csrRoamCompleteCallback callback,
14411 void *pContext, tANI_U8 *pSelfMacAddr,
14412 tANI_U8 *pbSessionId)
Jeff Johnson295189b2012-06-20 16:38:30 -070014413{
14414 eHalStatus status = eHAL_STATUS_SUCCESS;
14415 tANI_U32 i;
14416 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014417 *pbSessionId = CSR_SESSION_ID_INVALID;
14418 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14419 {
14420 if( !CSR_IS_SESSION_VALID( pMac, i ) )
14421 {
14422 pSession = CSR_GET_SESSION( pMac, i );
14423 status = eHAL_STATUS_SUCCESS;
14424 pSession->sessionActive = eANI_BOOLEAN_TRUE;
14425 pSession->sessionId = (tANI_U8)i;
14426 pSession->callback = callback;
14427 pSession->pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014428 vos_mem_copy(&pSession->selfMacAddr, pSelfMacAddr, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014429 *pbSessionId = (tANI_U8)i;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014430 status = vos_timer_init(&pSession->hTimerRoaming, VOS_TIMER_TYPE_SW,
14431 csrRoamRoamingTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014432 &pSession->roamingTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014433 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014434 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014435 smsLog(pMac, LOGE, FL("cannot allocate memory for Roaming timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014436 break;
14437 }
14438#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014439 status = vos_timer_init(&pSession->hTimerJoinRetry, VOS_TIMER_TYPE_SW,
14440 csrRoamJoinRetryTimerHandler,
Jeff Johnson295189b2012-06-20 16:38:30 -070014441 &pSession->joinRetryTimerInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014442 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014443 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014444 smsLog(pMac, LOGE, FL("cannot allocate memory for joinretry timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014445 break;
14446 }
14447#endif
Kiran Kumar Lokere0ad5cd32013-06-25 11:26:22 -070014448 status = csrIssueAddStaForSessionReq (pMac, i, pSelfMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070014449 break;
14450 }
14451 }
14452 if( CSR_ROAM_SESSION_MAX == i )
14453 {
14454 //No session is available
14455 status = eHAL_STATUS_RESOURCES;
14456 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014457 return ( status );
14458}
Jeff Johnson295189b2012-06-20 16:38:30 -070014459eHalStatus csrProcessDelStaSessionRsp( tpAniSirGlobal pMac, tANI_U8 *pMsg)
14460{
14461 eHalStatus status = eHAL_STATUS_SUCCESS;
14462 tListElem *pEntry = NULL;
14463 tSmeCmd *pCommand = NULL;
14464 tSirSmeDelStaSelfRsp *pRsp;
Jeff Johnson295189b2012-06-20 16:38:30 -070014465 do
14466 {
14467 if(pMsg == NULL)
14468 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014469 smsLog(pMac, LOGE, "in %s msg ptr is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014470 status = eHAL_STATUS_FAILURE;
14471 break;
14472 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014473 pEntry = csrLLPeekHead( &pMac->sme.smeCmdActiveList, LL_ACCESS_LOCK );
14474 if(pEntry)
14475 {
14476 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14477 if(eSmeCommandDelStaSession == pCommand->command)
14478 {
14479 tANI_U8 sessionId = pCommand->sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070014480 pRsp = (tSirSmeDelStaSelfRsp*)pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014481 smsLog( pMac, LOG1, "Del Sta rsp status = %d", pRsp->status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014482 //This session is done.
14483 csrCleanupSession(pMac, sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -070014484 if(pCommand->u.delStaSessionCmd.callback)
14485 {
14486
14487 status = sme_ReleaseGlobalLock( &pMac->sme );
14488 if ( HAL_STATUS_SUCCESS( status ) )
14489 {
14490 pCommand->u.delStaSessionCmd.callback(
14491 pCommand->u.delStaSessionCmd.pContext);
14492 status = sme_AcquireGlobalLock( &pMac->sme );
14493 if (! HAL_STATUS_SUCCESS( status ) )
14494 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014495 smsLog(pMac, LOGP, "%s: Failed to Acquire Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014496 return status;
14497 }
14498 }
14499 else {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014500 smsLog(pMac, LOGE, "%s: Failed to Release Lock", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014501 }
14502 }
14503
14504 //Remove this command out of the active list
14505 if(csrLLRemoveEntry(&pMac->sme.smeCmdActiveList, pEntry, LL_ACCESS_LOCK))
14506 {
14507 //Now put this command back on the avilable command list
14508 csrReleaseCommand(pMac, pCommand);
14509 }
14510 smeProcessPendingQueue( pMac );
14511 }
14512 else
14513 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014514 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 -070014515 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014516 status = eHAL_STATUS_FAILURE;
14517 break;
14518 }
14519 }
14520 else
14521 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014522 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 -070014523 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -070014524 status = eHAL_STATUS_FAILURE;
14525 break;
14526 }
14527 } while(0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014528 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014529}
Jeff Johnson295189b2012-06-20 16:38:30 -070014530eHalStatus csrSendMBDelSelfStaReqMsg( tpAniSirGlobal pMac, tSirMacAddr macAddr )
14531{
14532 tSirSmeDelStaSelfReq *pMsg;
14533 tANI_U16 msgLen;
14534 eHalStatus status = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070014535 do {
Jeff Johnson295189b2012-06-20 16:38:30 -070014536 msgLen = sizeof( tANI_U16 ) + sizeof( tANI_U16 ) + sizeof( tSirMacAddr ) /*+
14537 sizeof( tSirBssType )*/;
Kiet Lam64c1b492013-07-12 13:56:44 +053014538 pMsg = vos_mem_malloc(msgLen);
14539 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
14540 vos_mem_set(pMsg, msgLen, 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070014541 pMsg->mesgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_DEL_STA_SELF_REQ);
14542 pMsg->mesgLen = pal_cpu_to_be16(msgLen);
Jeff Johnson295189b2012-06-20 16:38:30 -070014543 // self station address
Kiet Lam64c1b492013-07-12 13:56:44 +053014544 vos_mem_copy((tANI_U8 *)pMsg->selfMacAddr, (tANI_U8 *)macAddr,
14545 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070014546 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070014547 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070014548 return( status );
14549}
Jeff Johnson295189b2012-06-20 16:38:30 -070014550eHalStatus csrIssueDelStaForSessionReq(tpAniSirGlobal pMac, tANI_U32 sessionId,
14551 tSirMacAddr sessionMacAddr,
14552 csrRoamSessionCloseCallback callback,
14553 void *pContext)
14554{
14555 eHalStatus status = eHAL_STATUS_SUCCESS;
14556 tSmeCmd *pCommand;
Jeff Johnson295189b2012-06-20 16:38:30 -070014557 pCommand = csrGetCommandBuffer(pMac);
14558 if(NULL == pCommand)
14559 {
14560 status = eHAL_STATUS_RESOURCES;
14561 }
14562 else
14563 {
14564 pCommand->command = eSmeCommandDelStaSession;
14565 pCommand->sessionId = (tANI_U8)sessionId;
14566 pCommand->u.delStaSessionCmd.callback = callback;
14567 pCommand->u.delStaSessionCmd.pContext = pContext;
Kiet Lam64c1b492013-07-12 13:56:44 +053014568 vos_mem_copy(pCommand->u.delStaSessionCmd.selfMacAddr, sessionMacAddr,
14569 sizeof( tSirMacAddr ));
Jeff Johnson295189b2012-06-20 16:38:30 -070014570 status = csrQueueSmeCommand(pMac, pCommand, TRUE);
14571 if( !HAL_STATUS_SUCCESS( status ) )
14572 {
14573 //Should be panic??
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014574 smsLog( pMac, LOGE, FL(" fail to send message status = %d"), status );
Jeff Johnson295189b2012-06-20 16:38:30 -070014575 }
14576 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014577 return (status);
14578}
Jeff Johnson295189b2012-06-20 16:38:30 -070014579eHalStatus csrProcessDelStaSessionCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand )
14580{
14581 return csrSendMBDelSelfStaReqMsg( pMac,
14582 pCommand->u.delStaSessionCmd.selfMacAddr );
14583}
Jeff Johnson295189b2012-06-20 16:38:30 -070014584static void purgeCsrSessionCmdList(tpAniSirGlobal pMac, tANI_U32 sessionId)
14585{
14586 tDblLinkList *pList = &pMac->roam.roamCmdPendingList;
14587 tListElem *pEntry, *pNext;
14588 tSmeCmd *pCommand;
14589 tDblLinkList localList;
14590
14591 vos_mem_zero(&localList, sizeof(tDblLinkList));
14592 if(!HAL_STATUS_SUCCESS(csrLLOpen(pMac->hHdd, &localList)))
14593 {
14594 smsLog(pMac, LOGE, FL(" failed to open list"));
14595 return;
14596 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014597 csrLLLock(pList);
14598 pEntry = csrLLPeekHead(pList, LL_ACCESS_NOLOCK);
14599 while(pEntry != NULL)
14600 {
14601 pNext = csrLLNext(pList, pEntry, LL_ACCESS_NOLOCK);
14602 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14603 if(pCommand->sessionId == sessionId)
14604 {
14605 if(csrLLRemoveEntry(pList, pEntry, LL_ACCESS_NOLOCK))
14606 {
14607 csrLLInsertTail(&localList, pEntry, LL_ACCESS_NOLOCK);
14608 }
14609 }
14610 pEntry = pNext;
14611 }
14612 csrLLUnlock(pList);
14613
14614 while( (pEntry = csrLLRemoveHead(&localList, LL_ACCESS_NOLOCK)) )
14615 {
14616 pCommand = GET_BASE_ADDR( pEntry, tSmeCmd, Link );
14617 csrAbortCommand(pMac, pCommand, eANI_BOOLEAN_TRUE);
14618 }
14619 csrLLClose(&localList);
14620}
14621
Jeff Johnson295189b2012-06-20 16:38:30 -070014622void csrCleanupSession(tpAniSirGlobal pMac, tANI_U32 sessionId)
14623{
14624 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14625 {
14626 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070014627 csrRoamStop(pMac, sessionId);
14628 csrFreeConnectBssDesc(pMac, sessionId);
14629 csrRoamFreeConnectProfile( pMac, &pSession->connectedProfile );
14630 csrRoamFreeConnectedInfo ( pMac, &pSession->connectedInfo);
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014631 vos_timer_destroy(&pSession->hTimerRoaming);
Jeff Johnson295189b2012-06-20 16:38:30 -070014632#ifdef FEATURE_WLAN_BTAMP_UT_RF
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014633 vos_timer_destroy(&pSession->hTimerJoinRetry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014634#endif
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014635 purgeSmeSessionCmdList(pMac, sessionId, &pMac->sme.smeCmdPendingList);
14636 if (pMac->fScanOffload)
14637 {
14638 purgeSmeSessionCmdList(pMac, sessionId,
14639 &pMac->sme.smeScanCmdPendingList);
14640 }
14641
Jeff Johnson295189b2012-06-20 16:38:30 -070014642 purgeCsrSessionCmdList(pMac, sessionId);
14643 csrInitSession(pMac, sessionId);
14644 }
14645}
14646
Jeff Johnson295189b2012-06-20 16:38:30 -070014647eHalStatus csrRoamCloseSession( tpAniSirGlobal pMac, tANI_U32 sessionId,
14648 tANI_BOOLEAN fSync,
14649 csrRoamSessionCloseCallback callback,
14650 void *pContext )
14651{
14652 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson295189b2012-06-20 16:38:30 -070014653 if( CSR_IS_SESSION_VALID( pMac, sessionId ) )
14654 {
14655 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
14656 if(fSync)
14657 {
14658 csrCleanupSession(pMac, sessionId);
14659 }
14660 else
14661 {
Madan Mohan Koyyalamudi21255992013-08-01 18:00:25 +053014662 purgeSmeSessionCmdList(pMac, sessionId,
14663 &pMac->sme.smeCmdPendingList);
14664 if (pMac->fScanOffload)
14665 {
14666 purgeSmeSessionCmdList(pMac, sessionId,
14667 &pMac->sme.smeScanCmdPendingList);
14668 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014669 purgeCsrSessionCmdList(pMac, sessionId);
14670 status = csrIssueDelStaForSessionReq( pMac, sessionId,
14671 pSession->selfMacAddr, callback, pContext);
14672 }
14673 }
14674 else
14675 {
14676 status = eHAL_STATUS_INVALID_PARAMETER;
14677 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014678 return ( status );
14679}
14680
Jeff Johnson295189b2012-06-20 16:38:30 -070014681static void csrInitSession( tpAniSirGlobal pMac, tANI_U32 sessionId )
14682{
14683 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014684
14685 if(!pSession)
14686 {
14687 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14688 return;
14689 }
14690
Jeff Johnson295189b2012-06-20 16:38:30 -070014691 pSession->sessionActive = eANI_BOOLEAN_FALSE;
14692 pSession->sessionId = CSR_SESSION_ID_INVALID;
14693 pSession->callback = NULL;
14694 pSession->pContext = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070014695 pSession->connectState = eCSR_ASSOC_STATE_TYPE_NOT_CONNECTED;
14696 // TODO : Confirm pMac->roam.fReadyForPowerSave = eANI_BOOLEAN_FALSE;
14697 csrFreeRoamProfile( pMac, sessionId );
14698 csrRoamFreeConnectProfile(pMac, &pSession->connectedProfile);
14699 csrRoamFreeConnectedInfo( pMac, &pSession->connectedInfo );
14700 csrFreeConnectBssDesc(pMac, sessionId);
14701 csrScanEnable(pMac);
Kiet Lam64c1b492013-07-12 13:56:44 +053014702 vos_mem_set(&pSession->selfMacAddr, sizeof(tCsrBssid), 0);
14703 if (pSession->pWpaRsnReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014704 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014705 vos_mem_free(pSession->pWpaRsnReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014706 pSession->pWpaRsnReqIE = NULL;
14707 }
14708 pSession->nWpaRsnReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014709 if (pSession->pWpaRsnRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014710 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014711 vos_mem_free(pSession->pWpaRsnRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014712 pSession->pWpaRsnRspIE = NULL;
14713 }
14714 pSession->nWpaRsnRspIeLength = 0;
14715#ifdef FEATURE_WLAN_WAPI
Kiet Lam64c1b492013-07-12 13:56:44 +053014716 if (pSession->pWapiReqIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014717 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014718 vos_mem_free(pSession->pWapiReqIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014719 pSession->pWapiReqIE = NULL;
14720 }
14721 pSession->nWapiReqIeLength = 0;
Kiet Lam64c1b492013-07-12 13:56:44 +053014722 if (pSession->pWapiRspIE)
Jeff Johnson295189b2012-06-20 16:38:30 -070014723 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014724 vos_mem_free(pSession->pWapiRspIE);
Jeff Johnson295189b2012-06-20 16:38:30 -070014725 pSession->pWapiRspIE = NULL;
14726 }
14727 pSession->nWapiRspIeLength = 0;
14728#endif /* FEATURE_WLAN_WAPI */
Agarwal Ashish4f616132013-12-30 23:32:50 +053014729 if (pSession->nAddIEScanLength)
Jeff Johnson295189b2012-06-20 16:38:30 -070014730 {
Agarwal Ashish4f616132013-12-30 23:32:50 +053014731 memset(pSession->addIEScan, 0 , SIR_MAC_MAX_IE_LENGTH);
Jeff Johnson295189b2012-06-20 16:38:30 -070014732 }
14733 pSession->nAddIEScanLength = 0;
Agarwal Ashish4f616132013-12-30 23:32:50 +053014734
Kiet Lam64c1b492013-07-12 13:56:44 +053014735 if (pSession->pAddIEAssoc)
Jeff Johnson295189b2012-06-20 16:38:30 -070014736 {
Kiet Lam64c1b492013-07-12 13:56:44 +053014737 vos_mem_free(pSession->pAddIEAssoc);
Jeff Johnson295189b2012-06-20 16:38:30 -070014738 pSession->pAddIEAssoc = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053014739 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014740 pSession->nAddIEAssocLength = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014741}
14742
Jeff Johnson295189b2012-06-20 16:38:30 -070014743eHalStatus csrRoamGetSessionIdFromBSSID( tpAniSirGlobal pMac, tCsrBssid *bssid, tANI_U32 *pSessionId )
14744{
14745 eHalStatus status = eHAL_STATUS_FAILURE;
14746 tANI_U32 i;
Jeff Johnson295189b2012-06-20 16:38:30 -070014747 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14748 {
14749 if( CSR_IS_SESSION_VALID( pMac, i ) )
14750 {
14751 if( csrIsMacAddressEqual( pMac, bssid, &pMac->roam.roamSession[i].connectedProfile.bssid ) )
14752 {
14753 //Found it
14754 status = eHAL_STATUS_SUCCESS;
14755 *pSessionId = i;
14756 break;
14757 }
14758 }
14759 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014760 return( status );
14761}
14762
Jeff Johnson295189b2012-06-20 16:38:30 -070014763//This function assumes that we only support one IBSS session. We cannot use BSSID to identify
14764//session because for IBSS, the bssid changes.
14765static tANI_U32 csrFindIbssSession( tpAniSirGlobal pMac )
14766{
14767 tANI_U32 i, nRet = CSR_SESSION_ID_INVALID;
14768 tCsrRoamSession *pSession;
Jeff Johnson295189b2012-06-20 16:38:30 -070014769 for( i = 0; i < CSR_ROAM_SESSION_MAX; i++ )
14770 {
14771 if( CSR_IS_SESSION_VALID( pMac, i ) )
14772 {
14773 pSession = CSR_GET_SESSION( pMac, i );
14774 if( pSession->pCurRoamProfile && ( csrIsBssTypeIBSS( pSession->connectedProfile.BSSType ) ) )
14775 {
14776 //Found it
14777 nRet = i;
14778 break;
14779 }
14780 }
14781 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014782 return (nRet);
14783}
Jeff Johnson295189b2012-06-20 16:38:30 -070014784static void csrRoamLinkUp(tpAniSirGlobal pMac, tCsrBssid bssid)
14785{
Mukul Sharma20aa6582014-08-07 21:36:12 +053014786 VOS_STATUS status = VOS_STATUS_SUCCESS;
14787
14788 /* Update the current BSS info in ho control block based on connected
Jeff Johnson295189b2012-06-20 16:38:30 -070014789 profile info from pmac global structure */
14790
Arif Hussain24bafea2013-11-15 15:10:03 -080014791 smsLog(pMac, LOGW, " csrRoamLinkUp: WLAN link UP with AP= "MAC_ADDRESS_STR,
14792 MAC_ADDR_ARRAY(bssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070014793 /* Check for user misconfig of RSSI trigger threshold */
14794 pMac->roam.configParam.vccRssiThreshold =
14795 ( 0 == pMac->roam.configParam.vccRssiThreshold ) ?
14796 CSR_VCC_RSSI_THRESHOLD : pMac->roam.configParam.vccRssiThreshold;
14797 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
Jeff Johnson295189b2012-06-20 16:38:30 -070014798 /* Check for user misconfig of UL MAC Loss trigger threshold */
14799 pMac->roam.configParam.vccUlMacLossThreshold =
14800 ( 0 == pMac->roam.configParam.vccUlMacLossThreshold ) ?
14801 CSR_VCC_UL_MAC_LOSS_THRESHOLD : pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070014802#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14803 {
14804 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070014805 /* Indicate the neighbor roal algorithm about the connect indication */
14806 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssid, &sessionId);
14807 csrNeighborRoamIndicateConnect(pMac, sessionId, VOS_STATUS_SUCCESS);
Mukul Sharma20aa6582014-08-07 21:36:12 +053014808
14809 // Making sure we are roaming force fully to 5GHz AP only once and
14810 // only when we connected to 2.4GH AP only during initial association.
14811 if(pMac->roam.neighborRoamInfo.cfgParams.neighborInitialForcedRoamTo5GhEnable &&
14812 GetRFBand(pMac->roam.neighborRoamInfo.currAPoperationChannel) == SIR_BAND_2_4_GHZ)
14813 {
14814 //Making ini value to false here only so we just roam to
14815 //only once for whole driver load to unload tenure
14816 pMac->roam.neighborRoamInfo.cfgParams.neighborInitialForcedRoamTo5GhEnable = VOS_FALSE;
14817
14818 status = vos_timer_start(&pMac->roam.neighborRoamInfo.forcedInitialRoamTo5GHTimer,
14819 INITIAL_FORCED_ROAM_TO_5G_TIMER_PERIOD);
14820 //MUKUL TODO: change the neighborResultsRefreshPeriod to some ini value reuqired ??
14821 if ( status != VOS_STATUS_SUCCESS )
14822 {
14823 smsLog(pMac, LOGE, FL("%s Neighbor forcedInitialRoamTo5GHTimer start failed with status %d"), __func__, status);
14824 }
14825 smsLog(pMac, LOGE, FL("%s: Forced roam to 5G started Timer"), __func__);
14826 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014827 }
14828#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070014829}
14830
Jeff Johnson295189b2012-06-20 16:38:30 -070014831static void csrRoamLinkDown(tpAniSirGlobal pMac, tANI_U32 sessionId)
14832{
14833 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson32d95a32012-09-10 13:15:23 -070014834
14835 if(!pSession)
14836 {
14837 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
14838 return;
14839 }
14840
Jeff Johnson295189b2012-06-20 16:38:30 -070014841 //Only to handle the case for Handover on infra link
14842 if( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
14843 {
14844 return;
14845 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014846 /* deregister the clients requesting stats from PE/TL & also stop the corresponding timers*/
14847 csrRoamDeregStatisticsReq(pMac);
14848 pMac->roam.vccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
14849#if defined WLAN_FEATURE_NEIGHBOR_ROAMING
14850 /* Indicate the neighbor roal algorithm about the disconnect indication */
14851 csrNeighborRoamIndicateDisconnect(pMac, sessionId);
14852#endif
Madan Mohan Koyyalamudi96dd30d2012-10-05 17:24:51 -070014853
14854 //Remove this code once SLM_Sessionization is supported
14855 //BMPS_WORKAROUND_NOT_NEEDED
14856 if(!IS_FEATURE_SUPPORTED_BY_FW(SLM_SESSIONIZATION) &&
Mohit Khanna349bc392012-09-11 17:24:52 -070014857 csrIsInfraApStarted( pMac ) &&
14858 pMac->roam.configParam.doBMPSWorkaround)
Jeff Johnsone7245742012-09-05 17:12:55 -070014859 {
14860 pMac->roam.configParam.doBMPSWorkaround = 0;
14861 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014862}
14863
Jeff Johnson295189b2012-06-20 16:38:30 -070014864void csrRoamTlStatsTimerHandler(void *pv)
14865{
14866 tpAniSirGlobal pMac = PMAC_STRUCT( pv );
14867 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070014868 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
14869
Jeff Johnsone7245742012-09-05 17:12:55 -070014870 smsLog(pMac, LOG1, FL(" TL stat timer is no-op. It needs to support multiple stations"));
14871
Jeff Johnson295189b2012-06-20 16:38:30 -070014872#if 0
14873 // TODO Persession .???
14874 //req TL for stats
14875 if(WLANTL_GetStatistics(pMac->roam.gVosContext, &tlStats, pMac->roam.connectedInfo.staId))
14876 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014877 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:couldn't get the stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014878 }
14879 else
14880 {
14881 //save in SME
14882 csrRoamSaveStatsFromTl(pMac, tlStats);
14883 }
14884#endif
14885 if(!pMac->roam.tlStatsReqInfo.timerRunning)
14886 {
14887 if(pMac->roam.tlStatsReqInfo.periodicity)
14888 {
14889 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014890 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
14891 pMac->roam.tlStatsReqInfo.periodicity);
14892 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070014893 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014894 smsLog(pMac, LOGE, FL("csrRoamTlStatsTimerHandler:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014895 return;
14896 }
14897 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
14898 }
14899 }
14900}
Jeff Johnson295189b2012-06-20 16:38:30 -070014901void csrRoamPeStatsTimerHandler(void *pv)
14902{
14903 tCsrPeStatsReqInfo *pPeStatsReqListEntry = (tCsrPeStatsReqInfo *)pv;
14904 eHalStatus status;
14905 tpAniSirGlobal pMac = pPeStatsReqListEntry->pMac;
14906 VOS_STATUS vosStatus;
14907 tPmcPowerState powerState;
Jeff Johnson295189b2012-06-20 16:38:30 -070014908 pPeStatsReqListEntry->timerRunning = FALSE;
14909 if( pPeStatsReqListEntry->timerStopFailed == TRUE )
14910 {
14911 // If we entered here, meaning the timer could not be successfully
14912 // stopped in csrRoamRemoveEntryFromPeStatsReqList(). So do it here.
14913
14914 /* Destroy the timer */
14915 vosStatus = vos_timer_destroy( &pPeStatsReqListEntry->hPeStatsTimer );
14916 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14917 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014918 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014919 }
14920
14921 // Free the entry
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053014922 vos_mem_free(pPeStatsReqListEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070014923 pPeStatsReqListEntry = NULL;
14924 }
14925 else
14926 {
14927 if(!pPeStatsReqListEntry->rspPending)
14928 {
14929 status = csrSendMBStatsReqMsg(pMac, pPeStatsReqListEntry->statsMask & ~(1 << eCsrGlobalClassDStats),
14930 pPeStatsReqListEntry->staId);
14931 if(!HAL_STATUS_SUCCESS(status))
14932 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014933 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014934 }
14935 else
14936 {
14937 pPeStatsReqListEntry->rspPending = TRUE;
14938 }
14939 }
14940
14941 //send down a req
14942 if(pPeStatsReqListEntry->periodicity &&
14943 (VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pPeStatsReqListEntry->hPeStatsTimer)))
14944 {
14945 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
14946 if(ePMC_FULL_POWER == powerState)
14947 {
14948 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
14949 {
14950 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
14951 }
14952 }
14953 else
14954 {
14955 if(pPeStatsReqListEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
14956 {
14957 pPeStatsReqListEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
14958 }
14959 }
14960 //start timer
14961 vosStatus = vos_timer_start( &pPeStatsReqListEntry->hPeStatsTimer, pPeStatsReqListEntry->periodicity );
14962 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14963 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014964 smsLog(pMac, LOGE, FL("csrRoamPeStatsTimerHandler:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014965 return;
14966 }
Jeff Johnson295189b2012-06-20 16:38:30 -070014967 pPeStatsReqListEntry->timerRunning = TRUE;
14968
14969 }
14970
14971 }
14972}
Jeff Johnson295189b2012-06-20 16:38:30 -070014973void csrRoamStatsClientTimerHandler(void *pv)
14974{
14975 tCsrStatsClientReqInfo *pStaEntry = (tCsrStatsClientReqInfo *)pv;
Jeff Johnson295189b2012-06-20 16:38:30 -070014976 if(VOS_TIMER_STATE_STOPPED == vos_timer_getCurrentState(&pStaEntry->timer))
14977 {
14978#if 0
14979 // TODO Stats fix for multisession
14980 //start the timer
14981 vosStatus = vos_timer_start( &pStaEntry->timer, pStaEntry->periodicity );
14982
14983 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
14984 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080014985 smsLog(pStaEntry->pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070014986 }
14987#endif
14988 }
14989#if 0
14990 //send up the stats report
14991 csrRoamReportStatistics(pStaEntry->pMac, pStaEntry->statsMask, pStaEntry->callback,
14992 pStaEntry->staId, pStaEntry->pContext);
14993#endif
14994}
14995
14996
14997
Jeff Johnson295189b2012-06-20 16:38:30 -070014998eHalStatus csrSendMBStatsReqMsg( tpAniSirGlobal pMac, tANI_U32 statsMask, tANI_U8 staId)
14999{
15000 tAniGetPEStatsReq *pMsg;
15001 eHalStatus status = eHAL_STATUS_SUCCESS;
Kiet Lam64c1b492013-07-12 13:56:44 +053015002 pMsg = vos_mem_malloc(sizeof(tAniGetPEStatsReq));
15003 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015004 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015005 smsLog(pMac, LOGE, FL( "Failed to allocate mem for stats req "));
Kiet Lam64c1b492013-07-12 13:56:44 +053015006 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015007 }
15008 // need to initiate a stats request to PE
15009 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_STATISTICS_REQ);
15010 pMsg->msgLen = (tANI_U16)sizeof(tAniGetPEStatsReq);
15011 pMsg->staId = staId;
15012 pMsg->statsMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070015013 status = palSendMBMessage(pMac->hHdd, pMsg );
Jeff Johnson295189b2012-06-20 16:38:30 -070015014 if(!HAL_STATUS_SUCCESS(status))
15015 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015016 smsLog(pMac, LOG1, FL("Failed to send down the stats req "));
Jeff Johnson295189b2012-06-20 16:38:30 -070015017 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015018 return status;
15019}
Jeff Johnson295189b2012-06-20 16:38:30 -070015020void csrRoamStatsRspProcessor(tpAniSirGlobal pMac, tSirSmeRsp *pSirMsg)
15021{
15022 tAniGetPEStatsRsp *pSmeStatsRsp;
15023 eHalStatus status = eHAL_STATUS_FAILURE;
15024 tListElem *pEntry = NULL;
15025 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
15026 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15027 tANI_U32 tempMask = 0;
15028 tANI_U8 counter = 0;
15029 tANI_U8 *pStats = NULL;
15030 tANI_U32 length = 0;
15031 v_PVOID_t pvosGCtx;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015032 v_S7_t rssi = 0, snr = 0;
15033 tANI_U32 *pRssi = NULL, *pSnr = NULL;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015034 tANI_U32 linkCapacity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015035 pSmeStatsRsp = (tAniGetPEStatsRsp *)pSirMsg;
15036 if(pSmeStatsRsp->rc)
15037 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015038 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:stats rsp from PE shows failure"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015039 goto post_update;
15040 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015041 tempMask = pSmeStatsRsp->statsMask;
15042 pStats = ((tANI_U8 *)&pSmeStatsRsp->statsMask) + sizeof(pSmeStatsRsp->statsMask);
Jeff Johnson295189b2012-06-20 16:38:30 -070015043 /* subtract all statistics from this length, and after processing the entire
15044 * 'stat' part of the message, if the length is not zero, then rssi is piggy packed
15045 * in this 'stats' message.
15046 */
15047 length = pSmeStatsRsp->msgLen - sizeof(tAniGetPEStatsRsp);
Jeff Johnson295189b2012-06-20 16:38:30 -070015048 //new stats info from PE, fill up the stats strucutres in PMAC
15049 while(tempMask)
15050 {
15051 if(tempMask & 1)
15052 {
15053 switch(counter)
15054 {
15055 case eCsrSummaryStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015056 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015057 vos_mem_copy((tANI_U8 *)&pMac->roam.summaryStatsInfo,
15058 pStats, sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015059 pStats += sizeof(tCsrSummaryStatsInfo);
15060 length -= sizeof(tCsrSummaryStatsInfo);
15061 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015062 case eCsrGlobalClassAStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015063 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015064 vos_mem_copy((tANI_U8 *)&pMac->roam.classAStatsInfo,
15065 pStats, sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015066 pStats += sizeof(tCsrGlobalClassAStatsInfo);
15067 length -= sizeof(tCsrGlobalClassAStatsInfo);
15068 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015069 case eCsrGlobalClassBStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015070 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015071 vos_mem_copy((tANI_U8 *)&pMac->roam.classBStatsInfo,
15072 pStats, sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015073 pStats += sizeof(tCsrGlobalClassBStatsInfo);
15074 length -= sizeof(tCsrGlobalClassBStatsInfo);
15075 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015076 case eCsrGlobalClassCStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015077 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015078 vos_mem_copy((tANI_U8 *)&pMac->roam.classCStatsInfo,
15079 pStats, sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015080 pStats += sizeof(tCsrGlobalClassCStatsInfo);
15081 length -= sizeof(tCsrGlobalClassCStatsInfo);
15082 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015083 case eCsrPerStaStats:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015084 smsLog( pMac, LOG2, FL("csrRoamStatsRspProcessor:PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015085 if( CSR_MAX_STA > pSmeStatsRsp->staId )
15086 {
Kiet Lam64c1b492013-07-12 13:56:44 +053015087 vos_mem_copy((tANI_U8 *)&pMac->roam.perStaStatsInfo[pSmeStatsRsp->staId],
15088 pStats, sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070015089 }
15090 else
15091 {
15092 status = eHAL_STATUS_FAILURE;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015093 smsLog( pMac, LOGE, FL("csrRoamStatsRspProcessor:out bound staId:%d"), pSmeStatsRsp->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -070015094 VOS_ASSERT( 0 );
15095 }
15096 if(!HAL_STATUS_SUCCESS(status))
15097 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015098 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:failed to copy PerSta stats"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015099 }
15100 pStats += sizeof(tCsrPerStaStatsInfo);
15101 length -= sizeof(tCsrPerStaStatsInfo);
15102 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015103 default:
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015104 smsLog( pMac, LOGW, FL("csrRoamStatsRspProcessor:unknown stats type"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015105 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070015106 }
15107 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015108 tempMask >>=1;
15109 counter++;
15110 }
15111 pvosGCtx = vos_get_global_context(VOS_MODULE_ID_SME, pMac);
15112 if (length != 0)
15113 {
15114 pRssi = (tANI_U32*)pStats;
15115 rssi = (v_S7_t)*pRssi;
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015116 pStats += sizeof(tANI_U32);
15117 length -= sizeof(tANI_U32);
Jeff Johnson295189b2012-06-20 16:38:30 -070015118 }
15119 else
15120 {
15121 /* If riva is not sending rssi, continue to use the hack */
15122 rssi = RSSI_HACK_BMPS;
15123 }
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015124
Jeff Johnson295189b2012-06-20 16:38:30 -070015125 WDA_UpdateRssiBmps(pvosGCtx, pSmeStatsRsp->staId, rssi);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015126
15127 if (length != 0)
15128 {
15129 linkCapacity = *(tANI_U32*)pStats;
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015130 pStats += sizeof(tANI_U32);
15131 length -= sizeof(tANI_U32);
Gopichand Nakkala8a2b1442013-05-29 15:33:14 +053015132 }
15133 else
15134 {
15135 linkCapacity = 0;
15136 }
15137
15138 WDA_UpdateLinkCapacity(pvosGCtx, pSmeStatsRsp->staId, linkCapacity);
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015139
15140 if (length != 0)
15141 {
15142 pSnr = (tANI_U32*)pStats;
15143 snr = (v_S7_t)*pSnr;
15144 }
15145 else
15146 {
15147 snr = SNR_HACK_BMPS;
15148 }
15149
15150 WDA_UpdateSnrBmps(pvosGCtx, pSmeStatsRsp->staId, snr);
Jeff Johnson295189b2012-06-20 16:38:30 -070015151post_update:
15152 //make sure to update the pe stats req list
15153 pEntry = csrRoamFindInPeStatsReqList(pMac, pSmeStatsRsp->statsMask);
15154 if(pEntry)
15155 {
15156 pPeStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
15157 pPeStaEntry->rspPending = FALSE;
15158
15159 }
15160 //check the one timer cases
15161 pEntry = csrRoamCheckClientReqList(pMac, pSmeStatsRsp->statsMask);
15162 if(pEntry)
15163 {
Jeff Johnson295189b2012-06-20 16:38:30 -070015164 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015165 if(pTempStaEntry->timerExpired)
15166 {
15167 //send up the stats report
15168 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
15169 pTempStaEntry->staId, pTempStaEntry->pContext);
15170 //also remove from the client list
15171 csrRoamRemoveStatListEntry(pMac, pEntry);
15172 pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015173 }
15174 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015175}
Jeff Johnson295189b2012-06-20 16:38:30 -070015176tListElem * csrRoamFindInPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15177{
15178 tListElem *pEntry = NULL;
15179 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015180 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015181 if(!pEntry)
15182 {
15183 //list empty
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015184 smsLog(pMac, LOG2, "csrRoamFindInPeStatsReqList: List empty, no request to PE");
Jeff Johnson295189b2012-06-20 16:38:30 -070015185 return NULL;
15186 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015187 while( pEntry )
15188 {
15189 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015190 if(pTempStaEntry->statsMask == statsMask)
15191 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015192 smsLog(pMac, LOG3, "csrRoamFindInPeStatsReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015193 break;
15194 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015195 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
15196 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015197 return pEntry;
15198}
15199
Jeff Johnson295189b2012-06-20 16:38:30 -070015200tListElem * csrRoamChecknUpdateClientReqList(tpAniSirGlobal pMac, tCsrStatsClientReqInfo *pStaEntry,
15201 tANI_BOOLEAN update)
15202{
15203 tListElem *pEntry;
15204 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015205 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015206 if(!pEntry)
15207 {
15208 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015209 smsLog(pMac, LOG2, "csrRoamChecknUpdateClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015210 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015211 return NULL;
15212 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015213 while( pEntry )
15214 {
15215 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015216 if((pTempStaEntry->requesterId == pStaEntry->requesterId) &&
15217 (pTempStaEntry->statsMask == pStaEntry->statsMask))
15218 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015219 smsLog(pMac, LOG3, "csrRoamChecknUpdateClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015220 if(update)
15221 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015222 pTempStaEntry->periodicity = pStaEntry->periodicity;
15223 pTempStaEntry->callback = pStaEntry->callback;
15224 pTempStaEntry->pContext = pStaEntry->pContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015225 }
15226 break;
15227 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015228 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15229 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015230 return pEntry;
15231}
Jeff Johnson295189b2012-06-20 16:38:30 -070015232tListElem * csrRoamCheckClientReqList(tpAniSirGlobal pMac, tANI_U32 statsMask)
15233{
15234 tListElem *pEntry;
15235 tCsrStatsClientReqInfo *pTempStaEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070015236 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015237 if(!pEntry)
15238 {
15239 //list empty
Mohit Khanna23863762012-09-11 17:40:09 -070015240 smsLog(pMac, LOG2, "csrRoamCheckClientReqList: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015241 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070015242 return NULL;
15243 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015244 while( pEntry )
15245 {
15246 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070015247 if((pTempStaEntry->statsMask & ~(1 << eCsrGlobalClassDStats)) == statsMask)
15248 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015249 smsLog(pMac, LOG3, "csrRoamCheckClientReqList: match found");
Jeff Johnson295189b2012-06-20 16:38:30 -070015250 break;
15251 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015252 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
15253 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015254 return pEntry;
15255}
Jeff Johnson295189b2012-06-20 16:38:30 -070015256eHalStatus csrRoamRegisterLinkQualityIndCallback(tpAniSirGlobal pMac,
15257 csrRoamLinkQualityIndCallback callback,
15258 void *pContext)
15259{
15260 pMac->roam.linkQualityIndInfo.callback = callback;
15261 pMac->roam.linkQualityIndInfo.context = pContext;
15262 if( NULL == callback )
15263 {
15264 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being deregistered");
15265 }
15266 else
15267 {
15268 smsLog(pMac, LOGW, "csrRoamRegisterLinkQualityIndCallback: indication callback being registered");
Jeff Johnson295189b2012-06-20 16:38:30 -070015269 /* do we need to invoke the callback to notify client of initial value ?? */
15270 }
15271 return eHAL_STATUS_SUCCESS;
15272}
Jeff Johnson295189b2012-06-20 16:38:30 -070015273void csrRoamVccTrigger(tpAniSirGlobal pMac)
15274{
15275 eCsrRoamLinkQualityInd newVccLinkQuality;
15276 tANI_U32 ul_mac_loss = 0;
15277 tANI_U32 ul_mac_loss_trigger_threshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015278 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15279 /*-------------------------------------------------------------------------
15280 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015281 Check for a change in link quality and notify client if necessary
15282 -------------------------------------------------------------------------*/
15283 ul_mac_loss_trigger_threshold =
15284 pMac->roam.configParam.vccUlMacLossThreshold;
Jeff Johnson295189b2012-06-20 16:38:30 -070015285 VOS_ASSERT( ul_mac_loss_trigger_threshold != 0 );
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015286 smsLog(pMac, LOGW, "csrRoamVccTrigger: UL_MAC_LOSS_THRESHOLD is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015287 ul_mac_loss_trigger_threshold );
Jeff Johnson295189b2012-06-20 16:38:30 -070015288 if(ul_mac_loss_trigger_threshold < ul_mac_loss)
15289 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015290 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is POOR ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015291 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15292 }
15293 else
15294 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015295 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality is GOOD");
Jeff Johnson295189b2012-06-20 16:38:30 -070015296 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15297 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015298 smsLog(pMac, LOGW, "csrRoamVccTrigger: link qual : *** UL_MAC_LOSS %d *** ",
15299 ul_mac_loss);
Jeff Johnson295189b2012-06-20 16:38:30 -070015300 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15301 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015302 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015303 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15304 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015305 smsLog(pMac, LOGW, "csrRoamVccTrigger: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015306 newVccLinkQuality );
15307
15308 /* we now invoke the callback once to notify client of initial value */
15309 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15310 pMac->roam.linkQualityIndInfo.context );
15311 //event: EVENT_WLAN_VCC
15312 }
15313 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015314 pMac->roam.vccLinkQuality = newVccLinkQuality;
15315
Jeff Johnson295189b2012-06-20 16:38:30 -070015316}
Jeff Johnson295189b2012-06-20 16:38:30 -070015317VOS_STATUS csrRoamVccTriggerRssiIndCallback(tHalHandle hHal,
15318 v_U8_t rssiNotification,
15319 void * context)
15320{
15321 tpAniSirGlobal pMac = PMAC_STRUCT( context );
15322 eCsrRoamLinkQualityInd newVccLinkQuality;
15323 // TODO : Session info unavailable
15324 tANI_U32 sessionId = 0;
15325 VOS_STATUS status = VOS_STATUS_SUCCESS;
15326 /*-------------------------------------------------------------------------
15327 Link quality is currently binary based on OBIWAN recommended triggers
Jeff Johnson295189b2012-06-20 16:38:30 -070015328 Check for a change in link quality and notify client if necessary
15329 -------------------------------------------------------------------------*/
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015330 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: RSSI trigger threshold is %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015331 pMac->roam.configParam.vccRssiThreshold);
15332 if(!csrIsConnStateConnectedInfra(pMac, sessionId))
15333 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015334 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: ignoring the indication as we are not connected");
Jeff Johnson295189b2012-06-20 16:38:30 -070015335 return VOS_STATUS_SUCCESS;
15336 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015337 if(WLANTL_HO_THRESHOLD_DOWN == rssiNotification)
15338 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015339 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is POOR");
Jeff Johnson295189b2012-06-20 16:38:30 -070015340 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_POOR_IND;
15341 }
15342 else if(WLANTL_HO_THRESHOLD_UP == rssiNotification)
15343 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015344 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality is GOOD ");
Jeff Johnson295189b2012-06-20 16:38:30 -070015345 newVccLinkQuality = eCSR_ROAM_LINK_QUAL_GOOD_IND;
15346 }
15347 else
15348 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015349 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: unknown rssi notification %d", rssiNotification);
Jeff Johnson295189b2012-06-20 16:38:30 -070015350 //Set to this so the code below won't do anything
15351 newVccLinkQuality = pMac->roam.vccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015352 VOS_ASSERT(0);
15353 }
15354
Jeff Johnson295189b2012-06-20 16:38:30 -070015355 if(newVccLinkQuality != pMac->roam.vccLinkQuality)
15356 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015357 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality changed: trigger necessary");
Jeff Johnson295189b2012-06-20 16:38:30 -070015358 if(NULL != pMac->roam.linkQualityIndInfo.callback)
15359 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015360 smsLog(pMac, LOGW, "csrRoamVccTriggerRssiIndCallback: link quality indication %d",
Jeff Johnson295189b2012-06-20 16:38:30 -070015361 newVccLinkQuality);
Jeff Johnson295189b2012-06-20 16:38:30 -070015362 /* we now invoke the callback once to notify client of initial value */
15363 pMac->roam.linkQualityIndInfo.callback( newVccLinkQuality,
15364 pMac->roam.linkQualityIndInfo.context );
15365 //event: EVENT_WLAN_VCC
15366 }
15367 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015368 pMac->roam.vccLinkQuality = newVccLinkQuality;
Jeff Johnson295189b2012-06-20 16:38:30 -070015369 return status;
15370}
Jeff Johnson295189b2012-06-20 16:38:30 -070015371tCsrStatsClientReqInfo * csrRoamInsertEntryIntoList( tpAniSirGlobal pMac,
15372 tDblLinkList *pStaList,
15373 tCsrStatsClientReqInfo *pStaEntry)
15374{
15375 tCsrStatsClientReqInfo *pNewStaEntry = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015376 //if same entity requested for same set of stats with different periodicity &
15377 // callback update it
15378 if(NULL == csrRoamChecknUpdateClientReqList(pMac, pStaEntry, TRUE))
15379 {
15380
Kiet Lam64c1b492013-07-12 13:56:44 +053015381 pNewStaEntry = vos_mem_malloc(sizeof(tCsrStatsClientReqInfo));
15382 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015383 {
15384 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015385 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015386 return NULL;
15387 }
15388
Jeff Johnson295189b2012-06-20 16:38:30 -070015389 pNewStaEntry->callback = pStaEntry->callback;
15390 pNewStaEntry->pContext = pStaEntry->pContext;
15391 pNewStaEntry->periodicity = pStaEntry->periodicity;
15392 pNewStaEntry->requesterId = pStaEntry->requesterId;
15393 pNewStaEntry->statsMask = pStaEntry->statsMask;
15394 pNewStaEntry->pPeStaEntry = pStaEntry->pPeStaEntry;
15395 pNewStaEntry->pMac = pStaEntry->pMac;
15396 pNewStaEntry->staId = pStaEntry->staId;
15397 pNewStaEntry->timerExpired = pStaEntry->timerExpired;
15398
15399 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
15400 }
15401 return pNewStaEntry;
15402}
15403
Jeff Johnson295189b2012-06-20 16:38:30 -070015404tCsrPeStatsReqInfo * csrRoamInsertEntryIntoPeStatsReqList( tpAniSirGlobal pMac,
15405 tDblLinkList *pStaList,
15406 tCsrPeStatsReqInfo *pStaEntry)
15407{
15408 tCsrPeStatsReqInfo *pNewStaEntry = NULL;
Kiet Lam64c1b492013-07-12 13:56:44 +053015409 pNewStaEntry = vos_mem_malloc(sizeof(tCsrPeStatsReqInfo));
15410 if (NULL == pNewStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015411 {
15412 smsLog(pMac, LOGW, "csrRoamInsertEntryIntoPeStatsReqList: couldn't allocate memory for the "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015413 "entry");
Jeff Johnson295189b2012-06-20 16:38:30 -070015414 return NULL;
15415 }
15416
Jeff Johnson295189b2012-06-20 16:38:30 -070015417 pNewStaEntry->hPeStatsTimer = pStaEntry->hPeStatsTimer;
15418 pNewStaEntry->numClient = pStaEntry->numClient;
15419 pNewStaEntry->periodicity = pStaEntry->periodicity;
15420 pNewStaEntry->statsMask = pStaEntry->statsMask;
15421 pNewStaEntry->pMac = pStaEntry->pMac;
15422 pNewStaEntry->staId = pStaEntry->staId;
15423 pNewStaEntry->timerRunning = pStaEntry->timerRunning;
15424 pNewStaEntry->rspPending = pStaEntry->rspPending;
15425
15426 csrLLInsertTail( pStaList, &pNewStaEntry->link, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070015427 return pNewStaEntry;
15428}
Jeff Johnson295189b2012-06-20 16:38:30 -070015429eHalStatus csrGetRssi(tpAniSirGlobal pMac,
15430 tCsrRssiCallback callback,
15431 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15432{
15433 eHalStatus status = eHAL_STATUS_SUCCESS;
15434 vos_msg_t msg;
15435 tANI_U32 sessionId;
15436
15437 tAniGetRssiReq *pMsg;
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015438 smsLog(pMac, LOG2, FL("called"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015439 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15440 if ( NULL == pMsg )
Jeff Johnson295189b2012-06-20 16:38:30 -070015441 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015442 smsLog(pMac, LOGE, " csrGetRssi: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015443 return eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015444 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015445 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15446
15447 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_RSSI_REQ);
15448 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15449 pMsg->sessionId = sessionId;
15450 pMsg->staId = staId;
15451 pMsg->rssiCallback = callback;
15452 pMsg->pDevContext = pContext;
15453 pMsg->pVosContext = pVosContext;
Jeff Johnson295189b2012-06-20 16:38:30 -070015454 msg.type = eWNI_SME_GET_RSSI_REQ;
15455 msg.bodyptr = pMsg;
15456 msg.reserved = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070015457 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15458 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015459 smsLog(pMac, LOGE, " csrGetRssi failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053015460 vos_mem_free((void *)pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070015461 status = eHAL_STATUS_FAILURE;
15462 }
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015463 smsLog(pMac, LOG2, FL("returned"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015464 return status;
15465}
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015466
Madan Mohan Koyyalamudid9383fd2013-08-13 09:27:30 +053015467eHalStatus csrGetSnr(tpAniSirGlobal pMac,
15468 tCsrSnrCallback callback,
15469 tANI_U8 staId, tCsrBssid bssId,
15470 void *pContext)
15471{
15472 eHalStatus status = eHAL_STATUS_SUCCESS;
15473 vos_msg_t msg;
15474 tANI_U32 sessionId;
15475
15476 tAniGetSnrReq *pMsg;
15477
15478 smsLog(pMac, LOG2, FL("called"));
15479
15480 pMsg =(tAniGetSnrReq *)vos_mem_malloc(sizeof(tAniGetSnrReq));
15481 if (NULL == pMsg )
15482 {
15483 smsLog(pMac, LOGE, "%s: failed to allocate mem for req",__func__);
15484 return status;
15485 }
15486
15487 csrRoamGetSessionIdFromBSSID(pMac, (tCsrBssid *)bssId, &sessionId);
15488
15489 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_SNR_REQ);
15490 pMsg->msgLen = (tANI_U16)sizeof(tAniGetSnrReq);
15491 pMsg->sessionId = sessionId;
15492 pMsg->staId = staId;
15493 pMsg->snrCallback = callback;
15494 pMsg->pDevContext = pContext;
15495 msg.type = eWNI_SME_GET_SNR_REQ;
15496 msg.bodyptr = pMsg;
15497 msg.reserved = 0;
15498
15499 if (VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
15500 {
15501 smsLog(pMac, LOGE, "%s failed to post msg to self", __func__);
15502 vos_mem_free((v_VOID_t *)pMsg);
15503 status = eHAL_STATUS_FAILURE;
15504 }
15505
15506 smsLog(pMac, LOG2, FL("returned"));
15507 return status;
15508}
15509
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015510#if defined WLAN_FEATURE_VOWIFI_11R || defined FEATURE_WLAN_ESE || defined(FEATURE_WLAN_LFR)
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015511eHalStatus csrGetRoamRssi(tpAniSirGlobal pMac,
15512 tCsrRssiCallback callback,
15513 tANI_U8 staId, tCsrBssid bssId, void *pContext, void* pVosContext)
15514{
15515 eHalStatus status = eHAL_STATUS_SUCCESS;
15516 tAniGetRssiReq *pMsg;
15517
Kiet Lam64c1b492013-07-12 13:56:44 +053015518 pMsg = vos_mem_malloc(sizeof(tAniGetRssiReq));
15519 if ( NULL == pMsg )
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015520 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015521 smsLog(pMac, LOGE, FL("Failed to allocate mem for req"));
Kiet Lam64c1b492013-07-12 13:56:44 +053015522 return eHAL_STATUS_FAILURE;
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015523 }
15524 // need to initiate a stats request to PE
15525 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_ROAM_RSSI_REQ);
15526 pMsg->msgLen = (tANI_U16)sizeof(tAniGetRssiReq);
15527 pMsg->staId = staId;
15528 pMsg->rssiCallback = callback;
15529 pMsg->pDevContext = pContext;
15530 pMsg->pVosContext = pVosContext;
15531 status = palSendMBMessage(pMac->hHdd, pMsg );
15532 if(!HAL_STATUS_SUCCESS(status))
15533 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053015534 smsLog(pMac, LOGE, FL(" Failed to send down get rssi req"));
Tushnim Bhattacharyya41f72862013-04-03 21:34:01 -070015535 //pMsg is freed by palSendMBMessage
Srinivas Girigowdad34cedb2013-01-25 13:33:11 -080015536 status = eHAL_STATUS_FAILURE;
15537 }
15538 return status;
15539}
15540#endif
15541
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015542
15543
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015544#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015545eHalStatus csrGetTsmStats(tpAniSirGlobal pMac,
15546 tCsrTsmStatsCallback callback,
15547 tANI_U8 staId,
15548 tCsrBssid bssId,
15549 void *pContext,
15550 void* pVosContext,
15551 tANI_U8 tid)
15552{
15553 eHalStatus status = eHAL_STATUS_SUCCESS;
15554 tAniGetTsmStatsReq *pMsg = NULL;
15555
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015556 pMsg = (tAniGetTsmStatsReq*)vos_mem_malloc(sizeof(tAniGetTsmStatsReq));
15557 if (NULL == pMsg)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015558 {
15559 smsLog(pMac, LOGE, "csrGetTsmStats: failed to allocate mem for req");
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015560 return eHAL_STATUS_FAILED_ALLOC;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015561 }
15562 // need to initiate a stats request to PE
15563 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_GET_TSM_STATS_REQ);
15564 pMsg->msgLen = (tANI_U16)sizeof(tAniGetTsmStatsReq);
15565 pMsg->staId = staId;
15566 pMsg->tid = tid;
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080015567 vos_mem_copy(pMsg->bssId, bssId, sizeof(tSirMacAddr));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015568 pMsg->tsmStatsCallback = callback;
15569 pMsg->pDevContext = pContext;
15570 pMsg->pVosContext = pVosContext;
15571 status = palSendMBMessage(pMac->hHdd, pMsg );
15572 if(!HAL_STATUS_SUCCESS(status))
15573 {
15574 smsLog(pMac, LOG1, " csrGetTsmStats: failed to send down the rssi req");
15575 //pMsg is freed by palSendMBMessage
15576 status = eHAL_STATUS_FAILURE;
15577 }
15578 return status;
15579}
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080015580#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070015581
15582
Madan Mohan Koyyalamudi8af9b402013-07-11 14:59:10 +053015583/* ---------------------------------------------------------------------------
15584 \fn csrGetTLSTAState
15585 \helper function to get teh TL STA State whenever the function is called.
15586
15587 \param staId - The staID to be passed to the TL
15588 to get the relevant TL STA State
15589 \return the state as tANI_U16
15590 ---------------------------------------------------------------------------*/
15591tANI_U16 csrGetTLSTAState(tpAniSirGlobal pMac, tANI_U8 staId)
15592{
15593 WLANTL_STAStateType tlSTAState;
15594 tlSTAState = WLANTL_STA_INIT;
15595
15596 //request TL for STA State
15597 if ( !VOS_IS_STATUS_SUCCESS(WLANTL_GetSTAState(pMac->roam.gVosContext, staId, &tlSTAState)) )
15598 {
15599 smsLog(pMac, LOGE, FL("csrGetTLSTAState:couldn't get the STA state from TL"));
15600 }
15601
15602 return tlSTAState;
15603}
15604
Jeff Johnson295189b2012-06-20 16:38:30 -070015605eHalStatus csrGetStatistics(tpAniSirGlobal pMac, eCsrStatsRequesterType requesterId,
15606 tANI_U32 statsMask,
15607 tCsrStatsCallback callback,
15608 tANI_U32 periodicity, tANI_BOOLEAN cache,
15609 tANI_U8 staId, void *pContext)
15610{
15611 tCsrStatsClientReqInfo staEntry;
15612 tCsrStatsClientReqInfo *pStaEntry = NULL;
15613 tCsrPeStatsReqInfo *pPeStaEntry = NULL;
15614 tListElem *pEntry = NULL;
15615 tANI_BOOLEAN found = FALSE;
15616 eHalStatus status = eHAL_STATUS_SUCCESS;
15617 tANI_BOOLEAN insertInClientList = FALSE;
15618 VOS_STATUS vosStatus;
Jeff Johnsone7245742012-09-05 17:12:55 -070015619 WLANTL_TRANSFER_STA_TYPE *pTlStats;
Jeff Johnson295189b2012-06-20 16:38:30 -070015620
15621 if( csrIsAllSessionDisconnected(pMac) )
15622 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015623 //smsLog(pMac, LOGW, "csrGetStatistics: wrong state curState(%d) not connected", pMac->roam.curState);
Jeff Johnson295189b2012-06-20 16:38:30 -070015624 return eHAL_STATUS_FAILURE;
15625 }
Hanumantha Reddy Pothula449aadf2014-02-07 13:53:35 +053015626
15627 if (csrNeighborMiddleOfRoaming((tHalHandle)pMac))
15628 {
15629 smsLog(pMac, LOG1, FL("in the middle of roaming states"));
15630 return eHAL_STATUS_FAILURE;
15631 }
15632
Jeff Johnson295189b2012-06-20 16:38:30 -070015633 if((!statsMask) && (!callback))
15634 {
15635 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015636 smsLog(pMac, LOGW, "csrGetStatistics: statsMask & callback empty in the request");
Jeff Johnson295189b2012-06-20 16:38:30 -070015637 return eHAL_STATUS_FAILURE;
15638 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015639 //for the search list method for deregister
15640 staEntry.requesterId = requesterId;
15641 staEntry.statsMask = statsMask;
15642 //requester wants to deregister or just an error
15643 if((statsMask) && (!callback))
15644 {
15645 pEntry = csrRoamChecknUpdateClientReqList(pMac, &staEntry, FALSE);
15646 if(!pEntry)
15647 {
15648 //msg
15649 smsLog(pMac, LOGW, "csrGetStatistics: callback is empty in the request & couldn't "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015650 "find any existing request in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015651 return eHAL_STATUS_FAILURE;
15652 }
15653 else
15654 {
15655 //clean up & return
15656 pStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnsond13512a2012-07-17 11:42:19 -070015657 if(NULL != pStaEntry->pPeStaEntry)
Jeff Johnson295189b2012-06-20 16:38:30 -070015658 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015659 pStaEntry->pPeStaEntry->numClient--;
15660 //check if we need to delete the entry from peStatsReqList too
15661 if(!pStaEntry->pPeStaEntry->numClient)
15662 {
15663 csrRoamRemoveEntryFromPeStatsReqList(pMac, pStaEntry->pPeStaEntry);
15664 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015665 }
Jeff Johnsond13512a2012-07-17 11:42:19 -070015666
Jeff Johnson295189b2012-06-20 16:38:30 -070015667 //check if we need to stop the tl stats timer too
15668 pMac->roam.tlStatsReqInfo.numClient--;
15669 if(!pMac->roam.tlStatsReqInfo.numClient)
15670 {
15671 if(pMac->roam.tlStatsReqInfo.timerRunning)
15672 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015673 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
15674 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015675 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015676 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015677 return eHAL_STATUS_FAILURE;
15678 }
15679 }
15680 pMac->roam.tlStatsReqInfo.periodicity = 0;
15681 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
15682 }
15683 vos_timer_stop( &pStaEntry->timer );
Jeff Johnson295189b2012-06-20 16:38:30 -070015684 // Destroy the vos timer...
15685 vosStatus = vos_timer_destroy( &pStaEntry->timer );
15686 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15687 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015688 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to destroy Client req timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015689 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015690 csrRoamRemoveStatListEntry(pMac, pEntry);
15691 pStaEntry = NULL;
15692 return eHAL_STATUS_SUCCESS;
15693 }
15694 }
15695
15696 if(cache && !periodicity)
15697 {
15698 //return the cached stats
15699 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15700 }
15701 else
15702 {
15703 //add the request in the client req list
15704 staEntry.callback = callback;
15705 staEntry.pContext = pContext;
15706 staEntry.periodicity = periodicity;
15707 staEntry.pPeStaEntry = NULL;
15708 staEntry.staId = staId;
15709 staEntry.pMac = pMac;
15710 staEntry.timerExpired = FALSE;
15711
15712
Jeff Johnson295189b2012-06-20 16:38:30 -070015713 //if periodic report requested with non cached result from PE/TL
15714 if(periodicity)
15715 {
15716
15717 //if looking for stats from PE
15718 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15719 {
15720
15721 //check if same request made already & waiting for rsp
15722 pPeStaEntry = csrRoamCheckPeStatsReqList(pMac, statsMask & ~(1 << eCsrGlobalClassDStats),
15723 periodicity, &found, staId);
15724 if(!pPeStaEntry)
15725 {
15726 //bail out, maxed out on number of req for PE
15727 return eHAL_STATUS_FAILURE;
15728 }
15729 else
15730 {
15731 staEntry.pPeStaEntry = pPeStaEntry;
15732 }
15733
15734 }
15735 //request stats from TL rightaway if requested by client, update tlStatsReqInfo if needed
15736 if(statsMask & (1 << eCsrGlobalClassDStats))
15737 {
15738 if(cache && pMac->roam.tlStatsReqInfo.numClient)
15739 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015740 smsLog(pMac, LOGE, FL("csrGetStatistics:Looking for cached stats from TL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015741 }
15742 else
15743 {
15744
15745 //update periodicity
15746 if(pMac->roam.tlStatsReqInfo.periodicity)
15747 {
15748 pMac->roam.tlStatsReqInfo.periodicity =
15749 CSR_ROAM_MIN(periodicity, pMac->roam.tlStatsReqInfo.periodicity);
15750 }
15751 else
15752 {
15753 pMac->roam.tlStatsReqInfo.periodicity = periodicity;
15754 }
15755 if(pMac->roam.tlStatsReqInfo.periodicity < CSR_MIN_TL_STAT_QUERY_PERIOD)
15756 {
15757 pMac->roam.tlStatsReqInfo.periodicity = CSR_MIN_TL_STAT_QUERY_PERIOD;
15758 }
15759
15760 if(!pMac->roam.tlStatsReqInfo.timerRunning)
15761 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015762 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015763 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015764 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015765 //req TL for class D stats
15766 if(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId))
15767 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015768 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015769 }
15770 else
15771 {
15772 //save in SME
15773 csrRoamSaveStatsFromTl(pMac, pTlStats);
15774 }
15775 vos_mem_free(pTlStats);
15776 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015777 }
15778 else
15779 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015780 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015781 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015782
Jeff Johnson295189b2012-06-20 16:38:30 -070015783 if(pMac->roam.tlStatsReqInfo.periodicity)
15784 {
15785 //start timer
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015786 status = vos_timer_start(&pMac->roam.tlStatsReqInfo.hTlStatsTimer,
15787 pMac->roam.tlStatsReqInfo.periodicity);
15788 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070015789 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015790 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015791 return eHAL_STATUS_FAILURE;
15792 }
15793 pMac->roam.tlStatsReqInfo.timerRunning = TRUE;
15794 }
15795 }
15796 }
15797 pMac->roam.tlStatsReqInfo.numClient++;
15798 }
15799
15800 insertInClientList = TRUE;
15801 }
15802 //if one time report requested with non cached result from PE/TL
15803 else if(!cache && !periodicity)
15804 {
15805 if(statsMask & ~(1 << eCsrGlobalClassDStats))
15806 {
15807 //send down a req
15808 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
15809 if(!HAL_STATUS_SUCCESS(status))
15810 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015811 smsLog(pMac, LOGE, FL("csrGetStatistics:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015812 }
15813 //so that when the stats rsp comes back from PE we respond to upper layer
15814 //right away
15815 staEntry.timerExpired = TRUE;
15816 insertInClientList = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -070015817 }
15818 if(statsMask & (1 << eCsrGlobalClassDStats))
15819 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015820 pTlStats = (WLANTL_TRANSFER_STA_TYPE *)vos_mem_malloc(sizeof(WLANTL_TRANSFER_STA_TYPE));
Kiet Lam64c1b492013-07-12 13:56:44 +053015821 if (NULL != pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070015822 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015823 //req TL for class D stats
15824 if(!VOS_IS_STATUS_SUCCESS(WLANTL_GetStatistics(pMac->roam.gVosContext, pTlStats, staId)))
15825 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015826 smsLog(pMac, LOGE, FL("csrGetStatistics:couldn't get the stats from TL"));
Jeff Johnsone7245742012-09-05 17:12:55 -070015827 }
15828 else
15829 {
15830 //save in SME
15831 csrRoamSaveStatsFromTl(pMac, pTlStats);
15832 }
15833 vos_mem_free(pTlStats);
15834 pTlStats = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070015835 }
15836 else
15837 {
Jeff Johnsone7245742012-09-05 17:12:55 -070015838 smsLog(pMac, LOGE, FL("cannot allocate memory for TL stat"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015839 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015840
15841 }
15842 //if looking for stats from TL only
15843 if(!insertInClientList)
15844 {
15845 //return the stats
15846 csrRoamReportStatistics(pMac, statsMask, callback, staId, pContext);
15847 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015848 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015849 if(insertInClientList)
15850 {
15851 pStaEntry = csrRoamInsertEntryIntoList(pMac, &pMac->roam.statsClientReqList, &staEntry);
15852 if(!pStaEntry)
15853 {
15854 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015855 smsLog(pMac, LOGW, "csrGetStatistics: Failed to insert req in statsClientReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070015856 return eHAL_STATUS_FAILURE;
15857 }
Jeff Johnsone7245742012-09-05 17:12:55 -070015858 pStaEntry->periodicity = periodicity;
Jeff Johnson295189b2012-06-20 16:38:30 -070015859 //Init & start timer if needed
15860 if(periodicity)
15861 {
15862 vosStatus = vos_timer_init( &pStaEntry->timer, VOS_TIMER_TYPE_SW,
15863 csrRoamStatsClientTimerHandler, pStaEntry );
15864 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15865 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015866 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot init StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015867 return eHAL_STATUS_FAILURE;
15868 }
15869 vosStatus = vos_timer_start( &pStaEntry->timer, periodicity );
15870 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
15871 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080015872 smsLog(pMac, LOGE, FL("csrGetStatistics:cannot start StatsClient timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070015873 return eHAL_STATUS_FAILURE;
15874 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015875 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015876 }
Jeff Johnson295189b2012-06-20 16:38:30 -070015877 }
15878 return eHAL_STATUS_SUCCESS;
15879}
15880
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015881#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
15882
15883static tSirRetStatus
15884csrRoamScanOffloadPopulateMacHeader(tpAniSirGlobal pMac,
15885 tANI_U8* pBD,
15886 tANI_U8 type,
15887 tANI_U8 subType,
15888 tSirMacAddr peerAddr,
15889 tSirMacAddr selfMacAddr)
15890{
15891 tSirRetStatus statusCode = eSIR_SUCCESS;
15892 tpSirMacMgmtHdr pMacHdr;
15893
15894 /* Prepare MAC management header */
15895 pMacHdr = (tpSirMacMgmtHdr) (pBD);
15896
15897 /* Prepare FC */
15898 pMacHdr->fc.protVer = SIR_MAC_PROTOCOL_VERSION;
15899 pMacHdr->fc.type = type;
15900 pMacHdr->fc.subType = subType;
15901
15902 /* Prepare Address 1 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015903 vos_mem_copy((tANI_U8 *) pMacHdr->da, (tANI_U8 *) peerAddr,
15904 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015905
15906 sirCopyMacAddr(pMacHdr->sa,selfMacAddr);
15907
15908 /* Prepare Address 3 */
Kiet Lam64c1b492013-07-12 13:56:44 +053015909 vos_mem_copy((tANI_U8 *) pMacHdr->bssId, (tANI_U8 *) peerAddr,
15910 sizeof( tSirMacAddr ));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015911 return statusCode;
15912} /*** csrRoamScanOffloadPopulateMacHeader() ***/
15913
15914static tSirRetStatus
15915csrRoamScanOffloadPrepareProbeReqTemplate(tpAniSirGlobal pMac,
15916 tANI_U8 nChannelNum,
15917 tANI_U32 dot11mode,
15918 tSirMacAddr selfMacAddr,
15919 tANI_U8 *pFrame,
15920 tANI_U16 *pusLen)
15921{
15922 tDot11fProbeRequest pr;
15923 tANI_U32 nStatus, nBytes, nPayload;
15924 tSirRetStatus nSirStatus;
15925 /*Bcast tx*/
15926 tSirMacAddr bssId = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
15927 /*- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
15928
15929
Kiet Lam64c1b492013-07-12 13:56:44 +053015930 vos_mem_set(( tANI_U8* )&pr, sizeof( pr ), 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015931
15932 PopulateDot11fSuppRates( pMac, nChannelNum, &pr.SuppRates,NULL);
15933
15934 if ( WNI_CFG_DOT11_MODE_11B != dot11mode )
15935 {
15936 PopulateDot11fExtSuppRates1( pMac, nChannelNum, &pr.ExtSuppRates );
15937 }
15938
15939
15940 if (IS_DOT11_MODE_HT(dot11mode))
15941 {
15942 PopulateDot11fHTCaps( pMac, NULL, &pr.HTCaps );
15943 }
15944
15945
15946 nStatus = dot11fGetPackedProbeRequestSize( pMac, &pr, &nPayload );
15947 if ( DOT11F_FAILED( nStatus ) )
15948 {
15949 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15950 "Failed to calculate the packed size f"
15951 "or a Probe Request (0x%08x).\n", nStatus );
15952
15953
15954 nPayload = sizeof( tDot11fProbeRequest );
15955 }
15956 else if ( DOT11F_WARNED( nStatus ) )
15957 {
15958 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15959 "There were warnings while calculating"
15960 "the packed size for a Probe Request ("
15961 "0x%08x).\n", nStatus );
15962 }
15963
15964 nBytes = nPayload + sizeof( tSirMacMgmtHdr );
15965
15966 /* Prepare outgoing frame*/
Kiet Lam64c1b492013-07-12 13:56:44 +053015967 vos_mem_set(pFrame, nBytes , 0);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015968
15969
15970 nSirStatus = csrRoamScanOffloadPopulateMacHeader( pMac, pFrame, SIR_MAC_MGMT_FRAME,
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053015971 SIR_MAC_MGMT_PROBE_REQ, bssId,selfMacAddr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015972
15973 if ( eSIR_SUCCESS != nSirStatus )
15974 {
15975 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15976 "Failed to populate the buffer descriptor for a Probe Request (%d).\n",
15977 nSirStatus );
15978 return nSirStatus;
15979 }
15980
15981
15982 nStatus = dot11fPackProbeRequest( pMac, &pr, pFrame +
15983 sizeof( tSirMacMgmtHdr ),
15984 nPayload, &nPayload );
15985 if ( DOT11F_FAILED( nStatus ) )
15986 {
15987 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
15988 "Failed to pack a Probe Request (0x%08x).\n", nStatus );
15989 return eSIR_FAILURE;
15990 }
15991 else if ( DOT11F_WARNED( nStatus ) )
15992 {
15993 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonce8ad512013-10-30 12:34:42 -070015994 "There were warnings while packing a Probe Request (0x%08x).\n",
15995 nStatus );
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070015996 }
15997
15998 *pusLen = nPayload + sizeof(tSirMacMgmtHdr);
15999 return eSIR_SUCCESS;
16000}
16001
16002eHalStatus csrRoamOffloadScan(tpAniSirGlobal pMac, tANI_U8 command, tANI_U8 reason)
16003{
16004 vos_msg_t msg;
16005 tSirRoamOffloadScanReq *pRequestBuf;
16006 tpCsrNeighborRoamControlInfo pNeighborRoamInfo = &pMac->roam.neighborRoamInfo;
16007 tCsrRoamSession *pSession;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016008 tANI_U8 i,j,num_channels = 0, ucDot11Mode;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016009 tANI_U8 *ChannelList = NULL;
16010 tANI_U32 sessionId;
16011 eHalStatus status = eHAL_STATUS_SUCCESS;
16012 tpCsrChannelInfo currChannelListInfo;
Srinivas Girigowda56076852013-08-20 14:00:50 -070016013 tANI_U32 host_channels = 0;
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016014 tANI_U8 ChannelCacheStr[128] = {0};
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016015 eCsrBand eBand;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016016 tSirBssDescription *pBssDesc = NULL;
16017 tDot11fBeaconIEs *pIes = NULL;
16018 tANI_U8 minRate = 0, dataRate;
Varun Reddy Yeturu52231ea2014-02-06 12:00:56 -080016019 tANI_U8 operationChannel = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016020
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016021 currChannelListInfo = &pNeighborRoamInfo->roamChannelInfo.currentChannelListInfo;
16022
Srinivas Girigowda830bbd02013-06-13 19:44:16 -070016023 if (0 == csrRoamIsRoamOffloadScanEnabled(pMac))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016024 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016025 smsLog( pMac, LOGE,"isRoamOffloadScanEnabled not set");
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016026 return eHAL_STATUS_FAILURE;
16027 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016028
16029 if ((VOS_TRUE == bRoamScanOffloadStarted) && (ROAM_SCAN_OFFLOAD_START == command))
16030 {
16031 smsLog( pMac, LOGE,"Roam Scan Offload is already started");
16032 return eHAL_STATUS_FAILURE;
16033 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016034 status = csrRoamGetSessionIdFromBSSID(pMac,
16035 (tCsrBssid *)pNeighborRoamInfo->currAPbssid,
16036 &sessionId);
16037 /*The Dynamic Config Items Update may happen even if the state is in INIT.
16038 * It is important to ensure that the command is passed down to the FW only
16039 * if the Infra Station is in a connected state.A connected station could also be
16040 * in a PREAUTH or REASSOC states.So, consider not sending the command down in INIT state.
16041 * We also have to ensure that if there is a STOP command we always have to inform Riva,
16042 * irrespective of whichever state we are in.*/
16043 if ((pMac->roam.neighborRoamInfo.neighborRoamState == eCSR_NEIGHBOR_ROAM_STATE_INIT) &&
16044 (command != ROAM_SCAN_OFFLOAD_STOP))
16045 {
Mahesh A Saptasagar14addb62014-02-17 17:17:51 +053016046 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO,
16047 FL("Scan Command not sent to FW with state = %s and cmd=%d\n"),
16048 macTraceGetNeighbourRoamState(
16049 pMac->roam.neighborRoamInfo.neighborRoamState), command);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016050 return eHAL_STATUS_FAILURE;
16051 }
16052
16053 if ( !HAL_STATUS_SUCCESS( status ) )
16054 {
16055 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to find the sessionId for Roam Offload scan request", __func__);
16056 return eHAL_STATUS_FAILURE;
16057 }
16058 pSession = CSR_GET_SESSION( pMac, sessionId );
krunal soni587bf012014-02-04 12:35:11 -080016059 if (NULL == pSession)
16060 {
16061 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16062 "%s:pSession is null", __func__);
16063 return eHAL_STATUS_FAILURE;
16064 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016065 pBssDesc = pSession->pConnectBssDesc;
16066 if (pBssDesc == NULL)
16067 {
16068 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: pBssDesc not found for current session", __func__);
16069 return eHAL_STATUS_FAILURE;
16070 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016071 pRequestBuf = vos_mem_malloc(sizeof(tSirRoamOffloadScanReq));
16072 if (NULL == pRequestBuf)
16073 {
16074 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to allocate memory for Roam Offload scan request", __func__);
16075 return eHAL_STATUS_FAILED_ALLOC;
16076 }
16077
Kiet Lam64c1b492013-07-12 13:56:44 +053016078 vos_mem_zero(pRequestBuf, sizeof(tSirRoamOffloadScanReq));
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016079 /* If command is STOP, then pass down ScanOffloadEnabled as Zero.This will handle the case of
16080 * host driver reloads, but Riva still up and running*/
Mukul Sharma90506b42014-04-24 13:24:12 +053016081 pRequestBuf->Command = command;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016082 if(command == ROAM_SCAN_OFFLOAD_STOP)
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016083 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016084 pRequestBuf->RoamScanOffloadEnabled = 0;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016085 /*For a STOP Command, there is no need to
16086 * go through filling up all the below parameters
16087 * since they are not required for the STOP command*/
16088 goto send_roam_scan_offload_cmd;
16089 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016090 else
16091 pRequestBuf->RoamScanOffloadEnabled = pMac->roam.configParam.isRoamOffloadScanEnabled;
Kiet Lam64c1b492013-07-12 13:56:44 +053016092 vos_mem_copy(pRequestBuf->ConnectedNetwork.currAPbssid,
16093 pNeighborRoamInfo->currAPbssid,
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016094 sizeof(tCsrBssid));
16095 pRequestBuf->ConnectedNetwork.ssId.length =
16096 pMac->roam.roamSession[sessionId].connectedProfile.SSID.length;
16097 vos_mem_copy(pRequestBuf->ConnectedNetwork.ssId.ssId,
16098 pMac->roam.roamSession[sessionId].connectedProfile.SSID.ssId,
16099 pRequestBuf->ConnectedNetwork.ssId.length);
16100 pRequestBuf->ConnectedNetwork.authentication =
16101 pMac->roam.roamSession[sessionId].connectedProfile.AuthType;
16102 pRequestBuf->ConnectedNetwork.encryption =
16103 pMac->roam.roamSession[sessionId].connectedProfile.EncryptionType;
16104 pRequestBuf->ConnectedNetwork.mcencryption =
16105 pMac->roam.roamSession[sessionId].connectedProfile.mcEncryptionType;
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016106 if (pNeighborRoamInfo->cfgParams.neighborLookupThreshold)
16107 {
16108 pRequestBuf->LookupThreshold =
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016109 (v_S7_t)pNeighborRoamInfo->cfgParams.neighborLookupThreshold * (-1);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016110 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16111 }
16112 else
16113 {
16114 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Calculate Adaptive Threshold");
16115 operationChannel = pSession->connectedProfile.operationChannel;
16116
16117 if (!HAL_STATUS_SUCCESS(csrGetParsedBssDescriptionIEs(pMac, pBssDesc, &pIes)))
16118 {
16119 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16120 "%s: csrGetParsedBssDescriptionIEs failed", __func__);
16121 vos_mem_free(pRequestBuf);
16122 return eHAL_STATUS_FAILURE;
16123 }
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016124 if(NULL == pIes)
16125 {
16126 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16127 "%s : pIes is Null", __func__);
Mukul Sharmad2b81862014-07-01 21:01:04 +053016128 vos_mem_free(pRequestBuf);
Kaushik, Sushant5874d032014-02-20 17:22:36 +053016129 return eHAL_STATUS_FAILURE;
16130 }
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016131 if (pIes->SuppRates.present)
16132 {
16133 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "Number \t Rate");
16134 /*Check for both basic rates and extended rates.*/
16135 for (i = 0; i < pIes->SuppRates.num_rates; i++)
16136 {
16137 /*Check if the Rate is Mandatory or Not*/
16138 if (csrRatesIsDot11RateSupported(pMac, pIes->SuppRates.rates[i])
16139 && (pIes->SuppRates.rates[i] & 0x80))
16140 {
16141 /*Retrieve the actual data rate*/
16142 dataRate = (pIes->SuppRates.rates[i] & 0x7F)/2;
16143 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16144 if (minRate == 0)
16145 minRate = dataRate;
16146 else
16147 minRate = (minRate < dataRate) ? minRate:dataRate;
16148 }
16149 }
16150
16151 if (pIes->ExtSuppRates.present)
16152 {
16153 for (i = 0; i < pIes->ExtSuppRates.num_rates; i++)
16154 {
16155 /*Check if the Rate is Mandatory or Not*/
16156 if (csrRatesIsDot11RateSupported(pMac, pIes->ExtSuppRates.rates[i])
16157 && (pIes->ExtSuppRates.rates[i] & 0x80))
16158 {
16159 /*Retrieve the actual data rate*/
16160 dataRate = (pIes->ExtSuppRates.rates[i] & 0x7F)/2;
16161 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_INFO, "%d \t\t %d", i, dataRate);
16162 if (minRate == 0)
16163 minRate = dataRate;
16164 else
16165 minRate = (minRate < dataRate) ? minRate:dataRate;
16166 }
16167 }
16168 }
16169 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "MinRate = %d", minRate);
16170 }
16171 else
16172 {
16173 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16174 "%s: Supp Rates not present in pIes", __func__);
16175 vos_mem_free(pRequestBuf);
16176 return eHAL_STATUS_FAILURE;
16177 }
16178 if (NULL != pIes)
16179 {
16180 vos_mem_free(pIes);
16181 pIes = NULL;
16182 }
16183 switch (minRate)
16184 {
16185 case 1:
16186 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_1MBPS;
16187 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_1MBPS;
16188 break;
16189 case 2:
16190 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_2MBPS;
16191 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_2MBPS;
16192 break;
16193 case 5:
16194 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_5_5MBPS;
16195 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_5_5MBPS;
16196 break;
16197 case 6:
16198 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16199 {
16200 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_2G;
16201 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_2G;
16202 }
16203 else
16204 {
16205 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_6MBPS_5G;
16206 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_6MBPS_5G;
16207 }
16208 break;
16209 case 11:
16210 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_11MBPS;
16211 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_11MBPS;
16212 break;
16213 case 12:
16214 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16215 {
16216 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_2G;
16217 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_2G;
16218 }
16219 else
16220 {
16221 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_12MBPS_5G;
16222 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_12MBPS_5G;
16223 }
16224 break;
16225 case 24:
16226 if (CSR_IS_CHANNEL_24GHZ(operationChannel))
16227 {
16228 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_2G;
16229 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_2G;
16230 }
16231 else
16232 {
16233 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_24MBPS_5G;
16234 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_24MBPS_5G;
16235 }
16236 break;
16237 default:
16238 pRequestBuf->LookupThreshold = LFR_LOOKUP_THR_DEFAULT;
16239 pRequestBuf->RxSensitivityThreshold = LFR_SENSITIVITY_THR_DEFAULT;
16240 break;
16241 }
16242 }
16243 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16244 "Chnl=%d,MinRate=%d,RxSenThr=%d,LookupThr=%d",
16245 operationChannel, minRate,
16246 pRequestBuf->RxSensitivityThreshold,
16247 pRequestBuf->LookupThreshold);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016248 pRequestBuf->RoamRssiDiff =
16249 pMac->roam.configParam.RoamRssiDiff;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016250 pRequestBuf->StartScanReason = reason;
16251 pRequestBuf->NeighborScanTimerPeriod =
16252 pNeighborRoamInfo->cfgParams.neighborScanPeriod;
16253 pRequestBuf->NeighborRoamScanRefreshPeriod =
16254 pNeighborRoamInfo->cfgParams.neighborResultsRefreshPeriod;
16255 pRequestBuf->NeighborScanChannelMinTime =
16256 pNeighborRoamInfo->cfgParams.minChannelScanTime;
16257 pRequestBuf->NeighborScanChannelMaxTime =
16258 pNeighborRoamInfo->cfgParams.maxChannelScanTime;
16259 pRequestBuf->EmptyRefreshScanPeriod =
16260 pNeighborRoamInfo->cfgParams.emptyScanRefreshPeriod;
Sameer Thalappil4ae66ec2013-11-05 14:17:35 -080016261 /* MAWC feature */
16262 pRequestBuf->MAWCEnabled =
16263 pMac->roam.configParam.MAWCEnabled;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016264#ifdef FEATURE_WLAN_ESE
16265 pRequestBuf->IsESEEnabled = pMac->roam.configParam.isEseIniFeatureEnabled;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016266#endif
16267 if (
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016268#ifdef FEATURE_WLAN_ESE
16269 ((pNeighborRoamInfo->isESEAssoc) &&
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016270 (pNeighborRoamInfo->roamChannelInfo.IAPPNeighborListReceived ==
16271 eANI_BOOLEAN_FALSE)) ||
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016272 (pNeighborRoamInfo->isESEAssoc == eANI_BOOLEAN_FALSE) ||
16273#endif // ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016274 currChannelListInfo->numOfChannels == 0)
16275 {
16276
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016277 /*Retrieve the Channel Cache either from ini or from the Occupied Channels list.
16278 * Give Preference to INI Channels.*/
16279 if (pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels)
16280 {
16281 ChannelList = pNeighborRoamInfo->cfgParams.channelInfo.ChannelList;
16282 /*The INI channels need to be filtered with respect to the current
16283 * band that is supported.*/
16284 eBand = pMac->roam.configParam.bandCapability;
16285 if ((eCSR_BAND_24 != eBand) && (eCSR_BAND_5G != eBand) && (eCSR_BAND_ALL != eBand))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016286 {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016287 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16288 "Invalid band, No operation carried out (Band %d)", eBand);
16289 vos_mem_free(pRequestBuf);
16290 return eHAL_STATUS_FAILURE;
16291 }
16292 for (i=0; i<pNeighborRoamInfo->cfgParams.channelInfo.numOfChannels; i++)
16293 {
16294 if(((eCSR_BAND_24 == eBand) && CSR_IS_CHANNEL_24GHZ(*ChannelList)) ||
16295 ((eCSR_BAND_5G == eBand) && CSR_IS_CHANNEL_5GHZ(*ChannelList)) ||
16296 (eCSR_BAND_ALL == eBand))
16297 {
16298 if(!CSR_IS_CHANNEL_DFS(*ChannelList) &&
16299 csrRoamIsChannelValid(pMac, *ChannelList) &&
16300 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16301 {
16302 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16303 }
16304 }
16305 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016306 }
16307 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16308 pRequestBuf->ChannelCacheType = CHANNEL_LIST_STATIC;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016309 }
16310 else
16311 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016312 ChannelList = pMac->scan.occupiedChannels.channelList;
16313 for(i=0; i<pMac->scan.occupiedChannels.numChannels; i++)
16314 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016315 /*Allow DFS channels only if the DFS channel roam flag is enabled */
16316 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16317 (!CSR_IS_CHANNEL_DFS(*ChannelList))) &&
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016318 *ChannelList && (num_channels < SIR_ROAM_MAX_CHANNELS))
16319 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016320 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016321 }
16322 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016323 }
16324 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16325 /* If the profile changes as to what it was earlier, inform the FW through
16326 * FLUSH as ChannelCacheType in which case, the FW will flush the occupied channels
16327 * for the earlier profile and try to learn them afresh.*/
16328 if (reason == REASON_FLUSH_CHANNEL_LIST)
16329 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_FLUSH;
16330 else {
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016331 if (csrNeighborRoamIsNewConnectedProfile(pMac))
16332 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_INIT;
16333 else
16334 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016335 }
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016336 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016337 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016338#ifdef FEATURE_WLAN_ESE
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016339 else
16340 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016341 /* If ESE is enabled, and a neighbor Report is received,then
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016342 * Ignore the INI Channels or the Occupied Channel List. Consider
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080016343 * the channels in the neighbor list sent by the ESE AP.*/
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016344 if (currChannelListInfo->numOfChannels != 0)
16345 {
16346 ChannelList = currChannelListInfo->ChannelList;
16347 for (i=0;i<currChannelListInfo->numOfChannels;i++)
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016348 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016349 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16350 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016351 {
16352 pRequestBuf->ConnectedNetwork.ChannelCache[num_channels++] = *ChannelList;
16353 }
16354 ChannelList++;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016355 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016356 pRequestBuf->ConnectedNetwork.ChannelCount = num_channels;
16357 pRequestBuf->ChannelCacheType = CHANNEL_LIST_DYNAMIC_UPDATE;
16358 }
16359 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016360#endif
Kaushik, Sushant5ed8ab62014-03-05 11:21:11 +053016361 for (i = 0, j = 0;j < (sizeof(ChannelCacheStr)/sizeof(ChannelCacheStr[0])) && i < pRequestBuf->ConnectedNetwork.ChannelCount; i++)
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016362 {
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016363 if (j < sizeof(ChannelCacheStr))
16364 {
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016365 j += snprintf(ChannelCacheStr + j, sizeof(ChannelCacheStr) - j," %d",
16366 pRequestBuf->ConnectedNetwork.ChannelCache[i]);
Kaushik, Sushantd39915b2014-04-23 15:12:28 +053016367 }
16368 else
16369 {
16370 break;
16371 }
Varun Reddy Yeturub4dedf22013-09-13 15:58:26 -070016372 }
16373 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,
16374 "ChnlCacheType:%d, No of Chnls:%d,Channels: %s",
16375 pRequestBuf->ChannelCacheType,
16376 pRequestBuf->ConnectedNetwork.ChannelCount,
16377 ChannelCacheStr);
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016378 num_channels = 0;
16379 ChannelList = NULL;
16380
16381 /* Maintain the Valid Channels List*/
Srinivas Girigowda56076852013-08-20 14:00:50 -070016382 host_channels = sizeof(pMac->roam.validChannelList);
16383 if (HAL_STATUS_SUCCESS(csrGetCfgValidChannels(pMac, pMac->roam.validChannelList, &host_channels)))
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016384 {
Srinivas Girigowda56076852013-08-20 14:00:50 -070016385 ChannelList = pMac->roam.validChannelList;
16386 pMac->roam.numValidChannels = host_channels;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016387 }
Srinivas Girigowda56076852013-08-20 14:00:50 -070016388 else
16389 {
16390 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR,
16391 "%s:Failed to get the valid channel list", __func__);
Praveen Kumar Sirisilla16c63772013-10-23 19:31:58 -070016392 vos_mem_free(pRequestBuf);
Srinivas Girigowda56076852013-08-20 14:00:50 -070016393 return eHAL_STATUS_FAILURE;
16394 }
16395 for(i=0; i<pMac->roam.numValidChannels; i++)
16396 {
Sandeep Puligillac80f26e2014-03-11 18:36:10 +053016397 if(((pMac->roam.configParam.allowDFSChannelRoam) ||
16398 (!CSR_IS_CHANNEL_DFS(*ChannelList))) && *ChannelList)
Srinivas Girigowda56076852013-08-20 14:00:50 -070016399 {
16400 pRequestBuf->ValidChannelList[num_channels++] = *ChannelList;
16401 }
16402 ChannelList++;
16403 }
16404 pRequestBuf->ValidChannelCount = num_channels;
16405
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016406 pRequestBuf->MDID.mdiePresent =
16407 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mdiePresent;
16408 pRequestBuf->MDID.mobilityDomain =
16409 pMac->roam.roamSession[sessionId].connectedProfile.MDID.mobilityDomain;
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016410 pRequestBuf->nProbes = pMac->roam.configParam.nProbes;
16411
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016412 pRequestBuf->HomeAwayTime = pMac->roam.configParam.nRoamScanHomeAwayTime;
Varun Reddy Yeturu9d4102c2013-12-02 15:47:03 -080016413 /* Home Away Time should be at least equal to (MaxDwell time + (2*RFS)),
16414 * where RFS is the RF Switching time. It is twice RFS to consider the
16415 * time to go off channel and return to the home channel. */
16416 if (pRequestBuf->HomeAwayTime < (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)))
16417 {
16418 VOS_TRACE( VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_WARN,
16419 "%s: Invalid config, Home away time(%d) is less than (twice RF switching time + channel max time)(%d)"
16420 " Hence enforcing home away time to disable (0)",
16421 __func__, pRequestBuf->HomeAwayTime,
16422 (pRequestBuf->NeighborScanChannelMaxTime + (2 * CSR_ROAM_SCAN_CHANNEL_SWITCH_TIME)));
16423 pRequestBuf->HomeAwayTime = 0;
16424 }
16425 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG,"HomeAwayTime:%d",pRequestBuf->HomeAwayTime);
Srinivas Girigowda6cf0b822013-06-27 14:00:20 -070016426
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016427 /*Prepare a probe request for 2.4GHz band and one for 5GHz band*/
16428 ucDot11Mode = (tANI_U8) csrTranslateToWNICfgDot11Mode(pMac,
16429 csrFindBestPhyMode( pMac, pMac->roam.configParam.phyMode ));
16430 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_24G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16431 pRequestBuf->p24GProbeTemplate, &pRequestBuf->us24GProbeTemplateLen);
16432
16433 csrRoamScanOffloadPrepareProbeReqTemplate(pMac,SIR_ROAM_SCAN_5G_DEFAULT_CH, ucDot11Mode, pSession->selfMacAddr,
16434 pRequestBuf->p5GProbeTemplate, &pRequestBuf->us5GProbeTemplateLen);
Varun Reddy Yeturu6c5e25c2014-01-09 21:55:37 -080016435send_roam_scan_offload_cmd:
Varun Reddy Yeturu920df212013-05-22 08:07:23 -070016436 msg.type = WDA_ROAM_SCAN_OFFLOAD_REQ;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016437 msg.reserved = 0;
16438 msg.bodyptr = pRequestBuf;
16439 if (!VOS_IS_STATUS_SUCCESS(vos_mq_post_message(VOS_MODULE_ID_WDA, &msg)))
16440 {
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016441 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_ERROR, "%s: Not able to post WDA_ROAM_SCAN_OFFLOAD_REQ message to WDA", __func__);
16442 vos_mem_free(pRequestBuf);
16443 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016444 }
Srinivas Girigowda577ed652013-08-14 11:38:29 -070016445 else
16446 {
16447 if (ROAM_SCAN_OFFLOAD_START == command)
16448 bRoamScanOffloadStarted = VOS_TRUE;
16449 else if (ROAM_SCAN_OFFLOAD_STOP == command)
16450 bRoamScanOffloadStarted = VOS_FALSE;
16451 }
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016452
16453 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Roam Scan Offload Command %d, Reason %d", command, reason);
16454 return status;
16455}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016456
16457eHalStatus csrRoamOffloadScanRspHdlr(tpAniSirGlobal pMac, tANI_U8 reason)
16458{
16459 switch(reason)
16460 {
16461 case 0:
16462 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "Rsp for Roam Scan Offload with failure status");
16463 break;
16464 case REASON_OS_REQUESTED_ROAMING_NOW:
16465 csrNeighborRoamProceedWithHandoffReq(pMac);
16466 break;
Mukul Sharma20aa6582014-08-07 21:36:12 +053016467 case REASON_INITIAL_FORCED_ROAM_TO_5G:
16468 VOS_TRACE(VOS_MODULE_ID_SME, VOS_TRACE_LEVEL_DEBUG, "%s recevied REASON_INITIAL_FORCED_ROAM_TO_5G", __func__);
16469 break;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070016470 default:
Tushnim Bhattacharyya5128d752013-06-26 23:23:18 -070016471 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 -070016472 }
16473 return eHAL_STATUS_SUCCESS;
16474}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016475#endif
16476
Jeff Johnson295189b2012-06-20 16:38:30 -070016477tCsrPeStatsReqInfo * csrRoamCheckPeStatsReqList(tpAniSirGlobal pMac, tANI_U32 statsMask,
16478 tANI_U32 periodicity, tANI_BOOLEAN *pFound, tANI_U8 staId)
16479{
16480 tANI_BOOLEAN found = FALSE;
16481 eHalStatus status = eHAL_STATUS_SUCCESS;
16482 tCsrPeStatsReqInfo staEntry;
16483 tCsrPeStatsReqInfo *pTempStaEntry = NULL;
16484 tListElem *pStaEntry = NULL;
16485 VOS_STATUS vosStatus;
16486 tPmcPowerState powerState;
16487 *pFound = FALSE;
16488
16489 pStaEntry = csrRoamFindInPeStatsReqList(pMac, statsMask);
16490 if(pStaEntry)
16491 {
16492 pTempStaEntry = GET_BASE_ADDR( pStaEntry, tCsrPeStatsReqInfo, link );
16493 if(pTempStaEntry->periodicity)
16494 {
16495 pTempStaEntry->periodicity =
16496 CSR_ROAM_MIN(periodicity, pTempStaEntry->periodicity);
16497 }
16498 else
16499 {
16500 pTempStaEntry->periodicity = periodicity;
16501 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016502 pTempStaEntry->numClient++;
16503 found = TRUE;
16504 }
16505 else
16506 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016507 vos_mem_set(&staEntry, sizeof(tCsrPeStatsReqInfo), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070016508 staEntry.numClient = 1;
16509 staEntry.periodicity = periodicity;
16510 staEntry.pMac = pMac;
16511 staEntry.rspPending = FALSE;
16512 staEntry.staId = staId;
16513 staEntry.statsMask = statsMask;
16514 staEntry.timerRunning = FALSE;
16515 pTempStaEntry = csrRoamInsertEntryIntoPeStatsReqList(pMac, &pMac->roam.peStatsReqList, &staEntry);
16516 if(!pTempStaEntry)
16517 {
16518 //msg
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016519 smsLog(pMac, LOGW, "csrRoamCheckPeStatsReqList: Failed to insert req in peStatsReqList");
Jeff Johnson295189b2012-06-20 16:38:30 -070016520 return NULL;
16521 }
16522 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016523 pmcQueryPowerState(pMac, &powerState, NULL, NULL);
16524 if(ePMC_FULL_POWER == powerState)
16525 {
16526 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicity)
16527 {
16528 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicity;
16529 }
16530 }
16531 else
16532 {
16533 if(pTempStaEntry->periodicity < pMac->roam.configParam.statsReqPeriodicityInPS)
16534 {
16535 pTempStaEntry->periodicity = pMac->roam.configParam.statsReqPeriodicityInPS;
16536 }
16537 }
16538 if(!pTempStaEntry->timerRunning)
16539 {
16540 //send down a req in case of one time req, for periodic ones wait for timer to expire
16541 if(!pTempStaEntry->rspPending &&
16542 !pTempStaEntry->periodicity)
16543 {
16544 status = csrSendMBStatsReqMsg(pMac, statsMask & ~(1 << eCsrGlobalClassDStats), staId);
16545 if(!HAL_STATUS_SUCCESS(status))
16546 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016547 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:failed to send down stats req to PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016548 }
16549 else
16550 {
16551 pTempStaEntry->rspPending = TRUE;
16552 }
16553 }
16554 if(pTempStaEntry->periodicity)
16555 {
16556 if(!found)
16557 {
16558
16559 vosStatus = vos_timer_init( &pTempStaEntry->hPeStatsTimer, VOS_TIMER_TYPE_SW,
16560 csrRoamPeStatsTimerHandler, pTempStaEntry );
16561 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16562 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016563 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot init hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016564 return NULL;
16565 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016566 }
16567 //start timer
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016568 smsLog(pMac, LOG1, "csrRoamCheckPeStatsReqList:peStatsTimer period %d", pTempStaEntry->periodicity);
Jeff Johnson295189b2012-06-20 16:38:30 -070016569 vosStatus = vos_timer_start( &pTempStaEntry->hPeStatsTimer, pTempStaEntry->periodicity );
16570 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16571 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016572 smsLog(pMac, LOGE, FL("csrRoamCheckPeStatsReqList:cannot start hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016573 return NULL;
16574 }
16575 pTempStaEntry->timerRunning = TRUE;
16576 }
16577 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016578 *pFound = found;
16579 return pTempStaEntry;
16580}
16581
Jeff Johnson295189b2012-06-20 16:38:30 -070016582/*
16583 pStaEntry is no longer invalid upon the return of this function.
16584*/
16585static void csrRoamRemoveStatListEntry(tpAniSirGlobal pMac, tListElem *pEntry)
16586{
16587 if(pEntry)
16588 {
16589 if(csrLLRemoveEntry(&pMac->roam.statsClientReqList, pEntry, LL_ACCESS_LOCK))
16590 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016591 vos_mem_free(GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link ));
Jeff Johnsone7245742012-09-05 17:12:55 -070016592 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016593 }
16594 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016595
16596void csrRoamRemoveEntryFromPeStatsReqList(tpAniSirGlobal pMac, tCsrPeStatsReqInfo *pPeStaEntry)
16597{
16598 tListElem *pEntry;
16599 tCsrPeStatsReqInfo *pTempStaEntry;
16600 VOS_STATUS vosStatus;
16601 pEntry = csrLLPeekHead( &pMac->roam.peStatsReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016602 if(!pEntry)
16603 {
16604 //list empty
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016605 smsLog(pMac, LOGE, FL(" List empty, no stats req for PE"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016606 return;
16607 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016608 while( pEntry )
16609 {
16610 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrPeStatsReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016611 if( pTempStaEntry && pTempStaEntry->statsMask == pPeStaEntry->statsMask)
16612 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016613 smsLog(pMac, LOGW, FL("Match found"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016614 if(pTempStaEntry->timerRunning)
16615 {
16616 vosStatus = vos_timer_stop( &pTempStaEntry->hPeStatsTimer );
16617 /* If we are not able to stop the timer here, just remove
16618 * the entry from the linked list. Destroy the timer object
16619 * and free the memory in the timer CB
16620 */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016621 if ( vosStatus == VOS_STATUS_SUCCESS )
Jeff Johnson295189b2012-06-20 16:38:30 -070016622 {
16623 /* the timer is successfully stopped */
16624 pTempStaEntry->timerRunning = FALSE;
16625
16626 /* Destroy the timer */
16627 vosStatus = vos_timer_destroy( &pTempStaEntry->hPeStatsTimer );
16628 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16629 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016630 smsLog(pMac, LOGE, FL("csrRoamRemoveEntryFromPeStatsReqList:failed to destroy hPeStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016631 }
16632 }
16633 else
16634 {
16635 // the timer could not be stopped. Hence destroy and free the
16636 // memory for the PE stat entry in the timer CB.
16637 pTempStaEntry->timerStopFailed = TRUE;
16638 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016639 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016640
16641 if(csrLLRemoveEntry(&pMac->roam.peStatsReqList, pEntry, LL_ACCESS_LOCK))
16642 {
16643 // Only free the memory if we could stop the timer successfully
16644 if(!pTempStaEntry->timerStopFailed)
16645 {
Kiet Lam64c1b492013-07-12 13:56:44 +053016646 vos_mem_free(pTempStaEntry);
Jeff Johnson295189b2012-06-20 16:38:30 -070016647 pTempStaEntry = NULL;
16648 }
16649 break;
16650 }
16651
16652 pEntry = csrLLNext( &pMac->roam.peStatsReqList, pEntry, LL_ACCESS_NOLOCK );
16653 }
16654 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016655 return;
16656}
16657
16658
Jeff Johnsone7245742012-09-05 17:12:55 -070016659void csrRoamSaveStatsFromTl(tpAniSirGlobal pMac, WLANTL_TRANSFER_STA_TYPE *pTlStats)
Jeff Johnson295189b2012-06-20 16:38:30 -070016660{
16661
Jeff Johnsone7245742012-09-05 17:12:55 -070016662 pMac->roam.classDStatsInfo.num_rx_bytes_crc_ok = pTlStats->rxBcntCRCok;
16663 pMac->roam.classDStatsInfo.rx_bc_byte_cnt = pTlStats->rxBCBcnt;
16664 pMac->roam.classDStatsInfo.rx_bc_frm_cnt = pTlStats->rxBCFcnt;
16665 pMac->roam.classDStatsInfo.rx_byte_cnt = pTlStats->rxBcnt;
16666 pMac->roam.classDStatsInfo.rx_mc_byte_cnt = pTlStats->rxMCBcnt;
16667 pMac->roam.classDStatsInfo.rx_mc_frm_cnt = pTlStats->rxMCFcnt;
16668 pMac->roam.classDStatsInfo.rx_rate = pTlStats->rxRate;
Jeff Johnson295189b2012-06-20 16:38:30 -070016669 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016670 pMac->roam.classDStatsInfo.rx_uc_byte_cnt[0] = pTlStats->rxUCBcnt;
16671 pMac->roam.classDStatsInfo.rx_uc_frm_cnt = pTlStats->rxUCFcnt;
16672 pMac->roam.classDStatsInfo.tx_bc_byte_cnt = pTlStats->txBCBcnt;
16673 pMac->roam.classDStatsInfo.tx_bc_frm_cnt = pTlStats->txBCFcnt;
16674 pMac->roam.classDStatsInfo.tx_mc_byte_cnt = pTlStats->txMCBcnt;
16675 pMac->roam.classDStatsInfo.tx_mc_frm_cnt = pTlStats->txMCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016676 //?? need per AC
Jeff Johnsone7245742012-09-05 17:12:55 -070016677 pMac->roam.classDStatsInfo.tx_uc_byte_cnt[0] = pTlStats->txUCBcnt;
16678 pMac->roam.classDStatsInfo.tx_uc_frm_cnt = pTlStats->txUCFcnt;
Jeff Johnson295189b2012-06-20 16:38:30 -070016679
16680}
16681
Jeff Johnson295189b2012-06-20 16:38:30 -070016682void csrRoamReportStatistics(tpAniSirGlobal pMac, tANI_U32 statsMask,
16683 tCsrStatsCallback callback, tANI_U8 staId, void *pContext)
16684{
16685 tANI_U8 stats[500];
16686 tANI_U8 *pStats = NULL;
16687 tANI_U32 tempMask = 0;
16688 tANI_U8 counter = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016689 if(!callback)
16690 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016691 smsLog(pMac, LOGE, FL("Cannot report callback NULL"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016692 return;
16693 }
16694 if(!statsMask)
16695 {
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016696 smsLog(pMac, LOGE, FL("Cannot report statsMask is 0"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016697 return;
16698 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016699 pStats = stats;
Jeff Johnson295189b2012-06-20 16:38:30 -070016700 tempMask = statsMask;
Jeff Johnson295189b2012-06-20 16:38:30 -070016701 while(tempMask)
16702 {
16703 if(tempMask & 1)
16704 {
16705 //new stats info from PE, fill up the stats strucutres in PMAC
16706 switch(counter)
16707 {
16708 case eCsrSummaryStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016709 smsLog( pMac, LOG2, FL("Summary stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016710 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.summaryStatsInfo,
16711 sizeof(tCsrSummaryStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016712 pStats += sizeof(tCsrSummaryStatsInfo);
16713 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016714 case eCsrGlobalClassAStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016715 smsLog( pMac, LOG2, FL("ClassA stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016716 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classAStatsInfo,
16717 sizeof(tCsrGlobalClassAStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016718 pStats += sizeof(tCsrGlobalClassAStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016719 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016720 case eCsrGlobalClassBStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016721 smsLog( pMac, LOG2, FL("ClassB stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016722 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classBStatsInfo,
16723 sizeof(tCsrGlobalClassBStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016724 pStats += sizeof(tCsrGlobalClassBStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016725 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016726 case eCsrGlobalClassCStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016727 smsLog( pMac, LOG2, FL("ClassC stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016728 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classCStatsInfo,
16729 sizeof(tCsrGlobalClassCStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016730 pStats += sizeof(tCsrGlobalClassCStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016731 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016732 case eCsrGlobalClassDStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016733 smsLog( pMac, LOG2, FL("ClassD stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016734 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.classDStatsInfo,
16735 sizeof(tCsrGlobalClassDStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016736 pStats += sizeof(tCsrGlobalClassDStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016737 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016738 case eCsrPerStaStats:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016739 smsLog( pMac, LOG2, FL("PerSta stats"));
Kiet Lam64c1b492013-07-12 13:56:44 +053016740 vos_mem_copy( pStats, (tANI_U8 *)&pMac->roam.perStaStatsInfo[staId],
16741 sizeof(tCsrPerStaStatsInfo));
Jeff Johnson295189b2012-06-20 16:38:30 -070016742 pStats += sizeof(tCsrPerStaStatsInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -070016743 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016744 default:
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053016745 smsLog( pMac, LOGE, FL("Unknown stats type and counter %d"), counter);
Jeff Johnson295189b2012-06-20 16:38:30 -070016746 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016747 }
16748 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016749 tempMask >>=1;
16750 counter++;
16751 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016752 callback(stats, pContext );
Jeff Johnson295189b2012-06-20 16:38:30 -070016753}
16754
Jeff Johnson295189b2012-06-20 16:38:30 -070016755eHalStatus csrRoamDeregStatisticsReq(tpAniSirGlobal pMac)
16756{
16757 tListElem *pEntry = NULL;
16758 tListElem *pPrevEntry = NULL;
16759 tCsrStatsClientReqInfo *pTempStaEntry = NULL;
16760 eHalStatus status = eHAL_STATUS_SUCCESS;
16761 VOS_STATUS vosStatus;
16762 pEntry = csrLLPeekHead( &pMac->roam.statsClientReqList, LL_ACCESS_LOCK );
Jeff Johnson295189b2012-06-20 16:38:30 -070016763 if(!pEntry)
16764 {
16765 //list empty
16766 smsLog(pMac, LOGW, "csrRoamDeregStatisticsReq: List empty, no request from "
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016767 "upper layer client(s)");
Jeff Johnson295189b2012-06-20 16:38:30 -070016768 return status;
16769 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016770 while( pEntry )
16771 {
16772 if(pPrevEntry)
16773 {
16774 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16775 //send up the stats report
16776 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16777 pTempStaEntry->staId, pTempStaEntry->pContext);
16778 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16779 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016780 pTempStaEntry = GET_BASE_ADDR( pEntry, tCsrStatsClientReqInfo, link );
Jeff Johnson295189b2012-06-20 16:38:30 -070016781 if (pTempStaEntry->pPeStaEntry) //pPeStaEntry can be NULL
16782 {
Jeff Johnsone7245742012-09-05 17:12:55 -070016783 pTempStaEntry->pPeStaEntry->numClient--;
16784 //check if we need to delete the entry from peStatsReqList too
16785 if(!pTempStaEntry->pPeStaEntry->numClient)
16786 {
16787 csrRoamRemoveEntryFromPeStatsReqList(pMac, pTempStaEntry->pPeStaEntry);
16788 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016789 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016790 //check if we need to stop the tl stats timer too
16791 pMac->roam.tlStatsReqInfo.numClient--;
16792 if(!pMac->roam.tlStatsReqInfo.numClient)
16793 {
16794 if(pMac->roam.tlStatsReqInfo.timerRunning)
16795 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053016796 status = vos_timer_stop(&pMac->roam.tlStatsReqInfo.hTlStatsTimer);
16797 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070016798 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016799 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:cannot stop TlStatsTimer timer"));
Jeff Johnson295189b2012-06-20 16:38:30 -070016800 //we will continue
16801 }
16802 }
16803 pMac->roam.tlStatsReqInfo.periodicity = 0;
16804 pMac->roam.tlStatsReqInfo.timerRunning = FALSE;
16805 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016806 if (pTempStaEntry->periodicity)
16807 {
16808 //While creating StaEntry in csrGetStatistics,
16809 //Initializing and starting timer only when periodicity is set.
16810 //So Stop and Destroy timer only when periodicity is set.
16811
Jeff Johnsone7245742012-09-05 17:12:55 -070016812 vos_timer_stop( &pTempStaEntry->timer );
16813 // Destroy the vos timer...
16814 vosStatus = vos_timer_destroy( &pTempStaEntry->timer );
16815 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
16816 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080016817 smsLog(pMac, LOGE, FL("csrRoamDeregStatisticsReq:failed to destroy Client req timer"));
Jeff Johnsone7245742012-09-05 17:12:55 -070016818 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016819 }
Jeff Johnsone7245742012-09-05 17:12:55 -070016820
Jeff Johnson295189b2012-06-20 16:38:30 -070016821
16822 pPrevEntry = pEntry;
16823 pEntry = csrLLNext( &pMac->roam.statsClientReqList, pEntry, LL_ACCESS_NOLOCK );
16824 }
16825 //the last one
16826 if(pPrevEntry)
16827 {
16828 pTempStaEntry = GET_BASE_ADDR( pPrevEntry, tCsrStatsClientReqInfo, link );
16829 //send up the stats report
16830 csrRoamReportStatistics(pMac, pTempStaEntry->statsMask, pTempStaEntry->callback,
16831 pTempStaEntry->staId, pTempStaEntry->pContext);
16832 csrRoamRemoveStatListEntry(pMac, pPrevEntry);
16833 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016834 return status;
16835
16836}
16837
Jeff Johnson295189b2012-06-20 16:38:30 -070016838eHalStatus csrIsFullPowerNeeded( tpAniSirGlobal pMac, tSmeCmd *pCommand,
16839 tRequestFullPowerReason *pReason,
16840 tANI_BOOLEAN *pfNeedPower )
16841{
16842 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
16843 tRequestFullPowerReason reason = eSME_REASON_OTHER;
16844 tPmcState pmcState;
16845 eHalStatus status = eHAL_STATUS_SUCCESS;
16846 // TODO : Session info unavailable
16847 tANI_U32 sessionId = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -070016848 if( pfNeedPower )
16849 {
16850 *pfNeedPower = eANI_BOOLEAN_FALSE;
16851 }
16852 //We only handle CSR commands
16853 if( !(eSmeCsrCommandMask & pCommand->command) )
16854 {
16855 return eHAL_STATUS_SUCCESS;
16856 }
Jeff Johnson295189b2012-06-20 16:38:30 -070016857 //Check PMC state first
16858 pmcState = pmcGetPmcState( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070016859 switch( pmcState )
16860 {
16861 case REQUEST_IMPS:
16862 case IMPS:
16863 if( eSmeCommandScan == pCommand->command )
16864 {
16865 switch( pCommand->u.scanCmd.reason )
16866 {
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070016867#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
16868 case eCsrScanGetLfrResult:
16869#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016870 case eCsrScanGetResult:
16871 case eCsrScanBGScanAbort:
16872 case eCsrScanBGScanEnable:
16873 case eCsrScanGetScanChnInfo:
16874 //Internal process, no need for full power
16875 fNeedFullPower = eANI_BOOLEAN_FALSE;
16876 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016877 default:
16878 //Other scans are real scan, ask for power
16879 fNeedFullPower = eANI_BOOLEAN_TRUE;
16880 break;
16881 } //switch
16882 }
16883 else
16884 {
16885 //ask for power for roam and status change
16886 fNeedFullPower = eANI_BOOLEAN_TRUE;
16887 }
16888 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016889 case REQUEST_BMPS:
16890 case BMPS:
16891 case REQUEST_START_UAPSD:
16892 case UAPSD:
16893 //We treat WOWL same as BMPS
16894 case REQUEST_ENTER_WOWL:
16895 case WOWL:
16896 if( eSmeCommandRoam == pCommand->command )
16897 {
16898 tScanResultList *pBSSList = (tScanResultList *)pCommand->u.roamCmd.hBSSList;
16899 tCsrScanResult *pScanResult;
16900 tListElem *pEntry;
Jeff Johnson295189b2012-06-20 16:38:30 -070016901 switch ( pCommand->u.roamCmd.roamReason )
16902 {
16903 case eCsrForcedDisassoc:
16904 case eCsrForcedDisassocMICFailure:
16905 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16906 fNeedFullPower = eANI_BOOLEAN_TRUE;
16907 break;
16908 case eCsrSmeIssuedDisassocForHandoff:
16909 case eCsrForcedDeauth:
16910 case eCsrHddIssuedReassocToSameAP:
16911 case eCsrSmeIssuedReassocToSameAP:
16912 fNeedFullPower = eANI_BOOLEAN_TRUE;
16913 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016914 case eCsrCapsChange:
16915 fNeedFullPower = eANI_BOOLEAN_TRUE;
16916 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016917 default:
16918 //Check whether the profile is already connected. If so, no need for full power
16919 //Note: IBSS is ignored for now because we don't support powersave in IBSS
16920 if ( csrIsConnStateConnectedInfra(pMac, sessionId) && pBSSList )
16921 {
16922 //Only need to check the first one
16923 pEntry = csrLLPeekHead(&pBSSList->List, LL_ACCESS_LOCK);
16924 if( pEntry )
16925 {
16926 pScanResult = GET_BASE_ADDR(pEntry, tCsrScanResult, Link);
16927#if 0
16928 // TODO : Session Specific info pConnectBssDesc
16929 if( csrIsBssIdEqual( pMac, &pScanResult->Result.BssDescriptor, pMac->roam.pConnectBssDesc ) &&
16930 csrIsSsidEqual( pMac, pMac->roam.pConnectBssDesc,
16931 &pScanResult->Result.BssDescriptor, (tDot11fBeaconIEs *)( pScanResult->Result.pvIes ) ) )
16932 {
16933 // Check to see if the Auth type has changed in the Profile. If so, we don't want to Reassociate
16934 // with Authenticating first. To force this, stop the current association (Disassociate) and
16935 // then re 'Join' the AP, wihch will force an Authentication (with the new Auth type) followed by
16936 // a new Association.
16937 if(csrIsSameProfile(pMac, &pMac->roam.connectedProfile, pProfile))
16938 {
16939 if(csrRoamIsSameProfileKeys(pMac, &pMac->roam.connectedProfile, pProfile))
16940 {
16941 //Done, eventually, the command reaches eCsrReassocToSelfNoCapChange;
16942 //No need for full power
16943 //Set the flag so the code later can avoid to do the above
16944 //check again.
16945 pCommand->u.roamCmd.fReassocToSelfNoCapChange = eANI_BOOLEAN_TRUE;
16946 break;
16947 }
16948 }
16949 }
16950#endif
16951 }
16952 }
16953 //If we are here, full power is needed
16954 fNeedFullPower = eANI_BOOLEAN_TRUE;
16955 break;
16956 }
16957 }
16958 else if( eSmeCommandWmStatusChange == pCommand->command )
16959 {
16960 //need full power for all
16961 fNeedFullPower = eANI_BOOLEAN_TRUE;
16962 reason = eSME_LINK_DISCONNECTED_BY_OTHER;
16963 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -080016964#ifdef FEATURE_WLAN_TDLS
16965 else if( eSmeCommandTdlsAddPeer == pCommand->command )
16966 {
16967 //TDLS link is getting established. need full power
16968 fNeedFullPower = eANI_BOOLEAN_TRUE;
16969 reason = eSME_FULL_PWR_NEEDED_BY_TDLS_PEER_SETUP;
16970 }
16971#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070016972 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016973 case REQUEST_STOP_UAPSD:
16974 case REQUEST_EXIT_WOWL:
16975 if( eSmeCommandRoam == pCommand->command )
16976 {
16977 fNeedFullPower = eANI_BOOLEAN_TRUE;
16978 switch ( pCommand->u.roamCmd.roamReason )
16979 {
16980 case eCsrForcedDisassoc:
16981 case eCsrForcedDisassocMICFailure:
16982 reason = eSME_LINK_DISCONNECTED_BY_HDD;
16983 break;
16984 default:
16985 break;
16986 }
16987 }
16988 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016989 case STOPPED:
16990 case REQUEST_STANDBY:
16991 case STANDBY:
16992 case LOW_POWER:
16993 //We are not supposed to do anything
Sushant Kaushike0d2cce2014-04-10 14:36:07 +053016994 smsLog( pMac, LOGE, FL( "cannot process because PMC is in"
16995 " stopped/standby state %s (%d)" ),
16996 sme_PmcStatetoString(pmcState), pmcState );
Jeff Johnson295189b2012-06-20 16:38:30 -070016997 status = eHAL_STATUS_FAILURE;
16998 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070016999 case FULL_POWER:
17000 case REQUEST_FULL_POWER:
17001 default:
17002 //No need to ask for full power. This has to be FULL_POWER state
17003 break;
Jeff Johnson295189b2012-06-20 16:38:30 -070017004 } //switch
Jeff Johnson295189b2012-06-20 16:38:30 -070017005 if( pReason )
17006 {
17007 *pReason = reason;
17008 }
17009 if( pfNeedPower )
17010 {
17011 *pfNeedPower = fNeedFullPower;
17012 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017013 return ( status );
17014}
17015
Jeff Johnson295189b2012-06-20 16:38:30 -070017016static eHalStatus csrRequestFullPower( tpAniSirGlobal pMac, tSmeCmd *pCommand )
17017{
17018 eHalStatus status = eHAL_STATUS_SUCCESS;
17019 tANI_BOOLEAN fNeedFullPower = eANI_BOOLEAN_FALSE;
17020 tRequestFullPowerReason reason = eSME_REASON_OTHER;
Jeff Johnson295189b2012-06-20 16:38:30 -070017021 status = csrIsFullPowerNeeded( pMac, pCommand, &reason, &fNeedFullPower );
Jeff Johnson295189b2012-06-20 16:38:30 -070017022 if( fNeedFullPower && HAL_STATUS_SUCCESS( status ) )
17023 {
17024 status = pmcRequestFullPower(pMac, csrFullPowerCallback, pMac, reason);
17025 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017026 return ( status );
17027}
17028
Jeff Johnson295189b2012-06-20 16:38:30 -070017029tSmeCmd *csrGetCommandBuffer( tpAniSirGlobal pMac )
17030{
17031 tSmeCmd *pCmd = smeGetCommandBuffer( pMac );
Jeff Johnson295189b2012-06-20 16:38:30 -070017032 if( pCmd )
17033 {
17034 pMac->roam.sPendingCommands++;
17035 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017036 return ( pCmd );
17037}
17038
Jeff Johnson295189b2012-06-20 16:38:30 -070017039void csrReleaseCommand(tpAniSirGlobal pMac, tSmeCmd *pCommand)
17040{
17041 if (pMac->roam.sPendingCommands > 0)
17042 {
17043 //All command allocated through csrGetCommandBuffer need to
17044 //decrement the pending count when releasing.
17045 pMac->roam.sPendingCommands--;
17046 smeReleaseCommand( pMac, pCommand );
17047 }
17048 else
17049 {
17050 smsLog(pMac, LOGE, FL( "no pending commands"));
17051 VOS_ASSERT(0);
17052 }
17053}
17054
Jeff Johnson295189b2012-06-20 16:38:30 -070017055//Return SUCCESS is the command is queued, failed
17056eHalStatus csrQueueSmeCommand( tpAniSirGlobal pMac, tSmeCmd *pCommand, tANI_BOOLEAN fHighPriority )
17057{
17058 eHalStatus status;
Jeff Johnson295189b2012-06-20 16:38:30 -070017059 if( (eSmeCommandScan == pCommand->command) && pMac->scan.fDropScanCmd )
17060 {
17061 smsLog(pMac, LOGW, FL(" drop scan (scan reason %d) command"),
17062 pCommand->u.scanCmd.reason);
17063 return eHAL_STATUS_CSR_WRONG_STATE;
17064 }
17065
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017066 if ((pMac->fScanOffload) && (pCommand->command == eSmeCommandScan))
17067 {
17068 csrLLInsertTail(&pMac->sme.smeScanCmdPendingList,
17069 &pCommand->Link, LL_ACCESS_LOCK);
17070 // process the command queue...
17071 smeProcessPendingQueue(pMac);
17072 status = eHAL_STATUS_SUCCESS;
17073 goto end;
17074 }
17075
Jeff Johnson295189b2012-06-20 16:38:30 -070017076 //We can call request full power first before putting the command into pending Q
17077 //because we are holding SME lock at this point.
17078 status = csrRequestFullPower( pMac, pCommand );
17079 if( HAL_STATUS_SUCCESS( status ) )
17080 {
17081 tANI_BOOLEAN fNoCmdPending;
Jeff Johnson295189b2012-06-20 16:38:30 -070017082 //make sure roamCmdPendingList is not empty first
17083 fNoCmdPending = csrLLIsListEmpty( &pMac->roam.roamCmdPendingList, eANI_BOOLEAN_FALSE );
17084 if( fNoCmdPending )
17085 {
17086 smePushCommand( pMac, pCommand, fHighPriority );
17087 }
17088 else
17089 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017090 //Other commands are waiting for PMC callback, queue the new command to the pending Q
Jeff Johnson295189b2012-06-20 16:38:30 -070017091 //no list lock is needed since SME lock is held
17092 if( !fHighPriority )
17093 {
17094 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17095 }
17096 else {
17097 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17098 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017099 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017100 }
17101 else if( eHAL_STATUS_PMC_PENDING == status )
17102 {
17103 //no list lock is needed since SME lock is held
17104 if( !fHighPriority )
17105 {
17106 csrLLInsertTail( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17107 }
17108 else {
17109 csrLLInsertHead( &pMac->roam.roamCmdPendingList, &pCommand->Link, eANI_BOOLEAN_FALSE );
17110 }
17111 //Let caller know the command is queue
17112 status = eHAL_STATUS_SUCCESS;
17113 }
17114 else
17115 {
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017116 //Not to decrease pMac->roam.sPendingCommands here. Caller will decrease it when it
Jeff Johnson295189b2012-06-20 16:38:30 -070017117 //release the command.
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017118 smsLog( pMac, LOGE, FL( " cannot queue command %d" ), pCommand->command );
Jeff Johnson295189b2012-06-20 16:38:30 -070017119 }
Madan Mohan Koyyalamudie1a64b42013-06-19 16:34:44 +053017120end:
Jeff Johnson295189b2012-06-20 16:38:30 -070017121 return ( status );
Jeff Johnson295189b2012-06-20 16:38:30 -070017122}
Jeff Johnson295189b2012-06-20 16:38:30 -070017123eHalStatus csrRoamUpdateAPWPSIE( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirAPWPSIEs* pAPWPSIES )
17124{
17125 eHalStatus status = eHAL_STATUS_SUCCESS;
17126 tSirUpdateAPWPSIEsReq *pMsg;
17127 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
17128
17129 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17130 if (NULL == pSession)
17131 {
17132 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17133 return eHAL_STATUS_FAILURE;
17134 }
17135
Jeff Johnson295189b2012-06-20 16:38:30 -070017136 do
17137 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017138 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPSIEsReq));
17139 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17140 vos_mem_set(pMsg, sizeof(tSirUpdateAPWPSIEsReq), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017141 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_UPDATE_APWPSIE_REQ);
17142
17143 pBuf = (tANI_U8 *)&pMsg->transactionId;
lukez3c809222013-05-03 10:23:02 -070017144 VOS_ASSERT(pBuf);
17145
Jeff Johnson295189b2012-06-20 16:38:30 -070017146 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017147 // transactionId
17148 *pBuf = 0;
17149 *( pBuf + 1 ) = 0;
17150 pBuf += sizeof(tANI_U16);
Jeff Johnson295189b2012-06-20 16:38:30 -070017151 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017152 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17153 sizeof(tSirMacAddr) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017154 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017155 //sessionId
17156 *pBuf++ = (tANI_U8)sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017157 // APWPSIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017158 vos_mem_copy((tSirAPWPSIEs *)pBuf, pAPWPSIES, sizeof(tSirAPWPSIEs));
Jeff Johnson295189b2012-06-20 16:38:30 -070017159 pBuf += sizeof(tSirAPWPSIEs);
Jeff Johnson295189b2012-06-20 16:38:30 -070017160 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017161 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017162 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017163 return ( status );
17164}
Jeff Johnson295189b2012-06-20 16:38:30 -070017165eHalStatus csrRoamUpdateWPARSNIEs( tpAniSirGlobal pMac, tANI_U32 sessionId, tSirRSNie * pAPSirRSNie)
17166{
17167 eHalStatus status = eHAL_STATUS_SUCCESS;
17168 tSirUpdateAPWPARSNIEsReq *pMsg;
17169 tANI_U8 *pBuf = NULL, *wTmpBuf = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -070017170 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17171 if (NULL == pSession)
17172 {
17173 smsLog( pMac, LOGE, FL( " Session does not exist for session id %d" ), sessionId);
17174 return eHAL_STATUS_FAILURE;
17175 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017176 do
17177 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017178 pMsg = vos_mem_malloc(sizeof(tSirUpdateAPWPARSNIEsReq));
17179 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17180 vos_mem_set(pMsg, sizeof( tSirUpdateAPWPARSNIEsReq ), 0);
Jeff Johnson295189b2012-06-20 16:38:30 -070017181 pMsg->messageType = pal_cpu_to_be16((tANI_U16)eWNI_SME_SET_APWPARSNIEs_REQ);
Jeff Johnson295189b2012-06-20 16:38:30 -070017182 pBuf = (tANI_U8 *)&pMsg->transactionId;
17183 wTmpBuf = pBuf;
Jeff Johnson295189b2012-06-20 16:38:30 -070017184 // transactionId
17185 *pBuf = 0;
17186 *( pBuf + 1 ) = 0;
17187 pBuf += sizeof(tANI_U16);
lukez3c809222013-05-03 10:23:02 -070017188 VOS_ASSERT(pBuf);
17189
Jeff Johnson295189b2012-06-20 16:38:30 -070017190 // bssId
Kiet Lam64c1b492013-07-12 13:56:44 +053017191 vos_mem_copy((tSirMacAddr *)pBuf, &pSession->selfMacAddr,
17192 sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017193 pBuf += sizeof(tSirMacAddr);
Jeff Johnson295189b2012-06-20 16:38:30 -070017194 // sessionId
17195 *pBuf++ = (tANI_U8)sessionId;
17196
17197 // APWPARSNIEs
Kiet Lam64c1b492013-07-12 13:56:44 +053017198 vos_mem_copy((tSirRSNie *)pBuf, pAPSirRSNie, sizeof(tSirRSNie));
Jeff Johnson295189b2012-06-20 16:38:30 -070017199 pBuf += sizeof(tSirRSNie);
Jeff Johnson295189b2012-06-20 16:38:30 -070017200 pMsg->length = pal_cpu_to_be16((tANI_U16)(sizeof(tANI_U32 ) + (pBuf - wTmpBuf))); //msg_header + msg
Jeff Johnson295189b2012-06-20 16:38:30 -070017201 status = palSendMBMessage(pMac->hHdd, pMsg);
Jeff Johnson295189b2012-06-20 16:38:30 -070017202 } while( 0 );
Jeff Johnson295189b2012-06-20 16:38:30 -070017203 return ( status );
17204}
Jeff Johnson295189b2012-06-20 16:38:30 -070017205
17206#ifdef WLAN_FEATURE_VOWIFI_11R
17207//eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tCsrBssid preAuthBssid, tANI_U8 channelId)
17208eHalStatus csrRoamIssueFTPreauthReq(tHalHandle hHal, tANI_U32 sessionId, tpSirBssDescription pBssDescription)
17209{
17210 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17211 tpSirFTPreAuthReq pftPreAuthReq;
17212 tANI_U16 auth_req_len = 0;
17213 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017214 auth_req_len = sizeof(tSirFTPreAuthReq);
17215 pftPreAuthReq = (tpSirFTPreAuthReq)vos_mem_malloc(auth_req_len);
Kiet Lam64c1b492013-07-12 13:56:44 +053017216 if (NULL == pftPreAuthReq)
Jeff Johnson295189b2012-06-20 16:38:30 -070017217 {
17218 smsLog(pMac, LOGE, FL("Memory allocation for FT Preauth request failed"));
17219 return eHAL_STATUS_RESOURCES;
17220 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017221 // Save the SME Session ID here. We need it while processing the preauth response
17222 pMac->ft.ftSmeContext.smeSessionId = sessionId;
Jeff Johnson295189b2012-06-20 16:38:30 -070017223 vos_mem_zero(pftPreAuthReq, auth_req_len);
17224
17225 pftPreAuthReq->pbssDescription = (tpSirBssDescription)vos_mem_malloc(
17226 sizeof(pBssDescription->length) + pBssDescription->length);
17227
17228 pftPreAuthReq->messageType = pal_cpu_to_be16(eWNI_SME_FT_PRE_AUTH_REQ);
17229
17230 pftPreAuthReq->preAuthchannelNum = pBssDescription->channelId;
17231
Kiet Lam64c1b492013-07-12 13:56:44 +053017232 vos_mem_copy((void *)&pftPreAuthReq->currbssId,
17233 (void *)pSession->connectedProfile.bssid, sizeof(tSirMacAddr));
17234 vos_mem_copy((void *)&pftPreAuthReq->preAuthbssId,
17235 (void *)pBssDescription->bssId, sizeof(tSirMacAddr));
Jeff Johnson295189b2012-06-20 16:38:30 -070017236
Jeff Johnson295189b2012-06-20 16:38:30 -070017237#ifdef WLAN_FEATURE_VOWIFI_11R
Madan Mohan Koyyalamudi5e32b962012-11-28 16:07:55 -080017238 if (csrRoamIs11rAssoc(pMac) &&
17239 (pMac->roam.roamSession[sessionId].connectedProfile.AuthType != eCSR_AUTH_TYPE_OPEN_SYSTEM))
Jeff Johnson295189b2012-06-20 16:38:30 -070017240 {
17241 pftPreAuthReq->ft_ies_length = (tANI_U16)pMac->ft.ftSmeContext.auth_ft_ies_length;
Kiet Lam64c1b492013-07-12 13:56:44 +053017242 vos_mem_copy(pftPreAuthReq->ft_ies, pMac->ft.ftSmeContext.auth_ft_ies,
17243 pMac->ft.ftSmeContext.auth_ft_ies_length);
Jeff Johnson295189b2012-06-20 16:38:30 -070017244 }
17245 else
17246#endif
17247 {
17248 pftPreAuthReq->ft_ies_length = 0;
17249 }
Madan Mohan Koyyalamudi613b0a42012-10-31 15:55:53 -070017250 vos_mem_copy(pftPreAuthReq->pbssDescription, pBssDescription,
17251 sizeof(pBssDescription->length) + pBssDescription->length);
17252 pftPreAuthReq->length = pal_cpu_to_be16(auth_req_len);
Jeff Johnson295189b2012-06-20 16:38:30 -070017253 return palSendMBMessage(pMac->hHdd, pftPreAuthReq);
17254}
Jeff Johnson295189b2012-06-20 16:38:30 -070017255/*--------------------------------------------------------------------------
17256 * This will receive and process the FT Pre Auth Rsp from the current
17257 * associated ap.
17258 *
17259 * This will invoke the hdd call back. This is so that hdd can now
17260 * send the FTIEs from the Auth Rsp (Auth Seq 2) to the supplicant.
17261 ------------------------------------------------------------------------*/
17262void csrRoamFTPreAuthRspProcessor( tHalHandle hHal, tpSirFTPreAuthRsp pFTPreAuthRsp )
17263{
17264 tpAniSirGlobal pMac = PMAC_STRUCT( hHal );
17265 eHalStatus status = eHAL_STATUS_SUCCESS;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017266#if defined(FEATURE_WLAN_LFR) || defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017267 tCsrRoamInfo roamInfo;
17268#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017269 eCsrAuthType conn_Auth_type;
Jeff Johnson295189b2012-06-20 16:38:30 -070017270
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017271#ifdef WLAN_FEATURE_NEIGHBOR_ROAMING
Srikant Kuppaa3ed0a32013-02-20 07:24:43 -080017272 status = csrNeighborRoamPreauthRspHandler(pMac, pFTPreAuthRsp->status);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017273 if (status != eHAL_STATUS_SUCCESS) {
17274 /*
17275 * Bail out if pre-auth was not even processed.
17276 */
Agarwal Ashishe3cca2a2013-07-21 03:01:48 +053017277 smsLog(pMac, LOGE,FL("Preauth was not processed: %d SessionID: %d"),
17278 status, pFTPreAuthRsp->smeSessionId);
Madan Mohan Koyyalamudi7a579cc2012-10-21 11:25:39 -070017279 return;
17280 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017281#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017282 /* The below function calls/timers should be invoked only if the pre-auth is successful */
17283 if (VOS_STATUS_SUCCESS != (VOS_STATUS)pFTPreAuthRsp->status)
17284 return;
Jeff Johnson295189b2012-06-20 16:38:30 -070017285 // Implies a success
17286 pMac->ft.ftSmeContext.FTState = eFT_AUTH_COMPLETE;
Jeff Johnson295189b2012-06-20 16:38:30 -070017287 // Indicate SME QoS module the completion of Preauth success. This will trigger the creation of RIC IEs
17288 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = pFTPreAuthRsp;
Sandeep Puligilla0c486ca2014-05-24 02:40:49 +053017289 /* No need to notify qos module if this is a non 11r & ESE roam*/
17290 if (csrRoamIs11rAssoc(pMac)
17291#if defined(FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_ESE_UPLOAD)
17292 || csrRoamIsESEAssoc(pMac)
17293#endif
17294 )
Tushnim Bhattacharyya8436d772013-06-26 23:03:29 -070017295 {
17296 sme_QosCsrEventInd(pMac, pMac->ft.ftSmeContext.smeSessionId, SME_QOS_CSR_PREAUTH_SUCCESS_IND, NULL);
17297 }
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053017298#ifdef DEBUG_ROAM_DELAY
17299 vos_record_roam_event(e_CACHE_ROAM_DELAY_DATA, NULL, 0);
17300#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017301 /* Start the pre-auth reassoc interval timer with a period of 400ms. When this expires,
17302 * actual transition from the current to handoff AP is triggered */
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017303 status = vos_timer_start(&pMac->ft.ftSmeContext.preAuthReassocIntvlTimer,
17304 60);
Mukul Sharmabe91e2f2014-06-29 22:09:20 +053017305#ifdef DEBUG_ROAM_DELAY
17306 vos_record_roam_event(e_SME_PREAUTH_REASSOC_START, NULL, 0);
17307#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017308 if (eHAL_STATUS_SUCCESS != status)
17309 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017310 smsLog(pMac, LOGE, FL("Preauth reassoc interval timer start failed to start with status %d"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017311 return;
17312 }
Jeff Johnson295189b2012-06-20 16:38:30 -070017313 // Save the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017314 vos_mem_copy((void *)&pMac->ft.ftSmeContext.preAuthbssId,
17315 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson295189b2012-06-20 16:38:30 -070017316 if (csrRoamIs11rAssoc(pMac))
17317 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, NULL, 0,
17318 eCSR_ROAM_FT_RESPONSE, eCSR_ROAM_RESULT_NONE);
17319
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017320#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
17321 if (csrRoamIsESEAssoc(pMac))
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017322 {
17323 /* read TSF */
17324 csrRoamReadTSF(pMac, (tANI_U8 *)roamInfo.timestamp);
17325
17326 // Save the bssid from the received response
Srinivas Girigowda6d1f9062014-02-03 18:15:54 -080017327 vos_mem_copy((void *)&roamInfo.bssid, (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017328 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_CCKM_PREAUTH_NOTIFY, 0);
17329 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017330#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017331#ifdef FEATURE_WLAN_LFR
17332 // If Legacy Fast Roaming is enabled, signal the supplicant
17333 // So he can send us a PMK-ID for this candidate AP.
Madan Mohan Koyyalamudi03aae5f2012-11-28 01:51:22 +053017334 if (csrRoamIsFastRoamEnabled(pMac, CSR_SESSION_ID_INVALID))
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017335 {
17336 // Save the bssid from the received response
Kiet Lam64c1b492013-07-12 13:56:44 +053017337 vos_mem_copy((void *)&roamInfo.bssid,
17338 (void *)pFTPreAuthRsp->preAuthbssId, sizeof(tCsrBssid));
Jeff Johnson04dd8a82012-06-29 20:41:40 -070017339 csrRoamCallCallback(pMac, pFTPreAuthRsp->smeSessionId, &roamInfo, 0, eCSR_ROAM_PMK_NOTIFY, 0);
17340 }
17341
17342#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070017343
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017344 // If its an Open Auth, FT IEs are not provided by supplicant
17345 // Hence populate them here
17346 conn_Auth_type = pMac->roam.roamSession[pMac->ft.ftSmeContext.smeSessionId].connectedProfile.AuthType;
17347 pMac->ft.ftSmeContext.addMDIE = FALSE;
17348 if( csrRoamIs11rAssoc(pMac) &&
17349 (conn_Auth_type == eCSR_AUTH_TYPE_OPEN_SYSTEM))
17350 {
17351 tANI_U16 ft_ies_length;
17352 ft_ies_length = pFTPreAuthRsp->ric_ies_length;
17353
17354 if ( (pMac->ft.ftSmeContext.reassoc_ft_ies) &&
17355 (pMac->ft.ftSmeContext.reassoc_ft_ies_length))
17356 {
17357 vos_mem_free(pMac->ft.ftSmeContext.reassoc_ft_ies);
17358 pMac->ft.ftSmeContext.reassoc_ft_ies_length = 0;
17359 }
17360
17361 pMac->ft.ftSmeContext.reassoc_ft_ies = vos_mem_malloc(ft_ies_length);
17362 if ( NULL == pMac->ft.ftSmeContext.reassoc_ft_ies )
17363 {
17364 smsLog( pMac, LOGE, FL("Memory allocation failed for ft_ies"));
17365 }
17366 else
17367 {
17368 // Copy the RIC IEs to reassoc IEs
17369 vos_mem_copy(((tANI_U8 *)pMac->ft.ftSmeContext.reassoc_ft_ies),
17370 (tANI_U8 *)pFTPreAuthRsp->ric_ies,
17371 pFTPreAuthRsp->ric_ies_length);
17372 pMac->ft.ftSmeContext.reassoc_ft_ies_length = ft_ies_length;
17373 pMac->ft.ftSmeContext.addMDIE = TRUE;
17374 }
17375 }
17376
Jeff Johnson295189b2012-06-20 16:38:30 -070017377 // Done with it, init it.
17378 pMac->ft.ftSmeContext.psavedFTPreAuthRsp = NULL;
17379}
17380#endif
Kanchanapally, Vidyullatha4f84f682014-04-29 20:40:34 +053017381
Jeff Johnson295189b2012-06-20 16:38:30 -070017382#ifdef FEATURE_WLAN_BTAMP_UT_RF
17383void csrRoamJoinRetryTimerHandler(void *pv)
17384{
17385 tCsrTimerInfo *pInfo = (tCsrTimerInfo *)pv;
17386 tpAniSirGlobal pMac = pInfo->pMac;
17387 tANI_U32 sessionId = pInfo->sessionId;
17388 tCsrRoamSession *pSession;
17389
17390 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17391 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017392 smsLog( pMac, LOGE, FL( " retrying the last roam profile on session %d" ), sessionId );
Jeff Johnson295189b2012-06-20 16:38:30 -070017393 pSession = CSR_GET_SESSION( pMac, sessionId );
17394 if(pSession->pCurRoamProfile && csrIsConnStateDisconnected(pMac, sessionId))
17395 {
17396 if( !HAL_STATUS_SUCCESS(csrRoamJoinLastProfile(pMac, sessionId)) )
17397 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017398 smsLog( pMac, LOGE, FL( " fail to retry the last roam profile" ) );
Jeff Johnson295189b2012-06-20 16:38:30 -070017399 }
17400 }
17401 }
17402}
Jeff Johnson295189b2012-06-20 16:38:30 -070017403eHalStatus csrRoamStartJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId, tANI_U32 interval)
17404{
17405 eHalStatus status = eHAL_STATUS_FAILURE;
17406 tCsrRoamSession *pSession = CSR_GET_SESSION( pMac, sessionId );
17407
17408 if(pSession->pCurRoamProfile && pSession->maxRetryCount)
17409 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017410 smsLog(pMac, LOGE, FL(" call sessionId %d retry count %d left"), sessionId, pSession->maxRetryCount);
Jeff Johnson295189b2012-06-20 16:38:30 -070017411 pSession->maxRetryCount--;
17412 pSession->joinRetryTimerInfo.pMac = pMac;
17413 pSession->joinRetryTimerInfo.sessionId = (tANI_U8)sessionId;
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017414 status = vos_timer_start(&pSession->hTimerJoinRetry, interval/PAL_TIMER_TO_MS_UNIT);
17415 if (!HAL_STATUS_SUCCESS(status))
Jeff Johnson295189b2012-06-20 16:38:30 -070017416 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017417 smsLog(pMac, LOGE, FL(" fail to start timer status %s"), status);
Jeff Johnson295189b2012-06-20 16:38:30 -070017418 }
17419 }
17420 else
17421 {
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017422 smsLog(pMac, LOGE, FL(" not to start timer due to no profile or reach mac ret (%d)"),
Jeff Johnson295189b2012-06-20 16:38:30 -070017423 pSession->maxRetryCount);
17424 }
17425
17426 return (status);
17427}
Jeff Johnson295189b2012-06-20 16:38:30 -070017428eHalStatus csrRoamStopJoinRetryTimer(tpAniSirGlobal pMac, tANI_U32 sessionId)
17429{
Kiran Kumar Lokere3334fbb2013-03-07 12:36:05 -080017430 smsLog(pMac, LOGE, " csrRoamStopJoinRetryTimer");
Jeff Johnson295189b2012-06-20 16:38:30 -070017431 if( CSR_IS_SESSION_VALID(pMac, sessionId) )
17432 {
Madan Mohan Koyyalamudia48c6812013-07-11 12:01:37 +053017433 return (vos_timer_stop(&pMac->roam.roamSession[sessionId].hTimerJoinRetry));
Jeff Johnson295189b2012-06-20 16:38:30 -070017434 }
17435
17436 return eHAL_STATUS_SUCCESS;
17437}
17438#endif
17439
17440
17441/*
17442 pBuf points to the beginning of the message
17443 LIM packs disassoc rsp as below,
17444 messageType - 2 bytes
17445 messageLength - 2 bytes
17446 sessionId - 1 byte
17447 transactionId - 2 bytes (tANI_U16)
17448 reasonCode - 4 bytes (sizeof(tSirResultCodes))
17449 peerMacAddr - 6 bytes
17450 The rest is conditionally defined of (WNI_POLARIS_FW_PRODUCT == AP) and not used
17451*/
17452static void csrSerDesUnpackDiassocRsp(tANI_U8 *pBuf, tSirSmeDisassocRsp *pRsp)
17453{
17454 if(pBuf && pRsp)
17455 {
17456 pBuf += 4; //skip type and length
17457 pRsp->sessionId = *pBuf++;
17458 pal_get_U16( pBuf, (tANI_U16 *)&pRsp->transactionId );
17459 pBuf += 2;
17460 pal_get_U32( pBuf, (tANI_U32 *)&pRsp->statusCode );
17461 pBuf += 4;
17462 vos_mem_copy(pRsp->peerMacAddr, pBuf, 6);
17463 }
17464}
17465
Jeff Johnsond13512a2012-07-17 11:42:19 -070017466eHalStatus csrGetDefaultCountryCodeFrmNv(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17467{
17468 static uNvTables nvTables;
17469 eHalStatus status = eHAL_STATUS_SUCCESS;
17470 VOS_STATUS vosStatus = vos_nv_readDefaultCountryTable( &nvTables );
17471
17472 /* read the country code from NV and use it */
17473 if ( VOS_IS_STATUS_SUCCESS(vosStatus) )
17474 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017475 vos_mem_copy(pCountry, nvTables.defaultCountryTable.countryCode,
17476 WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017477 return status;
17478 }
17479 else
17480 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017481 vos_mem_copy(pCountry, "XXX", WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017482 status = eHAL_STATUS_FAILURE;
17483 return status;
17484 }
17485}
17486
17487eHalStatus csrGetCurrentCountryCode(tpAniSirGlobal pMac, tANI_U8 *pCountry)
17488{
Kiet Lam64c1b492013-07-12 13:56:44 +053017489 vos_mem_copy(pCountry, pMac->scan.countryCode11d, WNI_CFG_COUNTRY_CODE_LEN);
Jeff Johnsond13512a2012-07-17 11:42:19 -070017490 return eHAL_STATUS_SUCCESS;
17491}
schang86c22c42013-03-13 18:41:24 -070017492
17493eHalStatus csrSetTxPower(tpAniSirGlobal pMac, v_U8_t sessionId, v_U8_t mW)
17494{
17495 tSirSetTxPowerReq *pMsg = NULL;
17496 eHalStatus status = eHAL_STATUS_SUCCESS;
17497 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17498
17499 if (!pSession)
17500 {
17501 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17502 return eHAL_STATUS_FAILURE;
17503 }
17504
Kiet Lam64c1b492013-07-12 13:56:44 +053017505 pMsg = vos_mem_malloc(sizeof(tSirSetTxPowerReq));
17506 if ( NULL == pMsg ) return eHAL_STATUS_FAILURE;
17507 vos_mem_set((void *)pMsg, sizeof(tSirSetTxPowerReq), 0);
17508 pMsg->messageType = eWNI_SME_SET_TX_POWER_REQ;
17509 pMsg->length = sizeof(tSirSetTxPowerReq);
17510 pMsg->mwPower = mW;
17511 vos_mem_copy((tSirMacAddr *)pMsg->bssId, &pSession->selfMacAddr,
17512 sizeof(tSirMacAddr));
17513 status = palSendMBMessage(pMac->hHdd, pMsg);
17514 if (!HAL_STATUS_SUCCESS(status))
schang86c22c42013-03-13 18:41:24 -070017515 {
Kiet Lam64c1b492013-07-12 13:56:44 +053017516 smsLog(pMac, LOGE, FL(" csr set TX Power Post MSG Fail %d "), status);
17517 //pMsg is freed by palSendMBMessage
schang86c22c42013-03-13 18:41:24 -070017518 }
17519 return status;
17520}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017521
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017522eHalStatus csrHT40StopOBSSScan(tpAniSirGlobal pMac, v_U8_t sessionId)
17523{
17524 tSirSmeHT40OBSSStopScanInd *pMsg = NULL;
17525 eHalStatus status = eHAL_STATUS_SUCCESS;
17526 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17527
17528 if (!pSession)
17529 {
17530 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17531 return eHAL_STATUS_FAILURE;
17532 }
17533 if(IS_HT40_OBSS_SCAN_FEATURE_ENABLE)
17534 {
17535 pMsg = vos_mem_malloc(sizeof(tSirSmeHT40OBSSStopScanInd));
Abhishek Singh11aa2902014-05-05 11:52:52 +053017536
17537 if( NULL == pMsg )
17538 {
17539 smsLog(pMac, LOGE, FL("PMsg is NULL "));
17540 return eHAL_STATUS_FAILURE;
17541 }
Sandeep Puligilla332ea912014-02-04 00:16:24 +053017542 vos_mem_zero((void *)pMsg, sizeof(tSirSmeHT40OBSSStopScanInd));
17543 pMsg->messageType = eWNI_SME_HT40_STOP_OBSS_SCAN_IND;
17544 pMsg->length = sizeof(tANI_U8);
17545 pMsg->seesionId = sessionId;
17546 status = palSendMBMessage(pMac->hHdd, pMsg);
17547 if (!HAL_STATUS_SUCCESS(status))
17548 {
17549 smsLog(pMac, LOGE, FL(" csr STOP OBSS SCAN Fail %d "), status);
17550 //pMsg is freed by palSendMBMessage
17551 }
17552 }
17553 else
17554 {
17555 smsLog(pMac, LOGE, FL(" OBSS STOP OBSS SCAN is not supported"));
17556 status = eHAL_STATUS_FAILURE;
17557 }
17558 return status;
17559}
Varun Reddy Yeturud0a3f252013-04-15 21:58:13 -070017560/* Returns whether a session is in VOS_STA_MODE...or not */
17561tANI_BOOLEAN csrRoamIsStaMode(tpAniSirGlobal pMac, tANI_U32 sessionId)
17562{
17563 tCsrRoamSession *pSession = NULL;
17564 pSession = CSR_GET_SESSION ( pMac, sessionId );
17565 if(!pSession)
17566 {
17567 smsLog(pMac, LOGE, FL(" %s: session %d not found "), __func__, sessionId);
17568 return eANI_BOOLEAN_FALSE;
17569 }
17570 if ( !CSR_IS_SESSION_VALID ( pMac, sessionId ) )
17571 {
17572 smsLog(pMac, LOGE, FL(" %s: Inactive session"), __func__);
17573 return eANI_BOOLEAN_FALSE;
17574 }
17575 if ( eCSR_BSS_TYPE_INFRASTRUCTURE != pSession->connectedProfile.BSSType )
17576 {
17577 return eANI_BOOLEAN_FALSE;
17578 }
17579 /* There is a possibility that the above check may fail,because
17580 * P2P CLI also uses the same BSSType (eCSR_BSS_TYPE_INFRASTRUCTURE)
17581 * when it is connected.So,we may sneak through the above check even
17582 * if we are not a STA mode INFRA station. So, if we sneak through
17583 * the above condition, we can use the following check if we are
17584 * really in STA Mode.*/
17585
17586 if ( NULL != pSession->pCurRoamProfile )
17587 {
17588 if ( pSession->pCurRoamProfile->csrPersona == VOS_STA_MODE )
17589 {
17590 return eANI_BOOLEAN_TRUE;
17591 } else {
17592 smsLog(pMac, LOGE, FL(" %s: pCurRoamProfile is NULL\n"), __func__);
17593 return eANI_BOOLEAN_FALSE;
17594 }
17595 }
17596
17597 return eANI_BOOLEAN_FALSE;
17598}
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017599
17600#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
17601eHalStatus csrHandoffRequest(tpAniSirGlobal pMac,
17602 tCsrHandoffRequest *pHandoffInfo)
17603{
17604 eHalStatus status = eHAL_STATUS_SUCCESS;
17605 vos_msg_t msg;
17606
17607 tAniHandoffReq *pMsg;
Kiet Lam64c1b492013-07-12 13:56:44 +053017608 pMsg = vos_mem_malloc(sizeof(tAniHandoffReq));
17609 if ( NULL == pMsg )
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017610 {
17611 smsLog(pMac, LOGE, " csrHandoffRequest: failed to allocate mem for req ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017612 return eHAL_STATUS_FAILURE;
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017613 }
17614 pMsg->msgType = pal_cpu_to_be16((tANI_U16)eWNI_SME_HANDOFF_REQ);
17615 pMsg->msgLen = (tANI_U16)sizeof(tAniHandoffReq);
17616 pMsg->sessionId = pMac->roam.neighborRoamInfo.csrSessionId;
17617 pMsg->channel = pHandoffInfo->channel;
Kiet Lam64c1b492013-07-12 13:56:44 +053017618 vos_mem_copy(pMsg->bssid,
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017619 pHandoffInfo->bssid,
17620 6);
17621 msg.type = eWNI_SME_HANDOFF_REQ;
17622 msg.bodyptr = pMsg;
17623 msg.reserved = 0;
17624 if(VOS_STATUS_SUCCESS != vos_mq_post_message(VOS_MQ_ID_SME, &msg))
17625 {
17626 smsLog(pMac, LOGE, " csrHandoffRequest failed to post msg to self ");
Kiet Lam64c1b492013-07-12 13:56:44 +053017627 vos_mem_free((void *)pMsg);
Varun Reddy Yeturucc661d22013-05-20 11:47:10 -070017628 status = eHAL_STATUS_FAILURE;
17629 }
17630 return status;
17631}
17632#endif /* WLAN_FEATURE_ROAM_SCAN_OFFLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017633
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017634
17635#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017636/* ---------------------------------------------------------------------------
17637 \fn csrSetCCKMIe
17638 \brief This function stores the CCKM IE passed by the supplicant in a place holder
17639 data structure and this IE will be packed inside reassociation request
17640 \param pMac - pMac global structure
17641 \param sessionId - Current session id
17642 \param pCckmIe - pointer to CCKM IE data
17643 \param ccKmIeLen - length of the CCKM IE
17644 \- return Success or failure
17645 -------------------------------------------------------------------------*/
17646VOS_STATUS csrSetCCKMIe(tpAniSirGlobal pMac, const tANI_U8 sessionId,
17647 const tANI_U8 *pCckmIe,
17648 const tANI_U8 ccKmIeLen)
17649{
17650 eHalStatus status = eHAL_STATUS_SUCCESS;
17651 tCsrRoamSession *pSession = CSR_GET_SESSION(pMac, sessionId);
17652
17653 if (!pSession)
17654 {
17655 smsLog(pMac, LOGE, FL(" session %d not found "), sessionId);
17656 return eHAL_STATUS_FAILURE;
17657 }
Kiet Lamf2f201e2013-11-16 21:24:16 +053017658 vos_mem_copy(pSession->suppCckmIeInfo.cckmIe, pCckmIe, ccKmIeLen);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017659 pSession->suppCckmIeInfo.cckmIeLen = ccKmIeLen;
17660 return status;
17661}
17662
17663/* ---------------------------------------------------------------------------
17664 \fn csrRoamReadTSF
17665 \brief This function reads the TSF; and also add the time elapsed since last beacon or
17666 probe response reception from the hand off AP to arrive at the latest TSF value.
17667 \param pMac - pMac global structure
17668 \param pTimestamp - output TSF timestamp
17669 \- return Success or failure
17670 -------------------------------------------------------------------------*/
17671VOS_STATUS csrRoamReadTSF(tpAniSirGlobal pMac, tANI_U8 *pTimestamp)
17672{
17673 eHalStatus status = eHAL_STATUS_SUCCESS;
17674 tCsrNeighborRoamBSSInfo handoffNode;
17675 tANI_U32 timer_diff = 0;
17676 tANI_U32 timeStamp[2];
17677 tpSirBssDescription pBssDescription = NULL;
17678
17679 csrNeighborRoamGetHandoffAPInfo(pMac, &handoffNode);
17680 pBssDescription = handoffNode.pBssDescription;
17681
17682 // Get the time diff in milli seconds
17683 timer_diff = vos_timer_get_system_time() - pBssDescription->scanSysTimeMsec;
17684 // Convert msec to micro sec timer
17685 timer_diff = (tANI_U32)(timer_diff * SYSTEM_TIME_MSEC_TO_USEC);
17686
17687 timeStamp[0] = pBssDescription->timeStamp[0];
17688 timeStamp[1] = pBssDescription->timeStamp[1];
17689
17690 UpdateCCKMTSF(&(timeStamp[0]), &(timeStamp[1]), &timer_diff);
17691
Kiet Lamf2f201e2013-11-16 21:24:16 +053017692 vos_mem_copy(pTimestamp, (void *) &timeStamp[0],
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017693 sizeof (tANI_U32) * 2);
17694 return status;
17695}
17696
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080017697#endif /*FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -070017698
Agarwal Ashish738843c2014-09-25 12:27:56 +053017699/* ---------------------------------------------------------------------------
17700 \fn csrDisableDfsChannel
17701 \brief This function will call csrApplyChannelPowerCountryInfo to
17702 \ to trim the list on basis of NO_DFS flag.
17703 \param pMac - pMac global structure
17704 \- return void
17705 -------------------------------------------------------------------------*/
17706void csrDisableDfsChannel(tpAniSirGlobal pMac)
17707{
17708 csrApplyChannelPowerCountryInfo( pMac, &pMac->scan.base20MHzChannels,
17709 pMac->scan.countryCodeCurrent, eANI_BOOLEAN_TRUE);
17710}