blob: b3889c0731c1a13852f67da982b9bc33c650f906 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05302 * Copyright (c) 2012-2016 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028/**========================================================================
29
30 \file wlan_hdd_assoc.c
31 \brief WLAN Host Device Driver implementation
Shailender Karmuchia734f332013-04-19 14:02:48 -070032
Jeff Johnson295189b2012-06-20 16:38:30 -070033 ========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070034/**=========================================================================
35 EDIT HISTORY FOR FILE
36
37
38 This section contains comments describing changes made to the module.
39 Notice that changes are listed in reverse chronological order.
40
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070046 -------- --- --------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -070047 05/06/09 Shailender Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070048 ==========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070049
Jeff Johnson295189b2012-06-20 16:38:30 -070050#include "wlan_hdd_includes.h"
51#include <aniGlobal.h>
52#include "dot11f.h"
53#include "wlan_nlink_common.h"
54#include "wlan_btc_svc.h"
55#include "wlan_hdd_power.h"
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +053056#include "wlan_hdd_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070057#include <linux/ieee80211.h>
58#include <linux/wireless.h>
59#include <net/cfg80211.h>
60#include "wlan_hdd_cfg80211.h"
61#include "csrInsideApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include "wlan_hdd_p2p.h"
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053063#include <vos_sched.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080064#include "wlan_hdd_tdls.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "sme_Api.h"
Sushant Kaushikba6764e2014-06-30 19:52:09 +053066#include "wlan_hdd_hostapd.h"
Mukul Sharma84f27252014-07-14 18:11:42 +053067#include "vos_utils.h"
Siddharth Bhalda0d1622015-04-24 15:47:49 +053068#include <wlan_hdd_wext.h>
Mukul Sharma84f27252014-07-14 18:11:42 +053069
Jeff Johnson295189b2012-06-20 16:38:30 -070070v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
71
Shailender Karmuchia734f332013-04-19 14:02:48 -070072struct ether_addr
Jeff Johnson295189b2012-06-20 16:38:30 -070073{
74 u_char ether_addr_octet[6];
75};
76// These are needed to recognize WPA and RSN suite types
77#define HDD_WPA_OUI_SIZE 4
78v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
79v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
80v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
81v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
82v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
83v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080084#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070085v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080086#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070087#define HDD_RSN_OUI_SIZE 4
88v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
89v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
90v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
91v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
92v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
93v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080094#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070095v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080096#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -070097#ifdef WLAN_FEATURE_11W
98v_U8_t ccpRSNOui07[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x06 }; // RSN-PSK-SHA256
Abhishek Singhae408032014-09-25 17:22:04 +053099/* RSN-8021X-SHA256 */
100v_U8_t ccpRSNOui08[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 };
Chet Lanctot186b5732013-03-18 10:26:30 -0700101#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700102
Shailender Karmuchia734f332013-04-19 14:02:48 -0700103#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700104// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700105#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
106#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700107#endif
108
109#define BEACON_FRAME_IES_OFFSET 12
110
Chet Lanctot186b5732013-03-18 10:26:30 -0700111#ifdef WLAN_FEATURE_11W
112void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
113 tANI_U32 nFrameLength,
114 tANI_U8* pbFrames,
115 tANI_U8 frameType );
116#endif
117
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800118#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700119static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
120 tANI_U8 state,
121 tANI_U16 measInterval );
122static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800123static void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
124static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700125
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800126#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700127
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530128static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
129 tCsrRoamInfo *pRoamInfo,
130 tANI_U32 roamId,
131 eRoamCmdStatus roamStatus,
132 eCsrRoamResult roamResult );
133
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530134v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
135 eConnectionState connState )
136{
137 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530138 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
139 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700140 pHddStaCtx->conn_info.connState = connState;
141}
142
143// returns FALSE if not connected.
144// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
145// returns the connection state. Can specify NULL if you dont' want to get the actual state.
146
Shailender Karmuchia734f332013-04-19 14:02:48 -0700147static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
148 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700149{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700150 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700152
Jeff Johnson295189b2012-06-20 16:38:30 -0700153 // get the connection state.
154 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700155 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700156 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700157 eConnectionState_IbssConnected == connState ||
158 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700159 {
160 fConnected = VOS_TRUE;
161 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700162 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700163 {
164 fConnected = VOS_FALSE;
165 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700166
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 if ( pConnState )
168 {
169 *pConnState = connState;
170 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700171
Jeff Johnson295189b2012-06-20 16:38:30 -0700172 return( fConnected );
173}
174
175v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
176{
177 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700178}
Jeff Johnson295189b2012-06-20 16:38:30 -0700179
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530180eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx )
181{
182 v_U8_t staChannel = 0;
183
184 if ( eConnectionState_Associated == pHddStaCtx->conn_info.connState )
185 {
186 staChannel = pHddStaCtx->conn_info.operationChannel;
187 }
188
189 if ( staChannel > 0 && staChannel < 14 )
190 return eCSR_BAND_24;
191 else if (staChannel >= 36 && staChannel <= 165 )
192 return eCSR_BAND_5G;
193 else /* If station is not connected return as eCSR_BAND_ALL */
194 return eCSR_BAND_ALL;
195}
196
197
Jeff Johnson295189b2012-06-20 16:38:30 -0700198//TODO - Not used anyhwere. Can be removed.
199#if 0
200//
201v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
202{
203 v_BOOL_t fConnectedInfra = FALSE;
204 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700205
Jeff Johnson295189b2012-06-20 16:38:30 -0700206 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700207 {
208 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700209 {
210 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700211 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700212 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700213
Jeff Johnson295189b2012-06-20 16:38:30 -0700214 return( fConnectedInfra );
215}
216#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700217
Jeff Johnson295189b2012-06-20 16:38:30 -0700218static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
219{
220 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700221
Jeff Johnson295189b2012-06-20 16:38:30 -0700222 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700223
224 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700225 {
226 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
227 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700228
Jeff Johnson295189b2012-06-20 16:38:30 -0700229 return( fConnected );
230}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700231
Jeff Johnson295189b2012-06-20 16:38:30 -0700232inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
233{
234 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700235
Jeff Johnson295189b2012-06-20 16:38:30 -0700236 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700237
238 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 {
240 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
241 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700242
Jeff Johnson295189b2012-06-20 16:38:30 -0700243 return( fConnected );
244}
245
246static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
247{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700248 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700249 {
250 case eCSR_BSS_TYPE_INFRASTRUCTURE:
251 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
252 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700253
Jeff Johnson295189b2012-06-20 16:38:30 -0700254 case eCSR_BSS_TYPE_IBSS:
255 case eCSR_BSS_TYPE_START_IBSS:
256 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
257 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700258
259 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700260 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700261 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700262 default:
263 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700264 break;
265 }
266
Jeff Johnson295189b2012-06-20 16:38:30 -0700267}
268
269void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
270{
271 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
272 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700273
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700275
276 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700277 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700278 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700279 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
280 {
281 VOS_ASSERT( pRoamInfo->pBssDesc );
282 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
283
284 // Save the Station ID for this station from the 'Roam Info'.
285 //For IBSS mode, staId is assigned in NEW_PEER_IND
286 //For reassoc, the staID doesn't change and it may be invalid in this structure
287 //so no change here.
288 if( !pRoamInfo->fReassocReq )
289 {
290 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
291 }
292 }
293 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700294 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700295 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700296 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 else
298 {
299 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
300 // or we can't function.
301 VOS_ASSERT( 0 );
302 }
303
304 // notify WMM
305 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
306
307 if( !pRoamInfo->u.pConnectedProfile )
308 {
309 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
310 }
311 else
312 {
313 // Get Multicast Encryption Type
314 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
315 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
316 // Get Unicast Encrytion Type
317 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
318 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
319
320 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
321
322 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
323
324 // Save the ssid for the connection
325 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530326
327 // Save dot11mode in which STA associated to AP
328 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Deepthi Gowriae6a1662015-10-12 12:59:37 +0530329
330 pHddStaCtx->conn_info.rate_flags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700332 }
333
Jeff Johnson295189b2012-06-20 16:38:30 -0700334 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700335 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
336
Jeff Johnson295189b2012-06-20 16:38:30 -0700337}
338
339#if defined(WLAN_FEATURE_VOWIFI_11R)
340/*
341 * Send the 11R key information to the supplicant.
342 * Only then can the supplicant generate the PMK-R1.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800343 * (BTW, the ESE supplicant also needs the Assoc Resp IEs
Jeff Johnson295189b2012-06-20 16:38:30 -0700344 * for the same purpose.)
345 *
346 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
347 * this contains the R1KHID, R0KHID and the MDID.
348 * For FT, this consists of the Reassoc Rsp FTIEs.
349 * This is the Assoc Response.
350 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700351static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700352 tCsrRoamInfo *pCsrRoamInfo)
353{
354 union iwreq_data wrqu;
355 char *buff;
356 unsigned int len = 0;
357 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700358
359 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700360 {
361 hddLog(LOGE,
362 "%s: pCsrRoamInfo->nAssocRspLength=%d",
363 __func__, (int)pCsrRoamInfo->nAssocRspLength);
364 return;
365 }
366
Shailender Karmuchia734f332013-04-19 14:02:48 -0700367 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700368 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700369 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700370 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700371 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 return;
373 }
374
375 // pFTAssocRsp needs to point to the IEs
376 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
377 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
378 (unsigned int)pFTAssocRsp[0],
379 (unsigned int)pFTAssocRsp[1]);
380
381 // We need to send the IEs to the supplicant.
382 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700383 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700384 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700385 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700386 return;
387 }
388
389 // Send the Assoc Resp, the supplicant needs this for initial Auth.
390 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700391 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700392 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700393 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700394 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
395
396 kfree(buff);
397}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700398#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700399
400#ifdef WLAN_FEATURE_VOWIFI_11R
401
402/*---------------------------------------------------
403 *
404 * Send the FTIEs, RIC IEs during FT. This is eventually
405 * used to send the FT events to the supplicant
406 *
407 * At the reception of Auth2 we send the RIC followed
408 * by the auth response IEs to the supplicant.
409 * Once both are received in the supplicant, an FT
410 * event is generated to the supplicant.
411 *
412 *---------------------------------------------------
413 */
414void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
415{
Jeff Johnson295189b2012-06-20 16:38:30 -0700416 tANI_U16 auth_resp_len = 0;
417 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700418 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
419
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530420#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700421 struct cfg80211_ft_event_params ftEvent;
422 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
423 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
424 struct net_device *dev = pAdapter->dev;
425#else
426 char *buff;
427 union iwreq_data wrqu;
428 tANI_U16 str_len;
429#endif
430
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530431#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530432 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
433 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700434
Kanchanapally, Vidyullatha31b8d142015-01-30 14:25:18 +0530435 sme_GetRICIEs(pHddCtx->hHal, (u8 *)ricIe,
436 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530437 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700438 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530439 hddLog(LOGW,
440 "%s: RIC IEs is of length 0 not sending RIC Information for now",
441 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700442 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700443
444 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530445 ftEvent.ric_ies_len = ric_ies_length;
446 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700447
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530448 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800449 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700450
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530451 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700452 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530453 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700454 return;
455 }
456
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530457 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530458
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530459 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700460
461 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
462 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
463
Jeff Johnson59a121e2013-11-30 09:46:08 -0800464 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
465 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
466 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530467 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800468 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
469 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
470 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700471
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530472 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700473
474#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530475 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -0700476 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530477 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530479 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700480 return;
481 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530482 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700483
Shailender Karmuchia734f332013-04-19 14:02:48 -0700484 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -0700485 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530486 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800487 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530488 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700489 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530490 hddLog(LOGW,
491 "%s: RIC IEs is of length 0 not sending RIC Information for now",
492 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700493 }
494 else
495 {
496 wrqu.data.length = str_len + ric_ies_length;
497 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
498 }
499
500 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530501 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530503 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
504 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700505
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530506 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530508 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Bhargav Shah8b5b2f72015-07-14 11:53:46 +0530509 kfree(buff);
Jeff Johnson295189b2012-06-20 16:38:30 -0700510 return;
511 }
512
513 wrqu.data.length = str_len + auth_resp_len;
514 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
515
516 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700517#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700518}
519
520#endif /* WLAN_FEATURE_VOWIFI_11R */
521
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800522#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700523
524/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800525 * Send the ESE required "new AP Channel info" to the supplicant.
Jeff Johnson295189b2012-06-20 16:38:30 -0700526 * (This keeps the supplicant "up to date" on the current channel.)
527 *
528 * The current (new AP) channel information is passed in.
529 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700530static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700531 tCsrRoamInfo *pCsrRoamInfo)
532{
533 union iwreq_data wrqu;
534 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700535
Shailender Karmuchia734f332013-04-19 14:02:48 -0700536
537 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700538 {
539 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800540 "%s: pCsrRoamInfo->pBssDesc=%p",
Jeff Johnson295189b2012-06-20 16:38:30 -0700541 __func__, descriptor);
542 return;
543 }
544
545 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -0800546 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700547 memset(&wrqu, '\0', sizeof(wrqu));
548 wrqu.freq.m = descriptor->channelId;
549 wrqu.freq.e = 0;
550 wrqu.freq.i = 0;
551 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
552}
553
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800554#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700555
556void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
557{
558 union iwreq_data wrqu;
559 u8 *pBeaconIes;
560 u8 currentLen = 0;
561 char *buff;
562 int totalIeLen = 0, currentOffset = 0, strLen;
563
564 memset(&wrqu, '\0', sizeof(wrqu));
565
566 if (0 == pCsrRoamInfo->nBeaconLength)
567 {
568 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
569 return;
570 }
571 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700572 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700574 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700575 return;
576 }
577
578 // pBeaconIes needs to point to the IEs
579 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
580 (unsigned int)pBeaconIes[0],
581 (unsigned int)pBeaconIes[1]);
582 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700583
Jeff Johnson295189b2012-06-20 16:38:30 -0700584 // We need to send the IEs to the supplicant.
585 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700586 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700588 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700589 return;
590 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700591 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700592
593 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
594 currentLen = strLen + 1;
595
596 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
597 do
598 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700599 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -0700600 * max size and send it to supplicant. Changes are done in supplicant to handle this */
601 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
602 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
603 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
604 currentOffset += currentLen;
605 totalIeLen -= currentLen;
606 wrqu.data.length = strLen + 1 + currentLen;
607 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700608 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -0700609 else
610 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
611
612 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
613 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
614 } while (totalIeLen > 0);
615
616 kfree(buff);
617}
618
619static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
620{
621 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
622 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
623 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
624 union iwreq_data wrqu;
625 int we_event;
626 char *msg;
627 int type = -1;
628
Shailender Karmuchia734f332013-04-19 14:02:48 -0700629#if defined (WLAN_FEATURE_VOWIFI_11R)
630 // Added to find the auth type on the fly at run time
631 // rather than with cfg to see if FT is enabled
632 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700633 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
634#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700635
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -0700637 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700639
Jeff Johnson295189b2012-06-20 16:38:30 -0700640 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
641 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530642 /* In case of roaming ; We are not doing disconnect.
643 * If disconnect is not being done for roam; We will not
644 * decrease count for Active sessions. We should not increase active
645 * active session in case of roaming.
646 */
Padma, Santhosh Kumar87ba40f2014-11-26 19:40:15 +0530647 if((pHddStaCtx->ft_carrier_on == FALSE) && !pCsrRoamInfo->fReassocReq)
Agarwal Ashish51325b52014-06-16 16:50:49 +0530648 {
649 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
650 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700651 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
652 type = WLAN_STA_ASSOC_DONE_IND;
653
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700654#ifdef WLAN_FEATURE_P2P_DEBUG
655 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
656 {
657 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
658 {
659 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
660 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
661 "Connecting state to Connected State for 8-way "
662 "Handshake");
663 }
664 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
665 {
666 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
667 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
668 "Connecting state to P2P Client Connection Completed");
669 }
670 }
671#endif
Sushant Kaushikdc3184b2015-10-09 12:00:21 +0530672 hddLog(VOS_TRACE_LEVEL_ERROR, MAC_ADDRESS_STR " connected to "
673 MAC_ADDRESS_STR,
Arif Hussain77d044f2014-01-03 19:56:04 -0800674 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
Kiet Lam34947452014-01-21 23:23:40 -0800675 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700676 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
677
Bhargav Shahd0715912015-10-01 18:17:37 +0530678 hdd_manage_delack_timer(pHddCtx);
679
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
681 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
682 * and fFTEnable is TRUE */
683#ifdef WLAN_FEATURE_VOWIFI_11R
684 // Send FT Keys to the supplicant when FT is enabled
685 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700686 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800687#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700688 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
689 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
690#endif
691 )
692 {
693 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
694 }
695#endif
696 }
697 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
698 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530699 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -0700700 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700701 type = WLAN_STA_ASSOC_DONE_IND;
Deepthi Gowric7591cc2015-12-28 15:43:17 +0530702
703 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
704 "wlan: new IBSS connection to " MAC_ADDRESS_STR,
705 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700706 }
707 else /* Not Associated */
708 {
Deepthi Gowric7591cc2015-12-28 15:43:17 +0530709 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
710 "wlan: disconnected");
Jeff Johnson295189b2012-06-20 16:38:30 -0700711 type = WLAN_STA_DISASSOC_DONE_IND;
712 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
Bhargav Shahd0715912015-10-01 18:17:37 +0530713
714 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700715 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700716 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700717
718 msg = NULL;
719 /*During the WLAN uninitialization,supplicant is stopped before the
720 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530721 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 {
723 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800724#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700725 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700726 {
727 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
728 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700729 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
730 }
731#endif
732 }
733 send_btc_nlink_msg(type, 0);
734}
735
736void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
737{
738 // Remove staId, bssId and peerMacAddress
739 pHddStaCtx->conn_info.staId [ 0 ] = 0;
740 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
741 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
742
743 // Clear all security settings
744 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
745 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
746 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
747
748 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700749 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700750
751 // Set not-connected state
752 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -0700753
754 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
755}
Katya Nigam47528772015-02-11 12:24:49 +0530756
757VOS_STATUS hdd_ibss_deinit_tx_rx_sta ( hdd_adapter_t *pAdapter, v_U8_t STAId )
758{
Katya Nigam1fd24402015-02-16 14:52:19 +0530759 v_U8_t ac;
760 /**Track whether OS TX queue has been disabled.*/
761 v_BOOL_t txSuspended[NUM_TX_QUEUES];
762 v_U8_t tlAC;
Katya Nigam47528772015-02-11 12:24:49 +0530763 v_U8_t i;
764 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
765 hdd_ibss_peer_info_t *pPeerInfo;
766
767 if( NULL == pHddStaCtx )
768 {
769 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
770 "%s: HDD station context NULL ",__func__);
771 return VOS_STATUS_E_FAILURE;
772 }
Katya Nigam1fd24402015-02-16 14:52:19 +0530773
Katya Nigam47528772015-02-11 12:24:49 +0530774 pPeerInfo = &pHddStaCtx->ibss_peer_info;
775 if (FALSE == pPeerInfo->ibssStaInfo[STAId].isUsed)
776 {
777 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
778 "%s: Deinit station not inited %d", __func__, STAId );
779 return VOS_STATUS_E_FAILURE;
780 }
781
782 hdd_flush_ibss_tx_queues(pAdapter, STAId);
Katya Nigam1fd24402015-02-16 14:52:19 +0530783
784 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
785 {
786 tlAC = hdd_QdiscAcToTlAC[ac];
787 txSuspended[ac] = pPeerInfo->ibssStaInfo[STAId].txSuspended[tlAC];
788 }
789
Katya Nigam47528772015-02-11 12:24:49 +0530790 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
791
Katya Nigam1fd24402015-02-16 14:52:19 +0530792 /* re-init hdd list, since netdev can still open adapter until
793 * driver gets unloaded
794 */
795 for (i = 0; i < NUM_TX_QUEUES; i ++)
796 {
797 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i],
798 HDD_TX_QUEUE_MAX_LEN);
799 }
800
801 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
802 {
803 if (txSuspended[ac])
804 {
805 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
806 "%s: TX queue re-enabled", __func__);
807 netif_wake_subqueue(pAdapter->dev, ac);
808 }
809 }
Katya Nigam47528772015-02-11 12:24:49 +0530810 return VOS_STATUS_SUCCESS;
811}
812
813static VOS_STATUS hdd_ibss_DeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
814{
815 VOS_STATUS vosStatus;
816
817 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
818 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
819 {
820 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
821 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
822 "Status= %d [0x%08X]",
823 __func__, staId, vosStatus, vosStatus );
824 }
825
826 vosStatus = hdd_ibss_deinit_tx_rx_sta ( pAdapter, staId );
827 if( VOS_STATUS_E_FAILURE == vosStatus )
828 {
829 VOS_TRACE ( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
830 "hdd_ibss_deinit_tx_rx_sta() failed for staID %d. "
831 "Status = %d [0x%08X]",
832 staId, vosStatus, vosStatus );
833 }
834
835 return( vosStatus );
836}
837
838VOS_STATUS hdd_ibss_init_tx_rx_sta( hdd_adapter_t *pAdapter, v_U8_t STAId, v_MACADDR_t *pmacAddrSTA)
839{
840 v_U8_t i = 0;
841 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
842 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
843
844 if (pPeerInfo->ibssStaInfo[STAId].isUsed)
845 {
846 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
847 "%s: Reinit station %d", __func__, STAId );
848 return VOS_STATUS_E_FAILURE;
849 }
850
851 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
852 for (i = 0; i < NUM_TX_QUEUES; i ++)
853 {
854 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i], HDD_TX_QUEUE_MAX_LEN);
855 }
856
857 pPeerInfo->ibssStaInfo[STAId].isUsed = VOS_TRUE;
858 pPeerInfo->ibssStaInfo[STAId].isDeauthInProgress = VOS_FALSE;
859 vos_copy_macaddr( &pPeerInfo->ibssStaInfo[STAId].macAddrSTA, pmacAddrSTA);
860
861 return VOS_STATUS_SUCCESS;
862}
863
864static VOS_STATUS hdd_ibss_RegisterSTA( hdd_adapter_t *pAdapter,
865 tCsrRoamInfo *pRoamInfo,
866 v_U8_t staId,
867 v_MACADDR_t *pPeerMacAddress,
868 tSirBssDescription *pBssDesc )
869{
870 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
871 WLAN_STADescType staDesc = {0};
872 eCsrEncryptionType connectedCipherAlgo;
873 v_BOOL_t fConnected;
874 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
875 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
876 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
877
878 if ( pPeerInfo->ibssStaInfo[staId].isUsed )
879 {
880 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
881 "clean up old entry for STA %d", staId);
882 hdd_ibss_DeregisterSTA( pAdapter, staId );
883 }
884
885 staDesc.ucSTAId = staId;
886 staDesc.wSTAType = WLAN_STA_IBSS;
887
888 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
889 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
890 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
891 // pass when making an Infrastructure connection.
892 vos_mem_copy(staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes));
893 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId, 6 );
894 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
895
896 if (hdd_wmm_is_active(pAdapter))
897 {
898 staDesc.ucQosEnabled = 1;
899 }
900 else
901 {
902 staDesc.ucQosEnabled = 0;
903 }
904 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
905 "HDD SOFTAP register TL QoS_enabled=%d",
906 staDesc.ucQosEnabled );
907
908 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
909 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
910 {
911 staDesc.ucProtectedFrame = 1;
912 }
913 else
914 {
915 staDesc.ucProtectedFrame = 0;
916
917 }
918
919 hdd_ibss_init_tx_rx_sta(pAdapter, staId, &staDesc.vSTAMACAddress);
920
921 // UMA is Not ready yet, Xlation will be done by TL
922 staDesc.ucSwFrameTXXlation = 1;
923 staDesc.ucSwFrameRXXlation = 1;
924 staDesc.ucAddRmvLLC = 1;
925 // Initialize signatures and state
926 staDesc.ucUcastSig = pRoamInfo->ucastSig;
927 staDesc.ucBcastSig = pRoamInfo->bcastSig;
928 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED;
929
930 staDesc.ucIsReplayCheckValid = VOS_FALSE;
931
932 // Register the Station with TL.
933 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
934 hdd_rx_packet_cbk,
935 hdd_tx_complete_cbk,
936 hdd_ibss_tx_fetch_packet_cbk, &staDesc,
937 pBssDesc->rssi );
938 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
939 {
940 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
941 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
942 vosStatus, vosStatus );
943 return vosStatus;
944 }
945
946 //Timer value should be in milliseconds
947 if ( pHddCtx->cfg_ini->dynSplitscan &&
948 ( VOS_TIMER_STATE_RUNNING !=
949 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
950 {
951 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
952 pHddCtx->cfg_ini->trafficMntrTmrForSplitScan);
953 }
954
955 pPeerInfo->ibssStaInfo[staId].ucSTAId = staId;
956 pPeerInfo->ibssStaInfo[staId].isQosEnabled = staDesc.ucQosEnabled;
957
958 vosStatus = WLANTL_ChangeSTAState( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staDesc.ucSTAId,
959 WLANTL_STA_AUTHENTICATED );
960
961 pPeerInfo->ibssStaInfo[staId].tlSTAState = WLANTL_STA_AUTHENTICATED;
962 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
963
964 return( vosStatus );
965}
966
Jeff Johnson295189b2012-06-20 16:38:30 -0700967/* TODO Revist this function. and data path */
968static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
969{
970 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700971
Katya Nigam47528772015-02-11 12:24:49 +0530972 hdd_disconnect_tx_rx(pAdapter);
Ravi Joshif9520d62013-10-18 04:11:46 -0700973
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
975 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
976 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530977 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700979 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700980 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700981 }
982 return( vosStatus );
983}
984
985
986static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
987 tANI_U32 roamId, eRoamCmdStatus roamStatus,
988 eCsrRoamResult roamResult )
989{
990 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700991 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700992 struct net_device *dev = pAdapter->dev;
993 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
994 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700995 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530996 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700997
998 // Sanity check
999 if(dev == NULL)
1000 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05301001 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001002 "%s: net_dev is released return", __func__);
1003 return eHAL_STATUS_FAILURE;
1004 }
1005
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301007 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 netif_tx_disable(dev);
1009 netif_carrier_off(dev);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +05301010 //TxTimeoutCount need to reset in case of disconnect handler
1011 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001012
Jeff Johnsone7245742012-09-05 17:12:55 -07001013 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301014 /* If only STA mode is on */
1015 if((pHddCtx->concurrency_mode <= 1) &&
1016 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
1017 {
1018 pHddCtx->isAmpAllowed = VOS_TRUE;
1019 }
1020
Agarwal Ashish47d18112014-08-04 19:55:07 +05301021 /* Need to apply spin lock before decreasing active sessions
1022 * as there can be chance for double decrement if context switch
1023 * Calls wlan_hdd_disconnect.
1024 */
1025
1026 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singh087de602015-10-21 17:18:55 +05301027
1028 /* HDD has initiated disconnect, do not send disconnect indication
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301029 * to kernel. Sending disconnected event to kernel for userspace
1030 * initiated disconnect will be handled by diconnect handler call
1031 * to cfg80211_disconnected
Abhishek Singh087de602015-10-21 17:18:55 +05301032 */
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301033 if ((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
1034 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301035 {
1036 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1037 FL(" HDD has initiated a disconnect, no need to send"
1038 " disconnect indication to kernel"));
1039 sendDisconInd = FALSE;
1040 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301041 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -07001042 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301043 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singh087de602015-10-21 17:18:55 +05301044 FL("Set HDD connState to eConnectionState_Disconnecting from %d "),
Agarwal Ashish47d18112014-08-04 19:55:07 +05301045 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301046 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
1047 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 }
Agarwal Ashish47d18112014-08-04 19:55:07 +05301049 spin_unlock_bh(&pAdapter->lock_for_active_session);
1050
Jeff Johnson295189b2012-06-20 16:38:30 -07001051 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -07001052
1053 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07001054
1055 // indicate 'disconnect' status to wpa_supplicant...
1056 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001057 /* indicate disconnected event to nl80211 */
1058 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
1059 {
1060 /*During the WLAN uninitialization,supplicant is stopped before the
1061 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301062 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001063 {
Sushant Kaushik0b343422015-05-25 17:15:55 +05301064 if (sendDisconInd)
1065 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1066 "%s: sent disconnected event to nl80211",
1067 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001068#ifdef WLAN_FEATURE_P2P_DEBUG
1069 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1070 {
1071 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
1072 {
1073 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
1074 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
1075 "and moved to disconnected state");
1076 }
1077 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
1078 {
1079 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
1080 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
1081 "and moved to inactive state");
1082 }
1083 }
1084#endif
Sushant Kaushikbad61892015-07-10 16:43:28 +05301085 if ((roamStatus == eCSR_ROAM_LOSTLINK) &&
1086 !pRoamInfo->reasonCode)
1087 wlan_hdd_get_frame_logs(pAdapter,
1088 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301089 /*Only send indication to kernel if not initiated by kernel*/
1090 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -07001091 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301092 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
1093 if ( eCSR_ROAM_LOSTLINK == roamStatus )
1094 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301095 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
1096 pRoamInfo->reasonCode);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301097 }
1098 else
1099 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301100 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301101 WLAN_REASON_UNSPECIFIED);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301104
1105 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1106 {
1107 hddLog(LOG1,
1108 FL("P2P client is getting removed and we are tryig to re-enable TDLS"));
1109 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301110 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301111
Jeff Johnson295189b2012-06-20 16:38:30 -07001112 //If the Device Mode is Station
1113 // and the P2P Client is Connected
1114 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001115
1116 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001117 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07001118 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -07001119 {
1120 //Enable BMPS only of other Session is P2P Client
1121 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001122 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001123
1124 if (NULL != pVosContext)
1125 {
1126 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1127
1128 if(NULL != pHddCtx)
1129 {
1130 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301131 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1132 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301134 if (pHddCtx->hdd_wlan_suspended)
1135 {
1136 hdd_set_pwrparams(pHddCtx);
1137 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301139 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001140 }
1141 }
1142 }
1143 }
1144 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001145
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +05301146 hdd_wmm_adapter_clear(pAdapter);
Mukul Sharmac159c432014-01-15 15:42:46 +05301147#if defined(WLAN_FEATURE_VOWIFI_11R)
1148 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
1149#endif
Katya Nigam63ce1772014-09-26 15:53:49 +05301150
1151 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
1152 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301153 v_U8_t i;
1154
Katya Nigam63ce1772014-09-26 15:53:49 +05301155 sta_id = IBSS_BROADCAST_STAID;
Katya Nigam47528772015-02-11 12:24:49 +05301156 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Katya Nigam63ce1772014-09-26 15:53:49 +05301157 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1158 {
1159 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301160 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1161 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +05301162 sta_id, status, status );
1163
1164 status = eHAL_STATUS_FAILURE;
1165 }
Katya Nigam63ce1772014-09-26 15:53:49 +05301166 pHddCtx->sta_to_adapter[sta_id] = NULL;
1167
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301168 /*Clear all the peer sta register with TL.*/
1169 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
1170 {
1171 if (0 != pHddStaCtx->conn_info.staId[i])
1172 {
1173 sta_id = pHddStaCtx->conn_info.staId[i];
1174
1175 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1176 FL("Deregister StaID %d"),sta_id);
Katya Nigam47528772015-02-11 12:24:49 +05301177 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301178 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1179 {
1180 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1181 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1182 "Status= %d [0x%x]"),
1183 sta_id, status, status );
1184 status = eHAL_STATUS_FAILURE;
1185 }
1186
Nirav Shah7e3c8132015-06-22 23:51:42 +05301187 vstatus = hdd_sta_id_hash_remove_entry(pAdapter,
1188 sta_id, &pHddStaCtx->conn_info.peerMacAddress[i]);
1189 if (vstatus != VOS_STATUS_SUCCESS) {
1190 hddLog(VOS_TRACE_LEVEL_ERROR,
1191 FL("Not able to remove staid hash %d"),
1192 sta_id);
1193 status = eHAL_STATUS_FAILURE;
1194 } else {
1195 hddLog(VOS_TRACE_LEVEL_INFO,
1196 FL("ibss station removed sta_id %d mac:"
1197 MAC_ADDRESS_STR), sta_id,
1198 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[i].bytes));
1199 }
1200
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301201 /*set the staid and peer mac as 0, all other reset are
1202 * done in hdd_connRemoveConnectInfo.
1203 */
1204 pHddStaCtx->conn_info.staId[i]= 0;
1205 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
1206
1207 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1208 pHddCtx->sta_to_adapter[sta_id] = NULL;
1209 }
1210 }
1211
Katya Nigam63ce1772014-09-26 15:53:49 +05301212 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301213 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001214 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301215 sta_id = pHddStaCtx->conn_info.staId[0];
1216
1217 //We should clear all sta register with TL, for now, only one.
1218 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
1219 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1220 {
1221 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1222 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1223 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -07001224 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001225
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301226 status = eHAL_STATUS_FAILURE;
1227 }
1228
1229 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001230 }
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301231
1232#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1233 if (VOS_STATUS_SUCCESS !=
1234 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1235 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE_AC))
1236 {
1237 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1238 "WLANTL_ClearInterfaceStats Failed", __func__);
1239 }
1240 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1241 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1242 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1243 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1244#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1245
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 // Clear saved connection information in HDD
1247 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhf4669da2014-05-26 15:07:49 +05301248 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1249 "%s: Set HDD connState to eConnectionState_NotConnected",
1250 __func__);
1251 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301252#ifdef WLAN_FEATURE_GTK_OFFLOAD
1253 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1254 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1255 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301256 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1257 sizeof (tSirGtkOffloadParams));
1258 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301259 }
1260#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001261
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001262#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001263 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1264 {
1265 wlan_hdd_tdls_disconnection_callback(pAdapter);
1266 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001267#endif
1268
Jeff Johnson295189b2012-06-20 16:38:30 -07001269 //Unblock anyone waiting for disconnect to complete
1270 complete(&pAdapter->disconnect_comp_var);
1271 return( status );
1272}
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301273
1274static void hdd_postTLPacketPendingInd(hdd_adapter_t *pAdapter,
1275 v_U8_t staId)
1276{
1277 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1278 v_SINT_t i;
1279 v_SIZE_t size;
1280 VOS_STATUS status;
1281 v_BOOL_t granted = VOS_FALSE;
1282
1283 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1284 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ||
1285 (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE))
1286 {
1287 //Indicate to TL that there is pending data if a queue is non empty
1288 for (i = WLANTL_AC_HIGH_PRIO; i>=0; --i)
1289 {
1290 size = 0;
1291 hdd_list_size(&pAdapter->wmm_tx_queue[i], &size);
1292 if (size > 0)
1293 {
1294 if (i != WLANTL_AC_HIGH_PRIO)
1295 {
1296 if (VOS_FALSE ==
1297 pAdapter->hddWmmStatus.wmmAcStatus[i].wmmAcAccessAllowed)
1298 {
1299 hdd_wmm_acquire_access(pAdapter,
1300 (WLANTL_ACEnumType)i, &granted);
1301 pAdapter->psbChanged |= (1 << i);
1302 }
1303 else
1304 granted = VOS_TRUE;
1305 }
1306
1307 if (granted || (i == WLANTL_AC_HIGH_PRIO))
1308 {
1309 status = WLANTL_STAPktPending(pHddCtx->pvosContext,
1310 staId, (WLANTL_ACEnumType)i);
1311 if (!VOS_IS_STATUS_SUCCESS(status))
1312 {
1313 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1314 "%s: Failure in indicating pkt to TL for QID=%d",
1315 __func__, i);
1316 }
1317 }
1318 }
1319 }
1320 }
1321}
1322
Jeff Johnson295189b2012-06-20 16:38:30 -07001323static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
1324 tCsrRoamInfo *pRoamInfo,
1325 v_U8_t staId,
1326 v_MACADDR_t *pPeerMacAddress,
1327 tSirBssDescription *pBssDesc )
1328{
1329 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1330 WLAN_STADescType staDesc = {0};
1331 eCsrEncryptionType connectedCipherAlgo;
1332 v_BOOL_t fConnected;
1333 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1334 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001335 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001336
1337 if ( NULL == pBssDesc)
1338 {
1339 return VOS_STATUS_E_FAILURE;
1340 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 // Get the Station ID from the one saved during the assocation.
1342 staDesc.ucSTAId = staId;
1343
Katya Nigam47528772015-02-11 12:24:49 +05301344 staDesc.wSTAType = WLAN_STA_INFRA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001345
Katya Nigam47528772015-02-11 12:24:49 +05301346 // grab the bssid from the connection info in the adapter structure and hand that
1347 // over to TL when registering.
1348 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,
1349 sizeof(pHddStaCtx->conn_info.bssId) );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001350
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1352
1353 // set the QoS field appropriately
1354 if (hdd_wmm_is_active(pAdapter))
1355 {
1356 staDesc.ucQosEnabled = 1;
1357 }
1358 else
1359 {
1360 staDesc.ucQosEnabled = 0;
1361 }
1362
1363 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1364 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1365 {
1366 staDesc.ucProtectedFrame = 1;
1367 }
1368 else
1369 {
1370 staDesc.ucProtectedFrame = 0;
1371
1372 }
1373
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001374#ifdef FEATURE_WLAN_ESE
1375 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
1376#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001377
1378#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1379 /* check whether replay check is valid for the station or not */
1380 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
1381 {
1382 /* Encryption mode is either TKIP or AES
1383 and replay check is valid for only these
1384 two encryption modes */
1385 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1386 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1387 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1388 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001389
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 else
1391 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001392 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001393 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001394 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001395 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1396 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1397 }
1398#endif
1399
1400#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001401 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001402 if (pAdapter->wapi_info.fIsWapiSta)
1403 {
1404 staDesc.ucIsWapiSta = 1;
1405 }
1406 else
1407 {
1408 staDesc.ucIsWapiSta = 0;
1409 }
1410#endif /* FEATURE_WLAN_WAPI */
1411
1412 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1413 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1414
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 // UMA is Not ready yet, Xlation will be done by TL
1416 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001417 staDesc.ucSwFrameRXXlation = 1;
1418 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001419 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 staDesc.ucQosEnabled );
1421 // Initialize signatures and state
1422 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1423 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1424 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1425 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001426 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001427 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "%s: HDD register TL ucInitState=%d", __func__, staDesc.ucInitState );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001428 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1429 hdd_rx_packet_cbk,
1430 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 hdd_tx_fetch_packet_cbk, &staDesc,
1432 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001433
Jeff Johnson295189b2012-06-20 16:38:30 -07001434 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1435 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001436 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001437 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001438 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001439 return vosStatus;
1440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001441
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001442 if ( cfg_param->dynSplitscan &&
1443 ( VOS_TIMER_STATE_RUNNING !=
1444 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1445 {
1446 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1447 cfg_param->trafficMntrTmrForSplitScan);
1448 }
1449
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301450 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1451 // then go to 'authenticated'. For all other authentication types
1452 // (those that donot require upper layer authentication) we can put
1453 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001454 if (staDesc.wSTAType != WLAN_STA_IBSS)
1455 VOS_ASSERT( fConnected );
1456
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301457 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001458 {
1459 // Connections that do not need Upper layer auth, transition TL directly
1460 // to 'Authenticated' state.
1461 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1462 WLANTL_STA_AUTHENTICATED );
1463
1464 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301465
1466 hdd_postTLPacketPendingInd(pAdapter, staDesc.ucSTAId);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001467 }
1468 else
1469 {
1470 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301471 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1472 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001473 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301474 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001475 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1476 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 return( vosStatus );
1478}
1479
Jeff Johnson295189b2012-06-20 16:38:30 -07001480static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1481 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1482{
1483 unsigned int len = 0;
1484 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001485 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001486 tANI_U32 rspRsnLength = 0;
1487 struct ieee80211_channel *chan;
1488
Agarwal Ashish51325b52014-06-16 16:50:49 +05301489 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001490 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001491 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001492 }
1493
Agarwal Ashish51325b52014-06-16 16:50:49 +05301494 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001495 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1496 goto done;
1497 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001498
Agarwal Ashish51325b52014-06-16 16:50:49 +05301499 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001500 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1501 goto done;
1502 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001503
1504 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1505 pCsrRoamInfo->nAssocReqLength);
1506 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001507 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001508
1509 //pFTAssocRsp needs to point to the IEs
1510 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001511 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001512 (unsigned int)pFTAssocRsp[0],
1513 (unsigned int)pFTAssocRsp[1]);
1514
1515 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001516 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001517 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001518 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001519 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001520
1521 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1522 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1523 reqRsnIe, reqRsnLength,
1524 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001525
1526done:
1527 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001528}
Jeff Johnson295189b2012-06-20 16:38:30 -07001529
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301530void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1531{
1532 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1533 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1534 tCsrRoamInfo roamInfo;
1535 roamInfo.fAuthRequired = FALSE;
1536 vos_mem_copy(roamInfo.bssid,
1537 pHddStaCtx->roam_info.bssid,
1538 WNI_CFG_BSSID_LEN);
1539 vos_mem_copy(roamInfo.peerMac,
1540 pHddStaCtx->roam_info.peerMac,
1541 WNI_CFG_BSSID_LEN);
1542
1543 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1544 &roamInfo,
1545 pHddStaCtx->roam_info.roamId,
1546 pHddStaCtx->roam_info.roamStatus,
1547 eCSR_ROAM_RESULT_AUTHENTICATED);
1548 if (halStatus != eHAL_STATUS_SUCCESS)
1549 {
1550 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1551 }
1552 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1553}
1554
Shailender Karmuchia734f332013-04-19 14:02:48 -07001555static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1556 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 eCsrRoamResult roamResult )
1558{
1559 struct net_device *dev = pAdapter->dev;
1560 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1561 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301562 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05301563 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001564 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1565 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001566#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001567 int ft_carrier_on = FALSE;
1568#endif
1569 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301570 v_BOOL_t hddDisconInProgress = FALSE;
1571
1572 /* HDD has initiated disconnect, do not send connect result indication
1573 * to kernel as it will be handled by __cfg80211_disconnect.
1574 */
Agarwal Ashishc089cec2015-08-10 13:10:04 +05301575 if (((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
1576 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)) &&
1577 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
1578 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301579 {
1580 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1581 FL(" Disconnect from HDD in progress "));
1582 hddDisconInProgress = TRUE;
1583 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001584
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1586 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301587 if ( !hddDisconInProgress )
1588 {
1589 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05301590 "%s: Set HDD connState to eConnectionState_Associated",
1591 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301592 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1593 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001594
c_hpothu44ff4e02014-05-08 00:13:57 +05301595 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 // Save the connection info from CSR...
1597 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1598#ifdef FEATURE_WLAN_WAPI
1599 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1600 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1601 {
1602 pAdapter->wapi_info.fIsWapiSta = 1;
1603 }
1604 else
1605 {
1606 pAdapter->wapi_info.fIsWapiSta = 0;
1607 }
1608#endif /* FEATURE_WLAN_WAPI */
1609
1610 // indicate 'connect' status to userspace
1611 hdd_SendAssociationEvent(dev,pRoamInfo);
1612
1613
Shailender Karmuchia734f332013-04-19 14:02:48 -07001614 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001615 INIT_COMPLETION(pAdapter->linkup_event_var);
1616
1617 /*
1618 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1619 packet to go up to the application, device activation has to be ensured for proper queue mapping by the
Shailender Karmuchia734f332013-04-19 14:02:48 -07001620 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 know that the device is getting activated properly.
1622 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001623#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05301624 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07001625 {
1626#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001627 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001628 pAdapter->isLinkUpSvcNeeded = TRUE;
1629
Shailender Karmuchia734f332013-04-19 14:02:48 -07001630 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 pAdapter->isLinkUpSvcNeeded = TRUE;
1632
1633 // Switch on the Carrier to activate the device
1634 netif_carrier_on(dev);
1635
1636 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1637 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1638 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001639 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001640 {
1641 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1642 }
1643
1644 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1645 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001646#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001647 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001648 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001649 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001651 }
1652#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05301653 /* Check for STAID */
1654 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
1655 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1656 else
1657 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001658
1659 //For reassoc, the station is already registered, all we need is to change the state
1660 //of the STA in TL.
1661 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05301662 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07001663 if( !pRoamInfo->fReassocReq )
1664 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001665 struct cfg80211_bss *bss;
1666#ifdef WLAN_FEATURE_VOWIFI_11R
1667 u8 *pFTAssocRsp = NULL;
1668 unsigned int assocRsplen = 0;
1669 u8 *pFTAssocReq = NULL;
1670 unsigned int assocReqlen = 0;
1671 struct ieee80211_channel *chan;
1672#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001675
1676 /* add bss_id to cfg80211 data base */
1677 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1678 if (NULL == bss)
1679 {
Abhishek Singh7ca68f32016-06-28 10:23:10 +05301680 hddLog(LOGE,
1681 FL("Not able to create BSS entry"));
Katya Nigam346d4e92014-09-02 16:16:12 +05301682 netif_carrier_off(dev);
Abhishek Singh7ca68f32016-06-28 10:23:10 +05301683 if (!hddDisconInProgress) {
1684 /*
1685 * Here driver was not able to update cfg80211 database
1686 * this can happen if connected channel is not valid,
1687 * i.e reg domain was changed during connection.
1688 * Queue disconnect for the session if disconnect is
1689 * not in progress.
1690 */
1691 hddLog(LOGE, FL("Disconnecting..."));
1692 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
1693 pAdapter->sessionId,
1694 eCSR_DISCONNECT_REASON_UNSPECIFIED);
1695 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001696 return eHAL_STATUS_FAILURE;
1697 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001698#ifdef WLAN_FEATURE_VOWIFI_11R
1699 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001700 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001701 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001702
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001703 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001704 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001705 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001706 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001707 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001708 // pFTAssocRsp needs to point to the IEs
1709 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1710 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1711 (unsigned int)pFTAssocRsp[0],
1712 (unsigned int)pFTAssocRsp[1]);
1713 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001714 }
1715 else
1716 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001717 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1718 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001719 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001720
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001721 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001722 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001723 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001724 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001725 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001726 if(!ft_carrier_on)
1727 {
1728 // pFTAssocReq needs to point to the IEs
1729 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1730 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1731 (unsigned int)pFTAssocReq[0],
1732 (unsigned int)pFTAssocReq[1]);
1733 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1734 }
1735 else
1736 {
1737 /* This should contain only the FTIEs */
1738 assocReqlen = pRoamInfo->nAssocReqLength;
1739 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001740 }
1741 else
1742 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001743 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1744 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001745 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001746
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001747 if(ft_carrier_on)
1748 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301749 if ( !hddDisconInProgress )
1750 {
1751 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001752 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301753 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001754 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301755 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001756 assocRsplen);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301757 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1758 {
1759 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1760 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301761 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001762 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1763 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301764 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301765 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1766 {
1767 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1768 pRoamInfo->fAuthRequired = FALSE;
1769
1770 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1771 pRoamInfo->bssid,
1772 HDD_MAC_ADDR_LEN);
1773 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1774 pRoamInfo->peerMac,
1775 HDD_MAC_ADDR_LEN);
1776 pHddStaCtx->roam_info.roamId = roamId;
1777 pHddStaCtx->roam_info.roamStatus = roamStatus;
1778 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1779 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001780 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301781 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001782 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001783 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001784 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001785 cfg80211_connect_result(dev, pRoamInfo->bssid,
1786 pFTAssocReq, assocReqlen,
1787 pFTAssocRsp, assocRsplen,
1788 WLAN_STATUS_SUCCESS,
1789 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001790 }
1791 }
1792 else
1793#endif
1794 {
1795 /* wpa supplicant expecting WPA/RSN IE in connect result */
1796 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1797 pAdapter->sessionId,
1798 &reqRsnLength,
1799 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001800
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001801 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1802 pAdapter->sessionId,
1803 &rspRsnLength,
1804 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301805 if ( !hddDisconInProgress )
1806 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001807#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301808 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05301809 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301810 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301811 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1812 {
1813 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1814 }
Mukul Sharma84f27252014-07-14 18:11:42 +05301815 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301816 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001817#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001818
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301819 {
1820 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301821 "%s: sending connect indication to nl80211:"
1822 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301823 " result:%d and Status:%d",
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301824 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1825 roamResult, roamStatus);
1826
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301827 /* inform connect result to nl80211 */
1828 cfg80211_connect_result(dev, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001829 reqRsnIe, reqRsnLength,
1830 rspRsnIe, rspRsnLength,
1831 WLAN_STATUS_SUCCESS,
1832 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301833 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301836 if ( !hddDisconInProgress )
1837 {
1838 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07001839#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301840 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07001841#endif
1842 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301843 // Register the Station with TL after associated...
1844 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 pRoamInfo,
1846 pHddStaCtx->conn_info.staId[ 0 ],
1847 NULL,
1848 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301849 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001850 }
1851 else
1852 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001853 /* wpa supplicant expecting WPA/RSN IE in connect result */
1854 /* in case of reassociation also need to indicate it to supplicant */
1855 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1856 pAdapter->sessionId,
1857 &reqRsnLength,
1858 reqRsnIe);
1859
1860 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301862 if( pRoamInfo->fAuthRequired )
1863 {
1864 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1865 pHddStaCtx->conn_info.staId[ 0 ],
1866 WLANTL_STA_CONNECTED );
1867 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1868 }
1869 else
1870 {
1871 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1872 "%s: staId: %d Changing TL state to AUTHENTICATED",
1873 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1874 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1875 pHddStaCtx->conn_info.staId[ 0 ],
1876 WLANTL_STA_AUTHENTICATED );
1877 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301878 hdd_postTLPacketPendingInd(pAdapter,
1879 pHddStaCtx->conn_info.staId[0]);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301880 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001881 }
1882
1883 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1884 {
1885 // perform any WMM-related association processing
1886 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1887 }
1888 else
1889 {
1890 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001891 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001892 vosStatus, vosStatus );
1893 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001894#ifdef WLAN_FEATURE_11W
1895 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1896 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1897#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301898
Jeff Johnson295189b2012-06-20 16:38:30 -07001899 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05301900 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301901 {
1902 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05301903 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301904 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301905 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1906 {
1907 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
1908 }
Padma, Santhosh Kumar38cef182016-02-18 12:22:51 +05301909#ifdef FEATURE_WLAN_TDLS
1910 wlan_hdd_tdls_connection_callback(pAdapter);
1911#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001912 }
1913 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1916
1917 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001918 if (pRoamInfo)
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301919 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1920 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
1921 MAC_ADDR_ARRAY(pRoamInfo->bssid), roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001922 else
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301923 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1924 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
Arif Hussain24bafea2013-11-15 15:10:03 -08001925 MAC_ADDR_ARRAY(pWextState->req_bssId),
1926 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001927
Sachin Ahuja674c5112015-10-14 13:16:49 +05301928 if (( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
1929 ((roamResult != eCSR_ROAM_RESULT_ASSOCIATED) &&
1930 (eCSR_ROAM_ASSOCIATION_COMPLETION == roamStatus)))
Abhishek Singh611295e2015-07-09 11:11:54 +05301931 wlan_hdd_get_frame_logs(pAdapter,
Siddharth Bhalda0d1622015-04-24 15:47:49 +05301932 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
1933
Abhishek Singhf4669da2014-05-26 15:07:49 +05301934 /* Set connection state to eConnectionState_NotConnected only when CSR
1935 * has completed operation - with a ASSOCIATION_FAILURE status
1936 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301937 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05301938 {
1939 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1940 "%s: Set HDD connState to eConnectionState_NotConnected",
1941 __func__);
1942 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1943 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05301944 if((pHddCtx->concurrency_mode <= 1) &&
1945 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 {
1947 pHddCtx->isAmpAllowed = VOS_TRUE;
1948 }
1949
1950 //If the Device Mode is Station
1951 // and the P2P Client is Connected
1952 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001953
1954 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001955 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001956 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1957 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05301958 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07001959 {
1960 //Enable BMPS only of other Session is P2P Client
1961 hdd_context_t *pHddCtx = NULL;
1962 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1963
1964 if (NULL != pVosContext)
1965 {
1966 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1967
1968 if(NULL != pHddCtx)
1969 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301970 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301971 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1972 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301973 {
1974 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001975 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301976 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001977 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301978 hdd_enable_bmps_imps(pHddCtx);
1979 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001980 }
1981 }
1982 }
1983
James Zmudafbf5ffc2013-03-25 12:45:35 -07001984 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001985 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301986 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07001987 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301988
1989 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1990 {
1991 hddLog(LOG1,
1992 FL("Assoication Failure for P2P client and we are trying to re-enable TDLS"));
1993 wlan_hdd_tdls_reenable(pHddCtx);
1994 }
1995
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301996 if (pRoamInfo)
1997 hddLog(VOS_TRACE_LEVEL_ERROR,
1998 "%s: send connect failure to nl80211:"
1999 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302000 " result:%d and Status:%d reasonCode %d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302001 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302002 roamResult, roamStatus, pRoamInfo->reasonCode);
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302003 else
2004 hddLog(VOS_TRACE_LEVEL_ERROR,
2005 "%s: connect failed:"
2006 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302007 " result:%d and Status:%d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302008 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
2009 roamResult, roamStatus);
2010
James Zmudafbf5ffc2013-03-25 12:45:35 -07002011 /* inform association failure event to nl80211 */
2012 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
2013 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002014 if (pRoamInfo)
2015 cfg80211_connect_result ( dev, pRoamInfo->bssid,
2016 NULL, 0, NULL, 0,
2017 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
2018 GFP_KERNEL );
2019 else
2020 cfg80211_connect_result ( dev, pWextState->req_bssId,
2021 NULL, 0, NULL, 0,
2022 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
2023 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07002024 }
2025 else
2026 {
Gao Wu6ca73b32016-05-09 14:35:49 +08002027 if (pRoamInfo)
2028 cfg80211_connect_result ( dev, pRoamInfo->bssid,
2029 NULL, 0, NULL, 0,
2030 pRoamInfo->reasonCode ?
2031 pRoamInfo->reasonCode :
2032 WLAN_STATUS_UNSPECIFIED_FAILURE,
2033 GFP_KERNEL );
2034 else
2035 cfg80211_connect_result ( dev, pWextState->req_bssId,
2036 NULL, 0, NULL, 0,
2037 WLAN_STATUS_UNSPECIFIED_FAILURE,
2038 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07002039 }
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302040 /*Clear the roam profile*/
2041 hdd_clearRoamProfileIe( pAdapter );
Jeff Johnsone7245742012-09-05 17:12:55 -07002042 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002043
Kumar Anand82c009f2014-05-29 00:29:42 -07002044 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07002045
c_hpothu24f40982014-04-18 18:00:36 +05302046 if (pRoamInfo)
2047 {
2048 WLANTL_AssocFailed(pRoamInfo->staId);
2049 }
Mihir Sheteb7337272014-04-11 15:53:08 +05302050
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302051 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002052 netif_tx_disable(dev);
2053 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002054
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 }
2056
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302057 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302058 {
2059 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
2060 if (pHostapdAdapter != NULL)
2061 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302062 /* Restart SAP if its operating channel is different
2063 * from AP channel.
2064 */
2065 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
2066 (int)pRoamInfo->pBssDesc->channelId)
2067 {
2068 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
2069 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
2070 (int)pRoamInfo->pBssDesc->channelId);
Deepthi Gowric9c777d2014-12-10 16:17:11 +05302071 hdd_hostapd_stop(pHostapdAdapter->dev);
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302072 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302073 }
2074 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002075 return eHAL_STATUS_SUCCESS;
2076}
2077
2078/**============================================================================
2079 *
Jeff Johnson81c17882013-05-03 09:53:35 -07002080 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07002081 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07002082
Jeff Johnson295189b2012-06-20 16:38:30 -07002083 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07002084static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
2085 tCsrRoamInfo *pRoamInfo,
2086 tANI_U32 roamId,
2087 eRoamCmdStatus roamStatus,
2088 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07002089{
Katya Nigam47528772015-02-11 12:24:49 +05302090 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2091 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2092 struct cfg80211_bss *bss;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302093 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Katya Nigam47528772015-02-11 12:24:49 +05302094
Jeff Johnson81c17882013-05-03 09:53:35 -07002095 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
2096 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
2097
Jeff Johnson295189b2012-06-20 16:38:30 -07002098 switch( roamResult )
2099 {
2100 // both IBSS Started and IBSS Join should come in here.
2101 case eCSR_ROAM_RESULT_IBSS_STARTED:
2102 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002103 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07002104 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002105 if (NULL == pRoamInfo)
2106 {
2107 VOS_ASSERT(0);
2108 return;
2109 }
2110
2111 /* When IBSS Started comes from CSR, we need to move
2112 * connection state to IBSS Disconnected (meaning no peers
2113 * are in the IBSS).
2114 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05302115 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2116 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
2117 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07002118 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2119 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302120 /*notify wmm */
2121 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002122 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002123
Jeff Johnson81c17882013-05-03 09:53:35 -07002124 if (pRoamInfo->pBssDesc)
2125 {
Anand N Sunkadfec40682015-07-29 09:51:17 +05302126#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2127 struct ieee80211_channel *chan;
2128 int chan_no;
2129 unsigned int freq;
2130#endif
Katya Nigam47528772015-02-11 12:24:49 +05302131 hdd_ibss_RegisterSTA (pAdapter, pRoamInfo,
2132 IBSS_BROADCAST_STAID,
2133 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson81c17882013-05-03 09:53:35 -07002134
2135 /* we created the IBSS, notify supplicant */
2136 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
2137 MAC_ADDRESS_STR,
2138 __func__, pAdapter->dev->name,
2139 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2140
2141 /* we must first give cfg80211 the BSS information */
2142 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2143 if (NULL == bss)
2144 {
2145 hddLog(VOS_TRACE_LEVEL_ERROR,
2146 "%s: %s: unable to create IBSS entry",
2147 __func__, pAdapter->dev->name);
2148 return;
2149 }
Abhishek Singh00b71972016-01-07 10:51:04 +05302150#ifdef WLAN_FEATURE_RMC
2151 netif_carrier_on(pAdapter->dev);
2152 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
2153 netif_tx_start_all_queues(pAdapter->dev);
2154#endif
Anand N Sunkadfec40682015-07-29 09:51:17 +05302155#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2156 chan_no = pRoamInfo->pBssDesc->channelId;
Jeff Johnson81c17882013-05-03 09:53:35 -07002157
Anand N Sunkadfec40682015-07-29 09:51:17 +05302158 if (chan_no <= 14)
2159 freq = ieee80211_channel_to_frequency(chan_no,
2160 IEEE80211_BAND_2GHZ);
2161 else
2162 freq = ieee80211_channel_to_frequency(chan_no,
2163 IEEE80211_BAND_5GHZ);
2164
2165 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
2166
2167 if (chan)
2168 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
2169 chan, GFP_KERNEL);
2170 else
2171 hddLog(LOGE, FL("%s: chanId: %d, can't find channel"),
2172 pAdapter->dev->name,
2173 (int)pRoamInfo->pBssDesc->channelId);
2174#else
Jeff Johnson81c17882013-05-03 09:53:35 -07002175 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302176#endif
Yue Maf49ba872013-08-19 12:04:25 -07002177 cfg80211_put_bss(
2178#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2179 pHddCtx->wiphy,
2180#endif
2181 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07002182 }
Katya Nigam47528772015-02-11 12:24:49 +05302183 else
2184 {
2185 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2186 "%s: NULL Bss Desc",__func__);
2187 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05302188
2189 /* Set Broadcast key again in case IBSS_COALESCED as DEL BSS,
2190 * in IBSS_COALESCED will remove the BC key.
2191 */
2192 if ((eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) &&
2193 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY
2194 == pHddStaCtx->ibss_enc_key.encType
2195 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY
2196 == pHddStaCtx->ibss_enc_key.encType
2197 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2198 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType ))
2199 {
2200 u8 grpmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2201 VOS_STATUS vosStatus;
2202
2203 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2204
2205 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2206 grpmacaddr, WNI_CFG_BSSID_LEN);
2207 hddLog(VOS_TRACE_LEVEL_INFO,
2208 FL(" SET GTK in case of COALESCED"));
2209 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2210 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2211 if ( VOS_STATUS_SUCCESS != vosStatus )
2212 {
2213 hddLog(VOS_TRACE_LEVEL_ERROR,
2214 FL("sme_RoamSetKey failed, returned %d"),vosStatus);
2215 }
2216 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 break;
2218 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002219
Jeff Johnson295189b2012-06-20 16:38:30 -07002220 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
2221 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002222 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
2223 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07002224 break;
2225 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002226
Jeff Johnson295189b2012-06-20 16:38:30 -07002227 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07002228 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
2229 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07002230 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002231 }
2232
Jeff Johnson81c17882013-05-03 09:53:35 -07002233 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002234}
2235
2236/**============================================================================
2237 *
2238 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
2239 This information is passed to iwconfig later. The peer that joined
2240 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002241 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002242 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002243
Jeff Johnson295189b2012-06-20 16:38:30 -07002244 ===========================================================================*/
Nirav Shah7e3c8132015-06-22 23:51:42 +05302245static int roamSaveIbssStation(hdd_adapter_t *pAdapter, v_U8_t staId, v_MACADDR_t *peerMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07002246{
2247 int fSuccess = FALSE;
2248 int idx = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302249 VOS_STATUS status;
2250 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002251
Jeff Johnson295189b2012-06-20 16:38:30 -07002252 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2253 {
2254 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
2255 {
2256 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002257
Jeff Johnson295189b2012-06-20 16:38:30 -07002258 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002259
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 fSuccess = TRUE;
2261 break;
2262 }
2263 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002264
Nirav Shah7e3c8132015-06-22 23:51:42 +05302265 status = hdd_sta_id_hash_add_entry(pAdapter, staId, peerMacAddress);
2266 if (status != VOS_STATUS_SUCCESS) {
2267 hddLog(VOS_TRACE_LEVEL_ERROR,
2268 FL("Not able to add staid hash %d"), staId);
2269 return FALSE;
2270 }
2271
2272 hddLog(VOS_TRACE_LEVEL_INFO,
2273 FL("New station added sta_id %d mac:"
2274 MAC_ADDRESS_STR), staId,
2275 MAC_ADDR_ARRAY(peerMacAddress->bytes));
2276
Shailender Karmuchia734f332013-04-19 14:02:48 -07002277 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07002278}
2279/**============================================================================
2280 *
2281 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002282 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002283 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002284
Jeff Johnson295189b2012-06-20 16:38:30 -07002285 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07002286static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07002287{
2288 int fSuccess = FALSE;
2289 int idx = 0;
2290 v_U8_t valid_idx = 0;
2291 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07002292 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002293 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Nirav Shah7e3c8132015-06-22 23:51:42 +05302294 VOS_STATUS status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002295
Jeff Johnson295189b2012-06-20 16:38:30 -07002296 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2297 {
2298 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
2299 {
2300 pHddStaCtx->conn_info.staId[ idx ] = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302301 status = hdd_sta_id_hash_remove_entry(pAdapter,
2302 staId, &pHddStaCtx->conn_info.peerMacAddress[idx]);
2303 if (status != VOS_STATUS_SUCCESS) {
2304 hddLog(VOS_TRACE_LEVEL_ERROR,
2305 FL("Not able to remove staid hash %d"), staId );
2306 fSuccess = FALSE;
2307 } else {
2308 hddLog(VOS_TRACE_LEVEL_INFO,
2309 FL("station removed sta_id %d mac:"
2310 MAC_ADDRESS_STR), staId,
2311 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[idx].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07002312
Nirav Shah7e3c8132015-06-22 23:51:42 +05302313 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002314
Nirav Shah7e3c8132015-06-22 23:51:42 +05302315 fSuccess = TRUE;
2316 // Note the deleted Index, if its 0 we need special handling
2317 del_idx = idx;
2318 empty_slots++;
2319 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 }
2321 else
2322 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002323 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002324 {
2325 valid_idx = idx;
2326 }
Ravi Joshi8a934352013-09-25 16:46:58 -07002327 else
2328 {
2329 // Found an empty slot
2330 empty_slots++;
2331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002332 }
2333 }
2334
Ravi Joshi8a934352013-09-25 16:46:58 -07002335 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
2336 {
2337 // Last peer departed, set the IBSS state appropriately
2338 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002339 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07002340 "Last IBSS Peer Departed!!!" );
2341 }
2342
Jeff Johnson295189b2012-06-20 16:38:30 -07002343 // Find next active staId, to have a valid sta trigger for TL.
2344 if (fSuccess == TRUE)
2345 {
2346 if (del_idx == 0)
2347 {
2348 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
2349 {
2350 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
2351 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
2352 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
2353
2354 pHddStaCtx->conn_info.staId[valid_idx] = 0;
2355 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
2356 }
2357 }
2358 }
2359 return( fSuccess );
2360}
2361
2362/**============================================================================
2363 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002364 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002366
Jeff Johnson295189b2012-06-20 16:38:30 -07002367 ===========================================================================*/
2368static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
2369{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002370 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05302371 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2372 "%s: IBSS Connect Indication from SME!!! "
2373 "Set HDD connState to eConnectionState_IbssConnected",
2374 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
2376 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
2377
2378 // Save the connection info from CSR...
2379 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
2380
2381 // Send the bssid address to the wext.
2382 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002383 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002384 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2385 if (NULL == bss)
2386 {
2387 hddLog(VOS_TRACE_LEVEL_ERROR,
2388 "%s: %s: unable to create IBSS entry",
2389 __func__, pAdapter->dev->name);
2390 return eHAL_STATUS_FAILURE;
2391 }
Yue Maf49ba872013-08-19 12:04:25 -07002392 cfg80211_put_bss(
2393#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2394 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
2395#endif
2396 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07002397
2398 return( eHAL_STATUS_SUCCESS );
2399}
2400/**============================================================================
2401 *
Mukul Sharmad2589a52014-04-23 21:06:25 +05302402 @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
2403 suspend related data which was cleared during roaming in FWR.
2404
2405 ===========================================================================*/
2406static void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
2407{
2408 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
2409 hdd_adapter_t *pAdapter;
2410 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
2411 ENTER();
2412
2413 spin_lock(&pHddCtx->filter_lock);
2414 if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
2415 {
2416 pHddCtx->sus_res_mcastbcast_filter =
2417 pHddCtx->configuredMcastBcastFilter;
2418 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
2419 hddLog(VOS_TRACE_LEVEL_INFO, FL("offload: callback to associated"));
2420 hddLog(VOS_TRACE_LEVEL_INFO,
2421 FL("saving configuredMcastBcastFilter = %d"),
2422 pHddCtx->configuredMcastBcastFilter);
2423 hddLog(VOS_TRACE_LEVEL_INFO,
2424 FL("offload: calling hdd_conf_mcastbcast_filter"));
2425 }
2426 spin_unlock(&pHddCtx->filter_lock);
2427
2428 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
2429 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
2430 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
2431
2432 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
2433 //No need to configure GTK Offload from here because it might possible
2434 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
2435 //be handled as part of cfg80211_set_rekey_data processing.
2436 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
2437 {
2438 pAdapter = pAdapterNode->pAdapter;
2439 if( pAdapter &&
2440 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
2441 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
2442 {
2443 if (pHddCtx->cfg_ini->fhostArpOffload)
2444 {
2445 //Configure ARPOFFLOAD
2446 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
2447 if (!VOS_IS_STATUS_SUCCESS(vstatus))
2448 {
2449 hddLog(VOS_TRACE_LEVEL_ERROR,
2450 FL("Failed to disable ARPOffload Feature %d"), vstatus);
2451 }
2452 }
2453#ifdef WLAN_NS_OFFLOAD
2454 //Configure NSOFFLOAD
2455 if (pHddCtx->cfg_ini->fhostNSOffload)
2456 {
2457 hdd_conf_ns_offload(pAdapter, TRUE);
2458 }
2459#endif
Mukul Sharma25e70c32014-05-22 12:50:24 +05302460#ifdef WLAN_FEATURE_PACKET_FILTERING
2461 /* During suspend, configure MC Addr list filter to the firmware
2462 * function takes care of checking necessary conditions before
2463 * configuring.
2464 */
2465 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
2466#endif
Mukul Sharmad2589a52014-04-23 21:06:25 +05302467 }
2468 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2469 pAdapterNode = pNext;
2470 }
2471 EXIT();
2472}
2473
2474/**============================================================================
2475 *
Jeff Johnson295189b2012-06-20 16:38:30 -07002476 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002477
Jeff Johnson295189b2012-06-20 16:38:30 -07002478 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002479static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2480 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002481 eCsrRoamResult roamResult )
2482{
2483 eCsrEncryptionType connectedCipherAlgo;
2484 v_BOOL_t fConnected = FALSE;
2485 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2486 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Bhargav Shaha805ef22015-07-29 17:31:38 +05302487 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002488 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302489 WLANTL_STAStateType prevTLState = WLANTL_STA_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07002490 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07002491
2492 if (NULL == pRoamInfo)
2493 {
2494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
2495 return eHAL_STATUS_FAILURE;
2496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002497 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002498 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07002499 // not require upper layer authentication) we can put TL directly into 'authenticated'
2500 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2502 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
2503 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002504
Jeff Johnson295189b2012-06-20 16:38:30 -07002505 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2506 if( fConnected )
2507 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002508 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
2509 {
2510 v_U8_t staId;
2511
2512 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2513
2514 if ( 0 == memcmp( pRoamInfo->peerMac,
2515 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
2516 {
2517 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2518 IBSS_BROADCAST_STAID);
Abhishek Singhb25e8442015-06-23 14:28:05 +05302519 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2520 "WLAN TL STA GTK Installed for STAID=%d", IBSS_BROADCAST_STAID);
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002521 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2522 }
2523 else
2524 {
2525 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
2526 (v_MACADDR_t*)pRoamInfo->peerMac,
2527 &staId);
2528 if ( VOS_STATUS_SUCCESS == vosStatus )
2529 {
2530 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2531 "WLAN TL STA Ptk Installed for STAID=%d", staId);
2532 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2533 staId);
2534 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2535 }
2536 }
2537 }
2538 else
2539 {
Bhargav Shaha805ef22015-07-29 17:31:38 +05302540 WLANTL_GetSTAState(pHddCtx->pvosContext,
2541 pHddStaCtx->conn_info.staId[0],
2542 &prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302543 // TODO: Considering getting a state machine in HDD later.
2544 // This routine is invoked twice. 1)set PTK 2)set GTK.
2545 // The folloing if statement will be TRUE when setting GTK.
2546 // At this time we don't handle the state in detail.
2547 // Related CR: 174048 - TL not in authenticated state
2548 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
2549 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
2550 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302551
2552 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
2553 "for StaId=%d. Changing TL state to AUTHENTICATED from"
2554 " state:%d", pHddStaCtx->conn_info.staId[0], prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302555
2556 // Connections that do not need Upper layer authentication,
2557 // transition TL to 'Authenticated' state after the keys are set.
2558 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2559 pHddStaCtx->conn_info.staId[ 0 ],
2560 WLANTL_STA_AUTHENTICATED );
2561
2562 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302563
2564 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2565 hdd_postTLPacketPendingInd(pAdapter,
2566 pHddStaCtx->conn_info.staId[0]);
Mukul Sharmad2589a52014-04-23 21:06:25 +05302567 //Need to call offload because when roaming happen at that time fwr
2568 //clean offload info as part of the DelBss
2569 // No need to configure offload if host was not suspended
2570 spin_lock(&pHddCtx->filter_lock);
2571 if(pHddCtx->hdd_wlan_suspended)
2572 {
2573 spin_unlock(&pHddCtx->filter_lock);
2574 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
2575 }
2576 else
2577 {
2578 spin_unlock(&pHddCtx->filter_lock);
2579 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302580 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2581 {
2582 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
2583 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302584 }
2585 else
2586 {
2587 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2588 pHddStaCtx->conn_info.staId[ 0 ]);
Bhargav Shaha805ef22015-07-29 17:31:38 +05302589
2590 /* In case of OSEN move TL to 'Authenticated' after PTK is set */
2591 if (pWextState->roamProfile.bOSENAssociation == VOS_TRUE)
2592 {
2593 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "PTK set"
2594 " for StaId=%d. Due to OSEN, Changing TL state to"
2595 "AUTHENTICATED from state:%d",
2596 pHddStaCtx->conn_info.staId[0], prevTLState);
2597
2598 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2599 pHddStaCtx->conn_info.staId[ 0 ],
2600 WLANTL_STA_AUTHENTICATED );
2601
2602 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
2603
2604 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2605 hdd_postTLPacketPendingInd(pAdapter,
2606 pHddStaCtx->conn_info.staId[0]);
2607 }
2608
2609
2610
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302611 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2612 {
2613 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
2614 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302615 }
2616
2617 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002618 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302620 else
2621 {
2622 // possible disassoc after issuing set key and waiting set key complete
2623 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2624 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002625
Jeff Johnson295189b2012-06-20 16:38:30 -07002626 EXIT();
2627 return( eHAL_STATUS_SUCCESS );
2628}
2629/**============================================================================
2630 *
2631 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2632 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002633static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002634 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002635{
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2637
2638 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2639 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2640 {
2641 struct iw_michaelmicfailure msg;
2642 union iwreq_data wreq;
2643 memset(&msg, '\0', sizeof(msg));
2644 msg.src_addr.sa_family = ARPHRD_ETHER;
2645 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002646 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2647 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002648
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2650 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002651 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002652 msg.flags = IW_MICFAILURE_PAIRWISE;
2653 memset(&wreq, 0, sizeof(wreq));
2654 wreq.data.length = sizeof(msg);
2655 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002656 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002657 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002658 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2659 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2660 NL80211_KEYTYPE_GROUP :
2661 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002662 pRoamInfo->u.pMICFailureInfo->keyId,
2663 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002664 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002665
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002667
Jeff Johnson295189b2012-06-20 16:38:30 -07002668 return( eHAL_STATUS_SUCCESS );
2669}
2670
2671/**============================================================================
2672 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002673 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002675
Jeff Johnson295189b2012-06-20 16:38:30 -07002676 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002677static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2678 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002679 eCsrRoamResult roamResult )
2680{
2681 VOS_STATUS vosStatus;
2682
2683 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2684 switch( roamResult )
2685 {
2686 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2687 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002688 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002689 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002690
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302691 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2692 "IBSS New Peer indication from SME with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002693 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2694 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002696
Jeff Johnson295189b2012-06-20 16:38:30 -07002697 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2698
Shailender Karmuchia734f332013-04-19 14:02:48 -07002699 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2700 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2701 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2702
2703 // Register the Station with TL for the new peer.
Katya Nigam47528772015-02-11 12:24:49 +05302704 vosStatus = hdd_ibss_RegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 pRoamInfo,
2706 pRoamInfo->staId,
2707 (v_MACADDR_t *)pRoamInfo->peerMac,
2708 pRoamInfo->pBssDesc );
2709 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2710 {
2711 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002712 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 vosStatus, vosStatus );
2714 }
Abhishek Singhdecf1b62016-02-09 11:53:58 +05302715 if (!roamSaveIbssStation(pAdapter,
2716 pRoamInfo->staId,
2717 (v_MACADDR_t *)pRoamInfo->peerMac))
2718 {
2719 hddLog(LOGW, FL("Not Able to add sta in sta hash"));
2720 break;
2721 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002722 pHddStaCtx->ibss_sta_generation++;
2723 memset(&staInfo, 0, sizeof(staInfo));
2724 staInfo.filled = 0;
2725 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2726
2727 cfg80211_new_sta(pAdapter->dev,
2728 (const u8 *)pRoamInfo->peerMac,
2729 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002730
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002731 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2732 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2733 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2734 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2735 {
2736 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302737
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002738 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2739 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2740
2741 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002742 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002743 pHddStaCtx->ibss_enc_key.encType);
2744
2745 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2746 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2747
2748 if ( VOS_STATUS_SUCCESS != vosStatus )
2749 {
2750 hddLog(VOS_TRACE_LEVEL_ERROR,
2751 "%s: sme_RoamSetKey failed, returned %d",
2752 __func__, vosStatus);
2753 return VOS_STATUS_E_FAILURE;
2754 }
2755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002756 netif_carrier_on(pAdapter->dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302757 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 netif_tx_start_all_queues(pAdapter->dev);
2759 break;
2760 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002761
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2763 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002764
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002766
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002769 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2770 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002771 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002772
Ravi Joshicc57ed42013-10-12 16:31:25 -07002773 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 {
2775 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2776 "IBSS peer departed by cannot find peer in our registration table with TL" );
2777 }
2778
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302779 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2780 "IBSS Peer Departed from SME with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002781 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2782 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2783 pRoamInfo->staId );
2784
Katya Nigam47528772015-02-11 12:24:49 +05302785 hdd_ibss_DeregisterSTA( pAdapter, pRoamInfo->staId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002786
2787 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002788 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002789
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002790 cfg80211_del_sta(pAdapter->dev,
2791 (const u8 *)&pRoamInfo->peerMac,
2792 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002793 break;
2794 }
2795 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2796 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002797 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2798 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002799 // Stop only when we are inactive
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302800 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002801 netif_tx_disable(pAdapter->dev);
2802 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05302803 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2804 "%s: Set HDD connState to eConnectionState_NotConnected",
2805 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002806 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002807
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 // Send the bssid address to the wext.
2809 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2810 // clean up data path
2811 hdd_disconnect_tx_rx(pAdapter);
2812 break;
2813 }
2814 default:
2815 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002816
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002818
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 return( eHAL_STATUS_SUCCESS );
2820}
2821
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002822#ifdef FEATURE_WLAN_TDLS
2823/**============================================================================
2824 *
2825 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2826 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2827 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002828
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002829 ===========================================================================*/
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05302830VOS_STATUS hdd_roamRegisterTDLSSTA(hdd_adapter_t *pAdapter,
2831#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
2832 const tANI_U8 *peerMac,
2833#else
2834 tANI_U8 *peerMac,
2835#endif
2836 tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002837{
2838 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002839 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002840 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2841 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002842 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2843 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002844 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2845 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002846
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002847 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2848 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002849 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002850 "%s not connected. ignored", __func__);
2851 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002852 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002853
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002854 /*
2855 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2856 * be peer MAC, here we are wokrking on direct Link
2857 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002858 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002859
2860 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002861
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002862 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002863 sizeof(tSirMacAddr) );
2864
2865 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2866 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2867
2868 /* set the QoS field appropriately ..*/
2869 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2870 : (staDesc.ucQosEnabled = 0) ;
2871
2872 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002873 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002874
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002875 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002876
2877 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002878 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002879
Shailender Karmuchia734f332013-04-19 14:02:48 -07002880 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002881 * UMA is ready we inform TL to do frame translation.
2882 */
2883 staDesc.ucSwFrameTXXlation = 1;
2884 staDesc.ucSwFrameRXXlation = 1;
2885 staDesc.ucAddRmvLLC = 1;
2886
2887 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002888 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002889
2890 /* tdls Direct Link do not need bcastSig */
2891 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002892
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002893#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2894 if(staDesc.ucProtectedFrame)
2895 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2896 else
2897 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2898#endif
2899
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302900 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002901
Shailender Karmuchia734f332013-04-19 14:02:48 -07002902 /* Register the Station with TL... */
2903 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2904 hdd_rx_packet_cbk,
2905 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002906 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002907
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002908 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2909 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002910 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002911 "%s: WLANTL_RegisterSTAClient() failed to register. "
2912 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002913 return vosStatus;
2914 }
2915
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002916 if ( cfg_param->dynSplitscan &&
2917 ( VOS_TIMER_STATE_RUNNING !=
2918 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2919 {
2920 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2921 cfg_param->trafficMntrTmrForSplitScan);
2922 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002923 return( vosStatus );
2924}
2925
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05302926VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002927{
2928 VOS_STATUS vosStatus;
2929 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2930 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2931 {
2932 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2933 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002934 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002935 __func__, staId, vosStatus, vosStatus );
2936 }
2937 return( vosStatus );
2938}
2939
2940
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002941/*
2942 * HDD interface between SME and TL to ensure TDLS client registration with
2943 * TL in case of new TDLS client is added and deregistration at the time
2944 * TDLS client is deleted.
2945 */
2946
Shailender Karmuchia734f332013-04-19 14:02:48 -07002947eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2948 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002949 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002950 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002951 eCsrRoamResult roamResult)
2952{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002953 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002954 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002955 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002956
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002958 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2959 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2960 "ADD_TDLS_PEER" :
2961 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2962 "DEL_TDLS_PEER" :
2963 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2964 "DEL_TDLS_PEER_IND" :
2965 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2966 "DEL_ALL_TDLS_PEER_IND" :
2967 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2968 "UPDATE_TDLS_PEER" :
2969 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05302970 "LINK_ESTABLISH_REQ_RSP" :
2971 roamResult == eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP ?
2972 "CHANNEL_SWITCH_REQ_RSP" : "UNKNOWN",
Arif Hussain24bafea2013-11-15 15:10:03 -08002973 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002974 switch( roamResult )
2975 {
2976 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2977 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002978 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2979 {
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05302980 hddTdlsPeer_t *curr_peer;
2981
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002983 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05302984 wlan_hdd_tdls_check_bmps(pAdapter);
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05302985
2986 mutex_lock(&pHddCtx->tdls_lock);
2987 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
2988 pRoamInfo->peerMac, FALSE);
2989 if (NULL != curr_peer)
2990 curr_peer->link_status = eTDLS_LINK_TEARING;
2991 else
2992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2993 "%s %d curr_peer is Null", __func__,__LINE__);
2994 mutex_unlock(&pHddCtx->tdls_lock);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002995 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002996 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002997 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002998
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002999 /* check if there is available index for this new TDLS STA */
3000 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
3001 {
3002 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
3003 {
3004 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
3005 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
3006
3007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003008 ("TDLS: STA IDX at %d is %d "
3009 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003010 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003011 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003012
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003013 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003014 (v_MACADDR_t *)pRoamInfo->peerMac) ;
3015 status = eHAL_STATUS_SUCCESS ;
3016 break ;
3017 }
3018 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003019 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003020 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003021 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003022 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3023 "wlan_hdd_tdls_set_sta_id() failed");
3024 return VOS_FALSE;
3025 }
3026
3027 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303028 /* store the ucast signature , if required for further reference. */
3029
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003030 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303031 /* start TDLS client registration with TL */
3032 status = hdd_roamRegisterTDLSSTA( pAdapter,
3033 pRoamInfo->peerMac,
3034 pRoamInfo->staId,
3035 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303036 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003037 }
3038 else
3039 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003040 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003041 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07003042 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003043 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003044 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003045 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003046 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003047 break ;
3048 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003049 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3050 {
3051 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3052 {
3053 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3054 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
3055 }
3056 /* store the ucast signature which will be used later when
3057 * registering to TL
3058 */
3059 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3060 complete(&pAdapter->tdls_add_station_comp);
3061 break;
3062 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303063 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3064 {
3065 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3066 {
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303067 hddTdlsPeer_t *curr_peer;
3068
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303069 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3070 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303071
3072 mutex_lock(&pHddCtx->tdls_lock);
3073 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3074 pRoamInfo->peerMac, FALSE);
3075 if (curr_peer)
3076 curr_peer->link_status = eTDLS_LINK_TEARING;
3077 else
3078 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3079 "%s %d curr_peer is Null",__func__,__LINE__);
3080 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303081 }
3082 complete(&pAdapter->tdls_link_establish_req_comp);
3083 break;
3084 }
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303085 case eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP:
3086 {
3087 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3089 "%s: Channel switch request failed. %d", __func__,
3090 pRoamInfo->statusCode);
3091 else
3092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3093 "%s: Channel switch request Success", __func__);
3094 break;
3095 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003096 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003097 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003098 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003099 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003100 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003101 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3102 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003103 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003104 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003105 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
3106
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303107 mutex_lock(&pHddCtx->tdls_lock);
3108 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3109 pRoamInfo->peerMac, FALSE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303110 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003111 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303112 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3113 " Current status for peer" MAC_ADDRESS_STR "is %d",
3114 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303115 if (TDLS_IS_CONNECTED(curr_peer) ||
3116 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303117 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303118 mutex_unlock(&pHddCtx->tdls_lock);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303119 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
3120 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303121 else
3122 mutex_unlock(&pHddCtx->tdls_lock);
3123
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303124 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003125 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303126 else
3127 mutex_unlock(&pHddCtx->tdls_lock);
3128
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303129 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003130 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303131 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003132
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003133 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3134 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
3135 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003136 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003137 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003138 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003139 break ;
3140 }
3141 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003142 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003143 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003144 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003145 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3146 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003147 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003148 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3149 "%s: Sending teardown to supplicant with reason code %u",
3150 __func__, pRoamInfo->reasonCode);
3151
3152#ifdef CONFIG_TDLS_IMPLICIT
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303153 mutex_lock(&pHddCtx->tdls_lock);
3154 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac,
3155 FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003156 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Abhishek Singh96568922016-01-05 15:28:12 +05303157 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3158 curr_peer->peerMac);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303159 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003160#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003161 status = eHAL_STATUS_SUCCESS ;
3162 break ;
3163 }
3164 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3165 {
3166 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003167 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003168 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003169 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3170 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003171 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003172 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003173 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003174 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003175 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303176
3177 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003178 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303179 mutex_unlock(&pHddCtx->tdls_lock);
3180
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003181 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3182 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003183
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003184 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003185 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003186 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3187 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003188
3189 status = eHAL_STATUS_SUCCESS ;
3190 }
3191 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303192 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003193 break ;
3194 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003195 default:
3196 {
3197 break ;
3198 }
3199 }
3200
3201 return status ;
3202}
3203#endif
3204
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05303205void iw_full_power_cbfn (void *pContext, eHalStatus status)
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003206{
3207 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3208 hdd_context_t *pHddCtx = NULL;
3209 int ret;
3210
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303211 ENTER();
3212
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003213 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3214 {
3215 hddLog(VOS_TRACE_LEVEL_ERROR,
3216 "%s: Bad param, pAdapter [%p]",
3217 __func__, pAdapter);
3218 return;
3219 }
3220
3221 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3222 ret = wlan_hdd_validate_context(pHddCtx);
3223 if (0 != ret)
3224 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003225 return;
3226 }
3227
3228 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3229 {
3230 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
3231 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303232
3233 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003234}
3235
Shailender Karmuchia734f332013-04-19 14:02:48 -07003236eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003237 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
3238{
3239 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
3240 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303241 hdd_wext_state_t *pWextState = NULL;
3242 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003243 VOS_STATUS status = VOS_STATUS_SUCCESS;
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05303244 struct cfg80211_bss *bss_status;
Amar Singhal49fdfd52013-08-13 13:25:12 -07003245 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003246
3247 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003248 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003249 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003250
3251 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303252 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003253 {
3254 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303255 "invalid adapter or adapter has invalid magic");
3256 return eHAL_STATUS_FAILURE;
3257 }
3258
3259 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3260 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3261
3262 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3263 {
3264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3265 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003266 return eHAL_STATUS_FAILURE;
3267 }
3268
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05303269 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
3270 pAdapter->sessionId, roamStatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003271 switch( roamStatus )
3272 {
3273 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki41d95e22015-08-28 12:51:32 +05303274 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
3275 complete(&pAdapter->session_open_comp_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07003276 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003277
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003278#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
3279 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07003281 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 * interface down */
3283 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303284 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
3285 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05303286 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3288 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
3289 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003290 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3291 }
3292 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05303293 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003294 break;
3295
3296 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003297 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07003299 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 // eCSR_ROAM_SHOULD_ROAM will be received.
3301 // Where in we will not mark the link down
3302 // Also we want to stop tx at this point when we will be
3303 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003304 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 {
3306 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303307 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303309 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3310 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3311 {
3312 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
3313 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003314 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303315 * Deregister this STA with TL, but do not flush the packets
3316 * for this STA from wmm_tx_queue. Since there is no valid STA
3317 * for these packets they will not be transmitted. Eventually
3318 * after the reassociation is successful, these packets will be
3319 * transmitted after registering STA with TL again. This ensures
3320 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003321 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303322 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
3323 pHddStaCtx->conn_info.staId[0]);
3324 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003325 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303326 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3327 FL("WLANTL_ClearSTAClient failed for staID %d."
3328 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
3329 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003330 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003332 }
3333 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003334 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 break;
3336#endif
3337
3338 case eCSR_ROAM_SHOULD_ROAM:
3339 // Dont need to do anything
3340 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 struct net_device *dev = pAdapter->dev;
3342 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3343 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303344 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003346#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003347 if (pHddStaCtx->ft_carrier_on == FALSE)
3348 {
3349#endif
3350 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003351#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003352 }
3353#endif
3354
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003355#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07003356 //We should clear all sta register with TL, for now, only one.
3357 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
3358 if ( !VOS_IS_STATUS_SUCCESS(status ) )
3359 {
3360 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3361 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
3362 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003363 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003364 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003365#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003366 }
3367 break;
3368 case eCSR_ROAM_LOSTLINK:
3369 case eCSR_ROAM_DISASSOCIATED:
3370 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3372 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05303373 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003374 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3375 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07003376 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3377 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303378 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07003379 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08003380
3381 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
3382 pHddCtx->configuredMcastBcastFilter =
3383 pHddCtx->sus_res_mcastbcast_filter;
3384 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
3385 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303386
Amar Singhald53568e2013-09-26 11:03:45 -07003387 hddLog(VOS_TRACE_LEVEL_INFO,
3388 "offload: disassociation happening, restoring configuredMcastBcastFilter");
3389 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
3390 pHddCtx->configuredMcastBcastFilter);
3391 hddLog(VOS_TRACE_LEVEL_INFO,
3392 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07003393 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3394 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003395#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303396 /* Call to clear any MC Addr List filter applied after
3397 * successful connection.
3398 */
3399 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003400#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 }
3402 break;
3403 case eCSR_ROAM_IBSS_LEAVE:
3404 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3405 "****eCSR_ROAM_IBSS_LEAVE****");
3406 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3407 break;
3408 case eCSR_ROAM_ASSOCIATION_COMPLETION:
3409 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3410 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303411 // To Do - address probable memory leak with WEP encryption upon successful association
3412 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07003413 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303414 //Clear saved connection information in HDD
3415 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003416 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303417 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003418
3419 break;
3420 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003421 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 pRoamInfo, roamId, roamStatus, roamResult );
3423 break;
3424 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07003425 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
3426 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003427 break;
3428
3429 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
3430 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003431 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003432
3433 case eCSR_ROAM_MIC_ERROR_IND:
3434 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3435 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05303436 case eCSR_ROAM_LOST_LINK_PARAMS_IND:
3437 {
3438 /*
3439 * The RSSI will be subtracted from 100 as FW is sending the RSSI by
3440 * adding the 100 value.
3441 */
3442 pAdapter->rssi_on_disconnect = pRoamInfo->u.pLostLinkParams->rssi - 100;
3443 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3444 "%s : Rssi on Disconnect : %d",
3445 __func__, pAdapter->rssi_on_disconnect);
3446 break;
3447 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003448 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003449 {
3450 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
3451
3452 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003453 (TRUE == pHddCtx->hdd_wlan_suspended) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05303454 ((eCSR_ROAM_RESULT_NONE == roamResult)||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05303455 (pRoamInfo && pRoamInfo->is11rAssoc)))
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003456 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003457 /* Send DTIM period to the FW; only if the wlan is already
3458 in suspend. This is the case with roaming (reassoc),
3459 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
3460 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
3461 before the ENTER_BMPS_REQ ensures Listen Interval is
3462 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003463 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003464
3465 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003466 if due to unexpected scenario, if we are in BMPS,
3467 then trigger Exit and Enter BMPS to take DTIM period
3468 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003469 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
3470 {
3471 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
3472
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003473 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3474 iw_full_power_cbfn, pAdapter,
3475 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003476 }
3477 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303478
3479 if ((pHddCtx) &&
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303480 (FULL_POWER == pmcGetPmcState(pHddCtx->hHal)) &&
3481 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05303482 ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05303483 (pRoamInfo && pRoamInfo->is11rAssoc)))
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303484 {
3485 hddLog( LOG1, FL("Device in full power."
3486 "Stop and start traffic timer for roaming"));
3487 pmcStopTrafficTimer(pHddCtx->hHal);
3488 if (pmcStartTrafficTimer(pHddCtx->hHal,
3489 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
3490 {
3491 hddLog(LOGP, FL("Cannot start traffic timer"));
3492 }
3493 }
3494
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003495 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05303496 if ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05303497 (pRoamInfo && pRoamInfo->is11rAssoc))
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303498 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003499 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003500 break;
3501#ifdef WLAN_FEATURE_VOWIFI_11R
3502 case eCSR_ROAM_FT_RESPONSE:
3503 hdd_SendFTEvent(pAdapter);
3504 break;
3505#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07003506#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003507 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003508 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07003509 {
3510 /* Notify the supplicant of a new candidate */
3511 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
3512 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003513 break;
3514#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003515
Yue Maef608272013-04-08 23:09:17 -07003516#ifdef FEATURE_WLAN_LFR_METRICS
3517 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
3518 /* This event is to notify pre-auth initiation */
3519 if (VOS_STATUS_SUCCESS !=
3520 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
3521 {
3522 halStatus = eHAL_STATUS_FAILURE;
3523 }
3524 break;
3525 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
3526 /* This event will notify pre-auth completion in case of success */
3527 if (VOS_STATUS_SUCCESS !=
3528 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3529 pRoamInfo, 1))
3530 {
3531 halStatus = eHAL_STATUS_FAILURE;
3532 }
3533 break;
3534 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
3535 /* This event will notify pre-auth completion in case of failure. */
3536 if (VOS_STATUS_SUCCESS !=
3537 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3538 pRoamInfo, 0))
3539 {
3540 halStatus = eHAL_STATUS_FAILURE;
3541 }
3542 break;
3543 case eCSR_ROAM_HANDOVER_SUCCESS:
3544 /* This event is to notify handover success.
3545 It will be only invoked on success */
3546 if (VOS_STATUS_SUCCESS !=
3547 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
3548 {
3549 halStatus = eHAL_STATUS_FAILURE;
3550 }
3551 break;
3552#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 case eCSR_ROAM_REMAIN_CHAN_READY:
3554 hdd_remainChanReadyHandler( pAdapter );
3555 break;
3556 case eCSR_ROAM_SEND_ACTION_CNF:
3557 hdd_sendActionCnf( pAdapter,
3558 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
3559 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003560#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08003561 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003562 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08003563 roamId, roamStatus, roamResult );
3564 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003565 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
3566 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
3567 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003568#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003569#ifdef WLAN_FEATURE_11W
3570 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
3571 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
3572 pRoamInfo->pbFrames,
3573 pRoamInfo->frameType);
3574 break;
3575#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003576#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003577 case eCSR_ROAM_TSM_IE_IND:
3578 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
3579 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
3580 break;
3581
3582 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
3583 {
3584 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
3585 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
3586 {
3587 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
3588 }
3589 break;
3590 }
3591
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003592 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003593 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003594 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003595 break;
3596 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003597
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003598 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003599 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003600 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003601 break;
3602 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003603#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05303604 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
3605 {
3606 pAdapter->maxRateFlags = roamResult;
3607 break;
3608 }
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05303609 case eCSR_ROAM_UPDATE_SCAN_RESULT:
3610 if (pRoamInfo && pRoamInfo->pBssDesc) {
3611 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
3612 pRoamInfo->pBssDesc);
3613 if (bss_status)
3614 cfg80211_put_bss(
3615#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
3616 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
3617#endif
3618 bss_status);
3619 else
3620 hddLog(LOG1, FL("UPDATE_SCAN_RESULT returned NULL"));
3621 }
3622 break;
Girish Gowlia95daca2015-02-04 20:31:31 +05303623 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07003624 break;
3625 }
3626 return( halStatus );
3627}
Shailender Karmuchia734f332013-04-19 14:02:48 -07003628eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003629{
3630 eCsrAuthType auth_type;
3631 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003632 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 {
3634 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003635 } else
3636 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003637 {
3638 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003639 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003640#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003641 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003642 {
3643 // Check for 11r FT Authentication with PSK
3644 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003645 } else
3646 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003647 {
3648 // Check for 11R FT Authentication with 802.1X
3649 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003650 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003651#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003652#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003653 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003654 {
3655 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
3656 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003657#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07003658#ifdef WLAN_FEATURE_11W
3659 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
3660 {
3661 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3662 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303663 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
3664 {
3665 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3666 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003667#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003668 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003669 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3670 }
3671 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003672}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003673
Shailender Karmuchia734f332013-04-19 14:02:48 -07003674eCsrAuthType
3675hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003676{
3677 eCsrAuthType auth_type;
3678 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003679 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003680 {
3681 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003682 } else
3683 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003684 {
3685 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003686 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003687#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003688 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003689 {
3690 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003691 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003692#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003693 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3695 }
3696 hddLog(LOG1, FL("auth_type: %d"), auth_type);
3697 return auth_type;
3698}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003699
Shailender Karmuchia734f332013-04-19 14:02:48 -07003700eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003701hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003702{
3703 eCsrEncryptionType cipher_type;
3704 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003705 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003706 {
3707 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003708 }
3709 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003710 {
3711 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003712 }
3713 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 {
3715 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003716 }
3717 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003718 {
3719 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003720 }
3721 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
3722 {
3723 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3724 }
3725 else
3726 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3728 }
3729 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3730 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003731}
Jeff Johnson295189b2012-06-20 16:38:30 -07003732/* To find if the MAC address is NULL */
3733static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3734{
3735 int i;
3736 for (i = 0; i < length; i++)
3737 {
3738 if (0x00 != (macAddr[i]))
3739 {
3740 return FALSE;
3741 }
3742 }
3743 return TRUE;
3744} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003745
Shailender Karmuchia734f332013-04-19 14:02:48 -07003746eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003747hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003748{
3749 eCsrEncryptionType cipher_type;
3750 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003751 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003752 {
3753 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003754 } else
3755 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 {
3757 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003758 } else
3759 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 {
3761 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003762 } else
3763 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 {
3765 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003766 } else
3767 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003768 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003769 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3770 } else
3771 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3773 }
3774 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3775 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003776}
Jeff Johnson295189b2012-06-20 16:38:30 -07003777
Shailender Karmuchia734f332013-04-19 14:02:48 -07003778static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3779 struct ether_addr *pBssid,
3780 eCsrEncryptionType *pEncryptType,
3781 eCsrEncryptionType *mcEncryptType,
3782 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003783#ifdef WLAN_FEATURE_11W
3784 u_int8_t *pMfpRequired,
3785 u_int8_t *pMfpCapable,
3786#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003787 u_int16_t gen_ie_len,
3788 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003789{
3790 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003791 eHalStatus result;
3792 tDot11fIERSN dot11RSNIE;
3793 tDot11fIEWPA dot11WPAIE;
3794 tANI_U32 i;
3795 tANI_U8 *pRsnIe;
3796 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003797 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003798 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003799
3800 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3801 flag to 0 */
3802 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3803 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3804
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003806 if ( gen_ie[0] == DOT11F_EID_RSN)
3807 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003808 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003809 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003810 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3811 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303812 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3813 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 return -EINVAL;
3815 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003816 // Skip past the EID byte and length byte
3817 pRsnIe = gen_ie + 2;
3818 RSNIeLen = gen_ie_len - 2;
3819 // Unpack the RSN IE
3820 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3821 pRsnIe,
3822 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003824 // Copy out the encryption and authentication types
3825 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003826 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003827 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003828 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003829 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003830 but probably I suspect we can do something different*/
3831 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003832 // Just translate the FIRST one
3833 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3834 //dot11RSNIE.pwise_cipher_suite_count
3835 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3836 //dot11RSNIE.gp_cipher_suite_count
3837 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003838#ifdef WLAN_FEATURE_11W
3839 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3840 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3841#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003843 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003844 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003845 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003846 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303847 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 break;
3849 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003850 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003851 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303852 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 break;
3854 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003855 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 // For right now, I assume setASSOCIATE() has passed in the bssid.
3857 vos_mem_copy(PMKIDCache[i].BSSID,
3858 pBssid, ETHER_ADDR_LEN);
3859 vos_mem_copy(PMKIDCache[i].PMKID,
3860 dot11RSNIE.pmkid[i],
3861 CSR_RSN_PMKID_SIZE);
3862 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003863
3864 if (updatePMKCache)
3865 {
3866 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003867 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003868 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003869 // Finally set the PMKSA ID Cache in CSR
3870 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3871 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05303872 dot11RSNIE.pmkid_count,
3873 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07003874 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003875 }
3876 else if (gen_ie[0] == DOT11F_EID_WPA)
3877 {
3878 // Validity checks
3879 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3880 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3881 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303882 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3883 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003884 return -EINVAL;
3885 }
3886 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003887 pRsnIe = gen_ie + 2 + 4;
3888 RSNIeLen = gen_ie_len - (2 + 4);
3889 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003890 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3891 pRsnIe,
3892 RSNIeLen,
3893 &dot11WPAIE);
3894 // Copy out the encryption and authentication types
3895 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003896 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003898 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 //dot11WPAIE.auth_suite_count
3900 // Just translate the FIRST one
3901 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3902 //dot11WPAIE.unicast_cipher_count
3903 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3904 //dot11WPAIE.unicast_cipher_count
3905 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3906 }
3907 else
3908 {
3909 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003910 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003911 }
3912 return 0;
3913}
3914int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3915{
3916 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3917 v_U32_t status = 0;
3918 eCsrEncryptionType RSNEncryptType;
3919 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003920#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303921 u_int8_t RSNMfpRequired = 0;
3922 u_int8_t RSNMfpCapable = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07003923#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 struct ether_addr bSsid; // MAC address of assoc peer
3925 // MAC address of assoc peer
3926 // But, this routine is only called when we are NOT associated.
3927 vos_mem_copy(bSsid.ether_addr_octet,
3928 pWextState->roamProfile.BSSIDs.bssid,
3929 sizeof(bSsid.ether_addr_octet));
3930 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3931 {
3932 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003933 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 else
3935 {
3936 return 0;
3937 }
3938 // The actual processing may eventually be more extensive than this.
3939 // Right now, just consume any PMKIDs that are sent in by the app.
3940 status = hdd_ProcessGENIE(pAdapter,
3941 &bSsid, // MAC address of assoc peer
3942 &RSNEncryptType,
3943 &mcRSNEncryptType,
3944 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003945#ifdef WLAN_FEATURE_11W
3946 &RSNMfpRequired,
3947 &RSNMfpCapable,
3948#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003949 pWextState->WPARSNIE[1]+2,
3950 pWextState->WPARSNIE);
3951 if (status == 0)
3952 {
3953 // Now copy over all the security attributes you have parsed out
3954 pWextState->roamProfile.EncryptionType.numEntries = 1;
3955 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003956
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3958 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003959
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003960 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3961 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3962 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3963 {
3964 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3965 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3966 either AES/TKIP based on group cipher configuration
3967 mentioned in the wpa_supplicant.conf.*/
3968
3969 /*Set the unicast cipher same as multicast cipher*/
3970 pWextState->roamProfile.EncryptionType.encryptionType[0]
3971 = mcRSNEncryptType;
3972 }
3973
Chet Lanctot186b5732013-03-18 10:26:30 -07003974#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303975 hddLog( LOG1, FL("RSNMfpRequired = %d, RSNMfpCapable = %d"),
3976 RSNMfpRequired, RSNMfpCapable);
Chet Lanctot186b5732013-03-18 10:26:30 -07003977 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3978 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3979#endif
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303980 hddLog( LOG1,
3981 FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d"),
3982 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 }
3984 return 0;
3985}
3986int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3987{
3988 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3989 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3990 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3991 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003992
Jeff Johnson295189b2012-06-20 16:38:30 -07003993 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003994 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003995
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 switch( pHddStaCtx->conn_info.authType)
3997 {
3998 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003999#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 case eCSR_AUTH_TYPE_CCKM_WPA:
4001 case eCSR_AUTH_TYPE_CCKM_RSN:
4002#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004003 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
4004
Jeff Johnson295189b2012-06-20 16:38:30 -07004005 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004006 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004008
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004009#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004010 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
4011 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4012 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004013 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004014 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
4015 } else
4016 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004017 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004018 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07004019 } else
4020#endif
4021 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4022 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004023 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
4024 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004025 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4026 == IW_AUTH_KEY_MGMT_PSK) {
4027 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004028 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004029 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004030 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004031 }
4032 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004033#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004034 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
4035 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4036 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004037 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004038 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004039 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004040 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004041 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004042 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 } else
4044#endif
4045
4046#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004047 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
4048 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004049 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004050 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07004051 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004052 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004053 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4054 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004055 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07004056 } else
4057#endif
4058
Chet Lanctot186b5732013-03-18 10:26:30 -07004059#ifdef WLAN_FEATURE_11W
4060 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
4061 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4062 } else
Abhishek Singhae408032014-09-25 17:22:04 +05304063 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
4064 pRoamProfile->AuthType.authType[0] =
4065 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4066 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07004067#endif
4068
Shailender Karmuchia734f332013-04-19 14:02:48 -07004069 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004071 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
4072 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4074 == IW_AUTH_KEY_MGMT_PSK) {
4075 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004076 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004078 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004080 break;
4081
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004083
4084 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004085 break;
4086 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004087
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004088#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08004089 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004090#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
4092 break;
4093 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004094
Jeff Johnson295189b2012-06-20 16:38:30 -07004095 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004096 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004097
Jeff Johnson295189b2012-06-20 16:38:30 -07004098 EXIT();
4099 return 0;
4100}
4101
4102/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004103
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304104 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07004106 to the CSR roam profile.
4107
Jeff Johnson295189b2012-06-20 16:38:30 -07004108 \param - dev - Pointer to the net device.
4109 - info - Pointer to the iw_request_info.
4110 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004111 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004112 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004113
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 --------------------------------------------------------------------------*/
4115
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304116int __iw_set_essid(struct net_device *dev,
4117 struct iw_request_info *info,
4118 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004119{
4120 v_U32_t status = 0;
4121 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304122 hdd_adapter_t *pAdapter;
4123 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 v_U32_t roamId;
4125 tCsrRoamProfile *pRoamProfile;
4126 eMib_dot11DesiredBssType connectedBssType;
4127 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304128 tHalHandle hHal;
4129 hdd_station_ctx_t *pHddStaCtx;
4130 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004131
Jeff Johnson295189b2012-06-20 16:38:30 -07004132 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304133 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4134 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004135 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304136 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304137 "%s: Adapter is NULL",__func__);
4138 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004139 }
4140
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304141 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4142 ret = wlan_hdd_validate_context(pHddCtx);
4143 if (0 != ret)
4144 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304145 return ret;
4146 }
4147
4148 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4149 if (NULL == hHal)
4150 {
4151 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4152 "%s: Hal Context is NULL",__func__);
4153 return -EINVAL;
4154 }
4155 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4156 if (NULL == pHddStaCtx)
4157 {
4158 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4159 "%s: STA Context is NULL",__func__);
4160 return -EINVAL;
4161 }
4162 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4163 if (NULL == pWextState)
4164 {
4165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4166 "%s: pWextState is NULL",__func__);
4167 return -EINVAL;
4168 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004169 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
4170 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
4171 return -EBUSY;
4172 }
4173 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
4174 return -EINVAL;
4175 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004176 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004177 {
4178 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
4179 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
4180 {
4181 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004182 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07004183 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4184 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
4185
4186 if(VOS_STATUS_SUCCESS == vosStatus)
4187 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
4188 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4189 }
4190 }
4191 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004192 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 {
4194 return -EINVAL;
4195 }
4196 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004197 /** when cfg80211 defined, wpa_supplicant wext driver uses
4198 zero-length, null-string ssid for force disconnection.
4199 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07004200 driver MUST return success */
4201 if ( 0 == wrqu->essid.length ) {
4202 return 0;
4203 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004204
4205 status = hdd_wmm_get_uapsd_mask(pAdapter,
4206 &pWextState->roamProfile.uapsd_mask);
4207 if (VOS_STATUS_SUCCESS != status)
4208 {
4209 pWextState->roamProfile.uapsd_mask = 0;
4210 }
4211 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004212
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004214
4215 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
4217 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
4218 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004219
Jeff Johnson295189b2012-06-20 16:38:30 -07004220 //set gen ie
4221 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
4222
4223 //set auth
4224 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
4225 }
4226#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004227 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004228 if (pAdapter->wapi_info.nWapiMode)
4229 {
4230 switch (pAdapter->wapi_info.wapiAuthMode)
4231 {
4232 case WAPI_AUTH_MODE_PSK:
4233 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004234 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 pRoamProfile->AuthType.numEntries = 1;
4236 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4237 break;
4238 }
4239 case WAPI_AUTH_MODE_CERT:
4240 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004241 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 pRoamProfile->AuthType.numEntries = 1;
4243 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4244 break;
4245 }
4246 } // End of switch
4247 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
4248 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
4249 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004250 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004251 pRoamProfile->EncryptionType.numEntries = 1;
4252 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4253 pRoamProfile->mcEncryptionType.numEntries = 1;
4254 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4255 }
4256 }
4257#endif /* FEATURE_WLAN_WAPI */
4258 /* if previous genIE is not NULL, update AssocIE */
4259 if (0 != pWextState->genIE.length)
4260 {
4261 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
4262 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
4263 pWextState->genIE.length);
4264 pWextState->assocAddIE.length = pWextState->genIE.length;
4265 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
4266 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
4267
4268 /* clear previous genIE after use it */
4269 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
4270 }
4271
4272 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
4273 pWextState->roamProfile.bWPSAssociation = FALSE;
4274
4275 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
4276 pWextState->roamProfile.nAddIEAssocLength))
4277 pWextState->roamProfile.bWPSAssociation = TRUE;
4278
4279
4280 // Disable auto BMPS entry by PMC until DHCP is done
4281 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
4282
Shailender Karmuchia734f332013-04-19 14:02:48 -07004283 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004285
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004286 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
4287 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004288 hdd_select_cbmode(pAdapter,
4289 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
4290 }
Agarwal Ashish40f9b872015-09-01 16:17:35 +05304291 /*
4292 * Change conn_state to connecting before sme_RoamConnect(),
4293 * because sme_RoamConnect() has a direct path to call
4294 * hdd_smeRoamCallback(), which will change the conn_state
4295 * If direct path, conn_state will be accordingly changed
4296 * to NotConnected or Associated by either
4297 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
4298 * in sme_RoamCallback()
4299 * if sme_RomConnect is to be queued,
4300 * Connecting state will remain until it is completed.
4301 *
4302 * If connection state is not changed,
4303 * connection state will remain in eConnectionState_NotConnected state.
4304 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
4305 * if conn state is eConnectionState_NotConnected.
4306 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
4307 * informed of connect result indication which is an issue.
4308 */
4309 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
4310 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
4311 {
4312 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4313 FL("Set HDD connState to eConnectionState_Connecting"));
4314 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
4315 eConnectionState_Connecting);
4316 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004317 status = sme_RoamConnect( hHal,pAdapter->sessionId,
4318 &(pWextState->roamProfile), &roamId);
Agarwal Ashish40f9b872015-09-01 16:17:35 +05304319
4320 if ((eHAL_STATUS_SUCCESS != status) &&
4321 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
4322 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4323 {
4324 hddLog(VOS_TRACE_LEVEL_ERROR,
4325 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
4326 pAdapter->sessionId, status);
4327 /* change back to NotAssociated */
4328 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
4329 eConnectionState_NotConnected);
4330 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004331 pRoamProfile->ChannelInfo.ChannelList = NULL;
4332 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004333
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004334 EXIT();
4335 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004336}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004337
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304338int iw_set_essid(struct net_device *dev,
4339 struct iw_request_info *info,
4340 union iwreq_data *wrqu, char *extra)
4341{
4342 int ret;
4343
4344 vos_ssr_protect(__func__);
4345 ret = __iw_set_essid(dev, info, wrqu, extra);
4346 vos_ssr_unprotect(__func__);
4347
4348 return ret;
4349}
4350
Jeff Johnson295189b2012-06-20 16:38:30 -07004351/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004352
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304353 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004354 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004355
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 \param - dev - Pointer to the net device.
4357 - info - Pointer to the iw_request_info.
4358 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004359 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004360 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004361
Jeff Johnson295189b2012-06-20 16:38:30 -07004362 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304363int __iw_get_essid(struct net_device *dev,
4364 struct iw_request_info *info,
4365 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004366{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304367 hdd_adapter_t *pAdapter;
4368 hdd_context_t *pHddCtx;
4369 hdd_wext_state_t *wextBuf;
4370 hdd_station_ctx_t *pHddStaCtx;
4371 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304372
Jeff Johnson295189b2012-06-20 16:38:30 -07004373 ENTER();
4374
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304375 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4376 if (NULL == pAdapter)
4377 {
4378 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4379 "%s: Adapter is NULL",__func__);
4380 return -EINVAL;
4381 }
4382
4383 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4384 ret = wlan_hdd_validate_context(pHddCtx);
4385 if (0 != ret)
4386 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304387 return ret;
4388 }
4389
4390 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4391 if (NULL == pHddStaCtx)
4392 {
4393 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4394 "%s: STA Context is NULL",__func__);
4395 return -EINVAL;
4396 }
4397
4398 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4399 if (NULL == wextBuf)
4400 {
4401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4402 "%s: wextBuf is NULL",__func__);
4403 return -EINVAL;
4404 }
4405
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
4407 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
4408 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
4409 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
4410 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
4411 {
4412 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
4413 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
4414 dwrq->flags = 1;
4415 } else {
4416 memset(extra, 0, dwrq->length);
4417 dwrq->length = 0;
4418 dwrq->flags = 0;
4419 }
4420 EXIT();
4421 return 0;
4422}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304423
4424int iw_get_essid(struct net_device *dev,
4425 struct iw_request_info *info,
4426 struct iw_point *dwrq, char *extra)
4427{
4428 int ret;
4429
4430 vos_ssr_protect(__func__);
4431 ret = __iw_get_essid(dev, info, dwrq, extra);
4432 vos_ssr_unprotect(__func__);
4433
4434 return ret;
4435}
Jeff Johnson295189b2012-06-20 16:38:30 -07004436/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004437
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304438 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004439 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004440
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 \param - dev - Pointer to the net device.
4442 - info - Pointer to the iw_request_info.
4443 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004444 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004445 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004446
Jeff Johnson295189b2012-06-20 16:38:30 -07004447 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304448int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
4449 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004450{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304451 hdd_adapter_t *pAdapter;
4452 hdd_context_t *pHddCtx;
4453 hdd_wext_state_t *pWextState;
4454 hdd_station_ctx_t *pHddStaCtx;
4455 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004456 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07004457 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304458 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004459
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004461
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304462 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4463 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004464 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4466 "%s: Adapter is NULL",__func__);
4467 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004468 }
4469
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304470 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4471 ret = wlan_hdd_validate_context(pHddCtx);
4472 if (0 != ret)
4473 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304474 return ret;
4475 }
4476
4477 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4478 if (NULL == pHddStaCtx)
4479 {
4480 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4481 "%s: STA Context is NULL",__func__);
4482 return -EINVAL;
4483 }
4484
4485 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4486 if (NULL == pWextState)
4487 {
4488 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4489 "%s: pWextState is NULL",__func__);
4490 return -EINVAL;
4491 }
4492
4493 pRoamProfile = &pWextState->roamProfile;
4494
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 switch(wrqu->param.flags & IW_AUTH_INDEX)
4496 {
4497 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004498
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004500
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004502
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 case IW_AUTH_CIPHER_PAIRWISE:
4504 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004505 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004506 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004507 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4509 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004510 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004511 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
4512 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004513 }
4514
Jeff Johnson295189b2012-06-20 16:38:30 -07004515 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004516
4517 if( (IW_AUTH_KEY_MGMT_802_1X
4518 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004519 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
4520 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004521 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07004522 else
4523 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004524 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4525 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004526 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004527
4528 if( ( IW_AUTH_KEY_MGMT_802_1X
4529 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004530 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4531 /*Dynamic WEP key*/
4532 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4533 else
4534 /*Static WEP key*/
4535 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004536
Jeff Johnson295189b2012-06-20 16:38:30 -07004537 }
4538 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004539
Jeff Johnson295189b2012-06-20 16:38:30 -07004540 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004541 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 return -EINVAL;
4543 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004544
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 pRoamProfile->EncryptionType.numEntries = 1;
4546 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004547 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004548 break;
4549 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004550 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004551 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
4552 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4553 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004554
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4556 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
4557 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004558
4559 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
4561 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004562
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004564
4565 if( ( IW_AUTH_KEY_MGMT_802_1X
4566 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
4567 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4568
Jeff Johnson295189b2012-06-20 16:38:30 -07004569 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004570
4571 else
4572 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004574
4575 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
4576 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004577 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004578 if( ( IW_AUTH_KEY_MGMT_802_1X
4579 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07004580 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4581 {
4582 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4583 }
4584 else
4585 {
4586 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4587 }
4588 }
4589 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004590
Jeff Johnson295189b2012-06-20 16:38:30 -07004591 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004592 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004593 return -EINVAL;
4594 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004595
Jeff Johnson295189b2012-06-20 16:38:30 -07004596 pRoamProfile->mcEncryptionType.numEntries = 1;
4597 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
4598 }
4599 break;
4600
4601 case IW_AUTH_80211_AUTH_ALG:
4602 {
4603 /*Save the auth algo here and set auth type to SME Roam profile
4604 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004605 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004607
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
4609 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
4610
4611 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
4612 /*Not supported*/
4613 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4614 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
4615 }
4616 break;
4617
4618 case IW_AUTH_KEY_MGMT:
4619 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004620#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004621#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
4622 /*Check for CCKM AKM type */
4623 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004624 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
4625 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004626 /* Set the CCKM bit in authKeyMgmt */
4627 /* Right now, this breaks all ref to authKeyMgmt because our
4628 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07004629 */
4630 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
4631 /*Set the key management to 802.1X*/
4632 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004633 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004634 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4635 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
4636 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
4637 /*Save the key management*/
4638 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
4639 //pWextState->authKeyMgmt = wrqu->param.value;
4640 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4641 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4642 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
4643 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
4644 /*Save the key management anyway*/
4645 pWextState->authKeyMgmt = wrqu->param.value;
4646 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
4647 /*Save the key management*/
4648 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
4649 //pWextState->authKeyMgmt = wrqu->param.value;
4650 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4651 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4652 }
4653#else
4654 /*Save the key management*/
4655 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004656#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004657 }
4658 break;
4659
4660 case IW_AUTH_TKIP_COUNTERMEASURES:
4661 {
4662 if(wrqu->param.value) {
4663 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4664 "Counter Measure started %d", wrqu->param.value);
4665 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
4666 }
4667 else {
4668 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4669 "Counter Measure stopped=%d", wrqu->param.value);
4670 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
4671 }
4672 }
4673 break;
4674 case IW_AUTH_DROP_UNENCRYPTED:
4675 case IW_AUTH_WPA_ENABLED:
4676 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
4677 case IW_AUTH_ROAMING_CONTROL:
4678 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004679
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004681
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004682 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004683 wrqu->param.flags & IW_AUTH_INDEX);
4684 break;
4685 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004686
Jeff Johnson295189b2012-06-20 16:38:30 -07004687 EXIT();
4688 return 0;
4689}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304690
4691int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
4692 union iwreq_data *wrqu, char *extra)
4693{
4694 int ret;
4695
4696 vos_ssr_protect(__func__);
4697 ret = __iw_set_auth(dev, info, wrqu, extra);
4698 vos_ssr_unprotect(__func__);
4699
4700 return ret;
4701}
4702
Jeff Johnson295189b2012-06-20 16:38:30 -07004703/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004704
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304705 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004706 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004707
Jeff Johnson295189b2012-06-20 16:38:30 -07004708 \param - dev - Pointer to the net device.
4709 - info - Pointer to the iw_request_info.
4710 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004711 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004713
Jeff Johnson295189b2012-06-20 16:38:30 -07004714 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304715int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4716 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004717{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304718 hdd_adapter_t* pAdapter;
4719 hdd_wext_state_t *pWextState;
4720 tCsrRoamProfile *pRoamProfile;
4721 hdd_context_t *pHddCtx;
4722 int ret = 0;
4723
Jeff Johnson295189b2012-06-20 16:38:30 -07004724 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004725
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304726 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4727 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004728 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304729 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4730 "%s: Adapter is NULL",__func__);
4731 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004732 }
4733
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304734 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4735 ret = wlan_hdd_validate_context(pHddCtx);
4736 if (0 != ret)
4737 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304738 return ret;
4739 }
4740
4741 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4742 if (NULL == pWextState)
4743 {
4744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4745 "%s: pWextState is NULL",__func__);
4746 return -EINVAL;
4747 }
4748 pRoamProfile = &pWextState->roamProfile;
4749
Jeff Johnson295189b2012-06-20 16:38:30 -07004750 switch(pRoamProfile->negotiatedAuthType)
4751 {
4752 case eCSR_AUTH_TYPE_WPA_NONE:
4753 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4754 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
4755 break;
4756 case eCSR_AUTH_TYPE_WPA:
4757 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4758 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
4759 break;
4760#ifdef WLAN_FEATURE_VOWIFI_11R
4761 case eCSR_AUTH_TYPE_FT_RSN:
4762#endif
4763 case eCSR_AUTH_TYPE_RSN:
4764 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4765 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
4766 break;
4767 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4768 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4769 break;
4770 case eCSR_AUTH_TYPE_SHARED_KEY:
4771 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
4772 break;
4773 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004774 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004775 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4776 break;
4777 case eCSR_AUTH_TYPE_AUTOSWITCH:
4778 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4779 break;
4780 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304781 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004782 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4783 return -EIO;
4784#ifdef WLAN_FEATURE_VOWIFI_11R
4785 case eCSR_AUTH_TYPE_FT_RSN_PSK:
4786#endif
4787 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07004788#ifdef WLAN_FEATURE_11W
4789 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05304790 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07004791#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05304792 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004793 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4794 return -EIO;
4795 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304796 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004797 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4798 return -EIO;
4799 }
4800 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
4801 {
4802 switch(pRoamProfile->negotiatedUCEncryptionType)
4803 {
4804 case eCSR_ENCRYPT_TYPE_NONE:
4805 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4806 break;
4807 case eCSR_ENCRYPT_TYPE_WEP40:
4808 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4809 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4810 break;
4811 case eCSR_ENCRYPT_TYPE_TKIP:
4812 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4813 break;
4814 case eCSR_ENCRYPT_TYPE_WEP104:
4815 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4816 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4817 break;
4818 case eCSR_ENCRYPT_TYPE_AES:
4819 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4820 break;
4821 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304822 hddLog(LOG1, "%s called with unknown auth type %d ",
4823 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004824 return -EIO;
4825 }
4826 }
4827
Shailender Karmuchia734f332013-04-19 14:02:48 -07004828 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07004829 {
4830 switch(pRoamProfile->negotiatedMCEncryptionType)
4831 {
4832 case eCSR_ENCRYPT_TYPE_NONE:
4833 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4834 break;
4835 case eCSR_ENCRYPT_TYPE_WEP40:
4836 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4837 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4838 break;
4839 case eCSR_ENCRYPT_TYPE_TKIP:
4840 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4841 break;
4842 case eCSR_ENCRYPT_TYPE_WEP104:
4843 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4844 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4845 break;
4846 case eCSR_ENCRYPT_TYPE_AES:
4847 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4848 break;
4849 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304850 hddLog(LOG1, "%s called with unknown auth type %d ",
4851 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004852 return -EIO;
4853 }
4854 }
4855
4856 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004857 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004858 EXIT();
4859 return 0;
4860}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304861
4862int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4863 union iwreq_data *wrqu,char *extra)
4864{
4865 int ret;
4866
4867 vos_ssr_protect(__func__);
4868 ret = __iw_get_auth(dev, info, wrqu, extra);
4869 vos_ssr_unprotect(__func__);
4870
4871 return ret;
4872}
4873
Jeff Johnson295189b2012-06-20 16:38:30 -07004874/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004875
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304876 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07004877 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07004878 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004879
Jeff Johnson295189b2012-06-20 16:38:30 -07004880 \param - dev - Pointer to the net device.
4881 - info - Pointer to the iw_request_info.
4882 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004883 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004884 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004885
Jeff Johnson295189b2012-06-20 16:38:30 -07004886 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304887int __iw_set_ap_address(struct net_device *dev,
4888 struct iw_request_info *info,
4889 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004890{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304891 hdd_station_ctx_t *pHddStaCtx;
4892 hdd_adapter_t *pAdapter;
4893 hdd_context_t *pHddCtx;
4894 v_U8_t *pMacAddress = NULL;
4895 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304896
Jeff Johnson295189b2012-06-20 16:38:30 -07004897 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304898
4899 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4900 if (NULL == pAdapter)
4901 {
4902 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4903 "%s: Adapter is NULL", __func__);
4904 return -EINVAL;
4905 }
4906 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4907 ret = wlan_hdd_validate_context(pHddCtx);
4908 if (0 != ret)
4909 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304910 return ret;
4911 }
4912 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4913 if (NULL == pHddStaCtx)
4914 {
4915 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4916 "%s: pHddStaCtx is NULL", __func__);
4917 return -EINVAL;
4918 }
4919
Jeff Johnson295189b2012-06-20 16:38:30 -07004920 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08004921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
4922 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07004923 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07004924
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304925 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004926 return 0;
4927}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304928
4929int iw_set_ap_address(struct net_device *dev,
4930 struct iw_request_info *info,
4931 union iwreq_data *wrqu, char *extra)
4932{
4933 int ret;
4934
4935 vos_ssr_protect(__func__);
4936 ret = __iw_set_ap_address(dev, info, wrqu, extra);
4937 vos_ssr_unprotect(__func__);
4938
4939 return ret;
4940}
4941
Jeff Johnson295189b2012-06-20 16:38:30 -07004942/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004943
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304944 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004945 This function returns the BSSID to the wpa_supplicant
4946 \param - dev - Pointer to the net device.
4947 - info - Pointer to the iw_request_info.
4948 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004949 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004951
Jeff Johnson295189b2012-06-20 16:38:30 -07004952 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304953int __iw_get_ap_address(struct net_device *dev,
4954 struct iw_request_info *info,
4955 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004956{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304957 hdd_station_ctx_t *pHddStaCtx;
4958 hdd_adapter_t *pAdapter;
4959 hdd_context_t *pHddCtx;
4960 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304961
Jeff Johnson295189b2012-06-20 16:38:30 -07004962 ENTER();
4963
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304964 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4965 if (NULL == pAdapter)
4966 {
4967 hddLog(VOS_TRACE_LEVEL_ERROR,
4968 "%s: Adapter is NULL", __func__);
4969 return -EINVAL;
4970 }
4971 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4972 ret = wlan_hdd_validate_context(pHddCtx);
4973 if (0 != ret)
4974 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304975 return ret;
4976 }
4977 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4978 if (NULL == pHddStaCtx)
4979 {
4980 hddLog(VOS_TRACE_LEVEL_ERROR,
4981 "%s: pHddStaCtx is NULL", __func__);
4982 return -EINVAL;
4983 }
4984
Jeff Johnson295189b2012-06-20 16:38:30 -07004985 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
4986 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
4987 {
Jeff Johnson4416a782013-03-25 14:17:50 -07004988 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07004989 }
4990 else
4991 {
4992 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4993 }
4994 EXIT();
4995 return 0;
4996}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004997
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304998int iw_get_ap_address(struct net_device *dev,
4999 struct iw_request_info *info,
5000 union iwreq_data *wrqu, char *extra)
5001{
5002 int ret;
5003
5004 vos_ssr_protect(__func__);
5005 ret = __iw_get_ap_address(dev, info, wrqu, extra);
5006 vos_ssr_unprotect(__func__);
5007
5008 return ret;
5009}
5010
Chet Lanctot186b5732013-03-18 10:26:30 -07005011#ifdef WLAN_FEATURE_11W
5012/**---------------------------------------------------------------------------
5013
5014 \brief hdd_indicateUnprotMgmtFrame -
5015 This function forwards the unprotected management frame to the supplicant
5016 \param - pAdapter - Pointer to HDD adapter
5017 - nFrameLength - Length of the unprotected frame being passed
5018 - pbFrames - Pointer to the frame buffer
5019 - frameType - 802.11 frame type
5020 \return - nothing
5021
5022 --------------------------------------------------------------------------*/
5023void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
5024 tANI_U32 nFrameLength,
5025 tANI_U8* pbFrames,
5026 tANI_U8 frameType )
5027{
5028 tANI_U8 type = 0;
5029 tANI_U8 subType = 0;
5030
5031 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
5032 __func__, frameType, nFrameLength);
5033
5034 /* Sanity Checks */
5035 if (NULL == pAdapter)
5036 {
5037 hddLog( LOGE, FL("pAdapter is NULL"));
5038 return;
5039 }
5040
5041 if (NULL == pAdapter->dev)
5042 {
5043 hddLog( LOGE, FL("pAdapter->dev is NULL"));
5044 return;
5045 }
5046
5047 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
5048 {
5049 hddLog( LOGE, FL("pAdapter has invalid magic"));
5050 return;
5051 }
5052
5053 if( !nFrameLength )
5054 {
5055 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
5056 return;
5057 }
5058
5059 if (NULL == pbFrames) {
5060 hddLog( LOGE, FL("pbFrames is NULL"));
5061 return;
5062 }
5063
5064 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
5065 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
5066
5067 /* Get pAdapter from Destination mac address of the frame */
5068 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
5069 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305070#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5071 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5072#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005073 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305074#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005075 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
5076 }
5077 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
5078 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305079#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5080 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5081#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005082 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305083#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005084 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
5085 }
5086 else
5087 {
5088 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
5089 return;
5090 }
5091}
5092#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005093
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005094#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005095void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
5096 tANI_U8 state,
5097 tANI_U16 measInterval )
5098{
5099 union iwreq_data wrqu;
5100 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005101 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005102
5103 if (NULL == pAdapter)
5104 return;
5105
5106 // create the event
5107 memset(&wrqu, '\0', sizeof(wrqu));
5108 memset(buf, '\0', sizeof(buf));
5109
5110 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
5111 tid, state, measInterval);
5112
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005113 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005114
5115 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005116 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005117 // send the event
5118 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5119}
5120
5121void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
5122{
5123 union iwreq_data wrqu;
5124 char buf[IW_CUSTOM_MAX + 1];
5125 char *pos = buf;
5126 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5127
5128 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5129 return;
5130
5131 // create the event
5132 memset(&wrqu, '\0', sizeof(wrqu));
5133 memset(buf, '\0', sizeof(buf));
5134
5135 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305136 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
5137 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
5138 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
5139 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005140
5141 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
5142 pos += nBytes;
5143 freeBytes -= nBytes;
5144
5145 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
5146 pos += WNI_CFG_BSSID_LEN;
5147 freeBytes -= WNI_CFG_BSSID_LEN;
5148
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005149 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
5150 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005151
5152 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005153 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005154
5155 // send the event
5156 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5157}
5158
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005159void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005160{
5161 union iwreq_data wrqu;
5162 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005163 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005164
5165 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5166 return;
5167
5168 // create the event
5169 memset(&wrqu, '\0', sizeof(wrqu));
5170 memset(buf, '\0', sizeof(buf));
5171
5172 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
5173
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005174 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005175
5176 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005177 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005178
5179 // send the event
5180 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5181}
5182
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005183void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
5184 const tANI_U16 measurementToken,
5185 const tANI_BOOLEAN flag,
5186 const tANI_U8 numBss)
5187{
5188 union iwreq_data wrqu;
5189 char buf[IW_CUSTOM_MAX];
5190 char *pos = buf;
5191 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5192
5193 memset(&wrqu, '\0', sizeof(wrqu));
5194 memset(buf, '\0', sizeof(buf));
5195
5196 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
5197 numBss);
5198
5199 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
5200 flag, numBss);
5201
5202 wrqu.data.pointer = buf;
5203 wrqu.data.length = nBytes;
5204 // send the event
5205 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5206}
5207
5208
5209static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005210 const tCsrRoamInfo *pRoamInfo)
5211{
5212 union iwreq_data wrqu;
5213 char buf[IW_CUSTOM_MAX + 1];
5214 char *pos = buf;
5215 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5216 tANI_U8 i = 0, len = 0;
5217 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
5218 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005219 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
5220 tANI_U8 ieLenByte = 1;
5221 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
5222#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005223
5224 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5225 return;
5226
5227 /* Custom event can pass maximum of 256 bytes of data,
5228 based on the IE len we need to identify how many BSS info can
5229 be filled in to custom event data */
5230 /*
5231 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
5232 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
5233 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
5234 */
5235
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005236 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005237 {
5238 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
5239 /* If the measurement is none and no scan results found,
5240 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005241 hdd_indicateEseBcnReportNoResults(pAdapter,
5242 pRoamInfo->pEseBcnReportRsp->measurementToken,
5243 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005244 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005245 }
5246 else
5247 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005248 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005249 {
5250 memset(&wrqu, '\0', sizeof(wrqu));
5251 memset(buf, '\0', sizeof(buf));
5252 tot_bcn_ieLen = 0;
5253 sendBss = 0;
5254 pos = buf;
5255 freeBytes = IW_CUSTOM_MAX;
5256
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005257 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005258 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005259 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
5260 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005261 {
5262 break;
5263 }
5264 tot_bcn_ieLen += len;
5265 sendBss++;
5266 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
5267 "IeLength(%d) Length of Ie(%d) totLen(%d)",
5268 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005269 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005270 tot_bcn_ieLen);
5271 }
5272
5273 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
5274 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005275 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5276 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005277
5278 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005279 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5280 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005281 pos += nBytes;
5282 freeBytes -= nBytes;
5283
5284 /* Copy total Beacon report data length */
5285 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
5286 pos += sizeof(tot_bcn_ieLen);
5287 freeBytes -= sizeof(tot_bcn_ieLen);
5288
5289 for (i = 0; i < sendBss; i++)
5290 {
5291 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305292 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
5293 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005294 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005295 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
5296 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
5297 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
5298 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
5299 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
5300 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
5301 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
5302 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
5303 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
5304 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
5305 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
5306 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
5307 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
5308 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
5309 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
5310 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005311
5312 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005313 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
5314 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005315 pos += len;
5316 freeBytes -= len;
5317
5318 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005319 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005320 vos_mem_copy(pos, (char*)&len, sizeof(len));
5321 pos += sizeof(len);
5322 freeBytes -= sizeof(len);
5323
5324 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005325 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005326 pos += len;
5327 freeBytes -= len;
5328 }
5329
5330 wrqu.data.pointer = buf;
5331 wrqu.data.length = strlen(buf);
5332
5333 // send the event
5334 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5335 lastSent += sendBss;
5336 }
5337 }
5338}
5339
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005340#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005341