blob: 5ae44ba154e4cc5822fb91e17c895c18155e6fd3 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Masti, Narayanraddie1892a52015-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 Shah66896792015-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 Gowri1d3aa3c2015-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 Gowri1d3aa3c2015-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 Shah66896792015-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
1029 * to kernel. Sending disconnected event to kernel for userspaces
1030 * initiated disconnect will be handled by hdd_DisConnectHandler call
1031 * to cfg80211_disconnected.
1032 */
1033 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 {
1095 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
1096 }
1097 else
1098 {
1099 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
1100 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001101 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301102
1103 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1104 {
1105 hddLog(LOG1,
1106 FL("P2P client is getting removed and we are tryig to re-enable TDLS"));
1107 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301108 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301109
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 //If the Device Mode is Station
1111 // and the P2P Client is Connected
1112 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001113
1114 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001115 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07001116 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -07001117 {
1118 //Enable BMPS only of other Session is P2P Client
1119 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001120 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001121
1122 if (NULL != pVosContext)
1123 {
1124 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1125
1126 if(NULL != pHddCtx)
1127 {
1128 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301129 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1130 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001131 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301132 if (pHddCtx->hdd_wlan_suspended)
1133 {
1134 hdd_set_pwrparams(pHddCtx);
1135 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001136 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301137 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 }
1139 }
1140 }
1141 }
1142 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001143
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +05301144 hdd_wmm_adapter_clear(pAdapter);
Mukul Sharmac159c432014-01-15 15:42:46 +05301145#if defined(WLAN_FEATURE_VOWIFI_11R)
1146 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
1147#endif
Katya Nigam63ce1772014-09-26 15:53:49 +05301148
1149 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
1150 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301151 v_U8_t i;
1152
Katya Nigam63ce1772014-09-26 15:53:49 +05301153 sta_id = IBSS_BROADCAST_STAID;
Katya Nigam47528772015-02-11 12:24:49 +05301154 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Katya Nigam63ce1772014-09-26 15:53:49 +05301155 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1156 {
1157 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301158 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1159 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +05301160 sta_id, status, status );
1161
1162 status = eHAL_STATUS_FAILURE;
1163 }
Katya Nigam63ce1772014-09-26 15:53:49 +05301164 pHddCtx->sta_to_adapter[sta_id] = NULL;
1165
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301166 /*Clear all the peer sta register with TL.*/
1167 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
1168 {
1169 if (0 != pHddStaCtx->conn_info.staId[i])
1170 {
1171 sta_id = pHddStaCtx->conn_info.staId[i];
1172
1173 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1174 FL("Deregister StaID %d"),sta_id);
Katya Nigam47528772015-02-11 12:24:49 +05301175 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301176 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1177 {
1178 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1179 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1180 "Status= %d [0x%x]"),
1181 sta_id, status, status );
1182 status = eHAL_STATUS_FAILURE;
1183 }
1184
Nirav Shah7e3c8132015-06-22 23:51:42 +05301185 vstatus = hdd_sta_id_hash_remove_entry(pAdapter,
1186 sta_id, &pHddStaCtx->conn_info.peerMacAddress[i]);
1187 if (vstatus != VOS_STATUS_SUCCESS) {
1188 hddLog(VOS_TRACE_LEVEL_ERROR,
1189 FL("Not able to remove staid hash %d"),
1190 sta_id);
1191 status = eHAL_STATUS_FAILURE;
1192 } else {
1193 hddLog(VOS_TRACE_LEVEL_INFO,
1194 FL("ibss station removed sta_id %d mac:"
1195 MAC_ADDRESS_STR), sta_id,
1196 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[i].bytes));
1197 }
1198
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301199 /*set the staid and peer mac as 0, all other reset are
1200 * done in hdd_connRemoveConnectInfo.
1201 */
1202 pHddStaCtx->conn_info.staId[i]= 0;
1203 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
1204
1205 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1206 pHddCtx->sta_to_adapter[sta_id] = NULL;
1207 }
1208 }
1209
Katya Nigam63ce1772014-09-26 15:53:49 +05301210 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301211 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001212 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301213 sta_id = pHddStaCtx->conn_info.staId[0];
1214
1215 //We should clear all sta register with TL, for now, only one.
1216 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
1217 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1218 {
1219 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1220 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1221 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -07001222 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001223
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301224 status = eHAL_STATUS_FAILURE;
1225 }
1226
1227 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 }
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301229
1230#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1231 if (VOS_STATUS_SUCCESS !=
1232 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1233 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE_AC))
1234 {
1235 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1236 "WLANTL_ClearInterfaceStats Failed", __func__);
1237 }
1238 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1239 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1240 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1241 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1242#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1243
Jeff Johnson295189b2012-06-20 16:38:30 -07001244 // Clear saved connection information in HDD
1245 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhf4669da2014-05-26 15:07:49 +05301246 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1247 "%s: Set HDD connState to eConnectionState_NotConnected",
1248 __func__);
1249 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301250#ifdef WLAN_FEATURE_GTK_OFFLOAD
1251 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1252 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1253 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301254 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1255 sizeof (tSirGtkOffloadParams));
1256 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301257 }
1258#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001259
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001260#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001261 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1262 {
1263 wlan_hdd_tdls_disconnection_callback(pAdapter);
1264 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001265#endif
1266
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 //Unblock anyone waiting for disconnect to complete
1268 complete(&pAdapter->disconnect_comp_var);
1269 return( status );
1270}
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301271
1272static void hdd_postTLPacketPendingInd(hdd_adapter_t *pAdapter,
1273 v_U8_t staId)
1274{
1275 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1276 v_SINT_t i;
1277 v_SIZE_t size;
1278 VOS_STATUS status;
1279 v_BOOL_t granted = VOS_FALSE;
1280
1281 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1282 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ||
1283 (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE))
1284 {
1285 //Indicate to TL that there is pending data if a queue is non empty
1286 for (i = WLANTL_AC_HIGH_PRIO; i>=0; --i)
1287 {
1288 size = 0;
1289 hdd_list_size(&pAdapter->wmm_tx_queue[i], &size);
1290 if (size > 0)
1291 {
1292 if (i != WLANTL_AC_HIGH_PRIO)
1293 {
1294 if (VOS_FALSE ==
1295 pAdapter->hddWmmStatus.wmmAcStatus[i].wmmAcAccessAllowed)
1296 {
1297 hdd_wmm_acquire_access(pAdapter,
1298 (WLANTL_ACEnumType)i, &granted);
1299 pAdapter->psbChanged |= (1 << i);
1300 }
1301 else
1302 granted = VOS_TRUE;
1303 }
1304
1305 if (granted || (i == WLANTL_AC_HIGH_PRIO))
1306 {
1307 status = WLANTL_STAPktPending(pHddCtx->pvosContext,
1308 staId, (WLANTL_ACEnumType)i);
1309 if (!VOS_IS_STATUS_SUCCESS(status))
1310 {
1311 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1312 "%s: Failure in indicating pkt to TL for QID=%d",
1313 __func__, i);
1314 }
1315 }
1316 }
1317 }
1318 }
1319}
1320
Jeff Johnson295189b2012-06-20 16:38:30 -07001321static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
1322 tCsrRoamInfo *pRoamInfo,
1323 v_U8_t staId,
1324 v_MACADDR_t *pPeerMacAddress,
1325 tSirBssDescription *pBssDesc )
1326{
1327 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1328 WLAN_STADescType staDesc = {0};
1329 eCsrEncryptionType connectedCipherAlgo;
1330 v_BOOL_t fConnected;
1331 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1332 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001333 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001334
1335 if ( NULL == pBssDesc)
1336 {
1337 return VOS_STATUS_E_FAILURE;
1338 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 // Get the Station ID from the one saved during the assocation.
1340 staDesc.ucSTAId = staId;
1341
Katya Nigam47528772015-02-11 12:24:49 +05301342 staDesc.wSTAType = WLAN_STA_INFRA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001343
Katya Nigam47528772015-02-11 12:24:49 +05301344 // grab the bssid from the connection info in the adapter structure and hand that
1345 // over to TL when registering.
1346 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,
1347 sizeof(pHddStaCtx->conn_info.bssId) );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001348
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1350
1351 // set the QoS field appropriately
1352 if (hdd_wmm_is_active(pAdapter))
1353 {
1354 staDesc.ucQosEnabled = 1;
1355 }
1356 else
1357 {
1358 staDesc.ucQosEnabled = 0;
1359 }
1360
1361 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1362 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1363 {
1364 staDesc.ucProtectedFrame = 1;
1365 }
1366 else
1367 {
1368 staDesc.ucProtectedFrame = 0;
1369
1370 }
1371
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001372#ifdef FEATURE_WLAN_ESE
1373 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
1374#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001375
1376#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1377 /* check whether replay check is valid for the station or not */
1378 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
1379 {
1380 /* Encryption mode is either TKIP or AES
1381 and replay check is valid for only these
1382 two encryption modes */
1383 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1384 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1385 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1386 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001387
Jeff Johnson295189b2012-06-20 16:38:30 -07001388 else
1389 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001390 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001391 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001392 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001393 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1394 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1395 }
1396#endif
1397
1398#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001399 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 if (pAdapter->wapi_info.fIsWapiSta)
1401 {
1402 staDesc.ucIsWapiSta = 1;
1403 }
1404 else
1405 {
1406 staDesc.ucIsWapiSta = 0;
1407 }
1408#endif /* FEATURE_WLAN_WAPI */
1409
1410 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1411 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1412
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 // UMA is Not ready yet, Xlation will be done by TL
1414 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001415 staDesc.ucSwFrameRXXlation = 1;
1416 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001417 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 staDesc.ucQosEnabled );
1419 // Initialize signatures and state
1420 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1421 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1422 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1423 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001424 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001425 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 -07001426 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1427 hdd_rx_packet_cbk,
1428 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 hdd_tx_fetch_packet_cbk, &staDesc,
1430 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001431
Jeff Johnson295189b2012-06-20 16:38:30 -07001432 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1433 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001434 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001435 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001436 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001437 return vosStatus;
1438 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001439
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001440 if ( cfg_param->dynSplitscan &&
1441 ( VOS_TIMER_STATE_RUNNING !=
1442 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1443 {
1444 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1445 cfg_param->trafficMntrTmrForSplitScan);
1446 }
1447
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301448 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1449 // then go to 'authenticated'. For all other authentication types
1450 // (those that donot require upper layer authentication) we can put
1451 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001452 if (staDesc.wSTAType != WLAN_STA_IBSS)
1453 VOS_ASSERT( fConnected );
1454
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301455 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001456 {
1457 // Connections that do not need Upper layer auth, transition TL directly
1458 // to 'Authenticated' state.
1459 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1460 WLANTL_STA_AUTHENTICATED );
1461
1462 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301463
1464 hdd_postTLPacketPendingInd(pAdapter, staDesc.ucSTAId);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001465 }
1466 else
1467 {
1468 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301469 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1470 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001471 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301472 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001473 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1474 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001475 return( vosStatus );
1476}
1477
Jeff Johnson295189b2012-06-20 16:38:30 -07001478static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1479 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1480{
1481 unsigned int len = 0;
1482 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001483 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001484 tANI_U32 rspRsnLength = 0;
1485 struct ieee80211_channel *chan;
1486
Agarwal Ashish51325b52014-06-16 16:50:49 +05301487 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001488 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001489 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001490 }
1491
Agarwal Ashish51325b52014-06-16 16:50:49 +05301492 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001493 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1494 goto done;
1495 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001496
Agarwal Ashish51325b52014-06-16 16:50:49 +05301497 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001498 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1499 goto done;
1500 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001501
1502 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1503 pCsrRoamInfo->nAssocReqLength);
1504 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001505 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001506
1507 //pFTAssocRsp needs to point to the IEs
1508 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001509 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001510 (unsigned int)pFTAssocRsp[0],
1511 (unsigned int)pFTAssocRsp[1]);
1512
1513 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001514 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001515 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001516 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001517 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001518
1519 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1520 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1521 reqRsnIe, reqRsnLength,
1522 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001523
1524done:
1525 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001526}
Jeff Johnson295189b2012-06-20 16:38:30 -07001527
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301528void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1529{
1530 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1531 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1532 tCsrRoamInfo roamInfo;
1533 roamInfo.fAuthRequired = FALSE;
1534 vos_mem_copy(roamInfo.bssid,
1535 pHddStaCtx->roam_info.bssid,
1536 WNI_CFG_BSSID_LEN);
1537 vos_mem_copy(roamInfo.peerMac,
1538 pHddStaCtx->roam_info.peerMac,
1539 WNI_CFG_BSSID_LEN);
1540
1541 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1542 &roamInfo,
1543 pHddStaCtx->roam_info.roamId,
1544 pHddStaCtx->roam_info.roamStatus,
1545 eCSR_ROAM_RESULT_AUTHENTICATED);
1546 if (halStatus != eHAL_STATUS_SUCCESS)
1547 {
1548 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1549 }
1550 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1551}
1552
Shailender Karmuchia734f332013-04-19 14:02:48 -07001553static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1554 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001555 eCsrRoamResult roamResult )
1556{
1557 struct net_device *dev = pAdapter->dev;
1558 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1559 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301560 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05301561 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001562 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1563 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001564#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 int ft_carrier_on = FALSE;
1566#endif
1567 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301568 v_BOOL_t hddDisconInProgress = FALSE;
Wu Gao2d18b3d2016-02-01 19:45:45 +08001569 tANI_U16 reason_code;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301570
1571 /* HDD has initiated disconnect, do not send connect result indication
1572 * to kernel as it will be handled by __cfg80211_disconnect.
1573 */
Agarwal Ashishc089cec2015-08-10 13:10:04 +05301574 if (((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
1575 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)) &&
1576 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
1577 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301578 {
1579 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1580 FL(" Disconnect from HDD in progress "));
1581 hddDisconInProgress = TRUE;
1582 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001583
Jeff Johnson295189b2012-06-20 16:38:30 -07001584 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1585 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301586 if ( !hddDisconInProgress )
1587 {
1588 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05301589 "%s: Set HDD connState to eConnectionState_Associated",
1590 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301591 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1592 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001593
c_hpothu44ff4e02014-05-08 00:13:57 +05301594 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001595 // Save the connection info from CSR...
1596 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1597#ifdef FEATURE_WLAN_WAPI
1598 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1599 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1600 {
1601 pAdapter->wapi_info.fIsWapiSta = 1;
1602 }
1603 else
1604 {
1605 pAdapter->wapi_info.fIsWapiSta = 0;
1606 }
1607#endif /* FEATURE_WLAN_WAPI */
1608
1609 // indicate 'connect' status to userspace
1610 hdd_SendAssociationEvent(dev,pRoamInfo);
1611
1612
Shailender Karmuchia734f332013-04-19 14:02:48 -07001613 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 INIT_COMPLETION(pAdapter->linkup_event_var);
1615
1616 /*
1617 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1618 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 -07001619 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 know that the device is getting activated properly.
1621 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001622#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05301623 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 {
1625#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001626 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001627 pAdapter->isLinkUpSvcNeeded = TRUE;
1628
Shailender Karmuchia734f332013-04-19 14:02:48 -07001629 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 pAdapter->isLinkUpSvcNeeded = TRUE;
1631
1632 // Switch on the Carrier to activate the device
1633 netif_carrier_on(dev);
1634
1635 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1636 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1637 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001638 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001639 {
1640 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1641 }
1642
1643 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1644 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001645#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001647 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001648 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001649 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 }
1651#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05301652 /* Check for STAID */
1653 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
1654 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1655 else
1656 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001657
1658 //For reassoc, the station is already registered, all we need is to change the state
1659 //of the STA in TL.
1660 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05301661 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 if( !pRoamInfo->fReassocReq )
1663 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001664 struct cfg80211_bss *bss;
1665#ifdef WLAN_FEATURE_VOWIFI_11R
1666 u8 *pFTAssocRsp = NULL;
1667 unsigned int assocRsplen = 0;
1668 u8 *pFTAssocReq = NULL;
1669 unsigned int assocReqlen = 0;
1670 struct ieee80211_channel *chan;
1671#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001673 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001674
1675 /* add bss_id to cfg80211 data base */
1676 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1677 if (NULL == bss)
1678 {
1679 pr_err("wlan: Not able to create BSS entry\n");
Katya Nigam346d4e92014-09-02 16:16:12 +05301680 netif_carrier_off(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001681 return eHAL_STATUS_FAILURE;
1682 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001683#ifdef WLAN_FEATURE_VOWIFI_11R
1684 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001685 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001686 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001687
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001688 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001689 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001690 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001691 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001692 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001693 // pFTAssocRsp needs to point to the IEs
1694 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1695 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1696 (unsigned int)pFTAssocRsp[0],
1697 (unsigned int)pFTAssocRsp[1]);
1698 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001699 }
1700 else
1701 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001702 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1703 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001704 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001705
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001706 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001707 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001708 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001709 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001710 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001711 if(!ft_carrier_on)
1712 {
1713 // pFTAssocReq needs to point to the IEs
1714 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1715 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1716 (unsigned int)pFTAssocReq[0],
1717 (unsigned int)pFTAssocReq[1]);
1718 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1719 }
1720 else
1721 {
1722 /* This should contain only the FTIEs */
1723 assocReqlen = pRoamInfo->nAssocReqLength;
1724 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001725 }
1726 else
1727 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001728 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1729 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001730 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001731
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001732 if(ft_carrier_on)
1733 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301734 if ( !hddDisconInProgress )
1735 {
1736 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001737 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301738 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001739 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301740 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001741 assocRsplen);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301742 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1743 {
1744 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1745 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301746 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001747 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1748 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301749 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301750 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1751 {
1752 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1753 pRoamInfo->fAuthRequired = FALSE;
1754
1755 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1756 pRoamInfo->bssid,
1757 HDD_MAC_ADDR_LEN);
1758 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1759 pRoamInfo->peerMac,
1760 HDD_MAC_ADDR_LEN);
1761 pHddStaCtx->roam_info.roamId = roamId;
1762 pHddStaCtx->roam_info.roamStatus = roamStatus;
1763 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1764 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001765 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301766 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001767 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001768 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001769 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001770 cfg80211_connect_result(dev, pRoamInfo->bssid,
1771 pFTAssocReq, assocReqlen,
1772 pFTAssocRsp, assocRsplen,
1773 WLAN_STATUS_SUCCESS,
1774 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001775 }
1776 }
1777 else
1778#endif
1779 {
1780 /* wpa supplicant expecting WPA/RSN IE in connect result */
1781 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1782 pAdapter->sessionId,
1783 &reqRsnLength,
1784 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001785
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001786 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1787 pAdapter->sessionId,
1788 &rspRsnLength,
1789 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301790 if ( !hddDisconInProgress )
1791 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001792#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301793 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05301794 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301795 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301796 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1797 {
1798 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1799 }
Mukul Sharma84f27252014-07-14 18:11:42 +05301800 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301801 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001802#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001803
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301804 {
1805 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301806 "%s: sending connect indication to nl80211:"
1807 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301808 " result:%d and Status:%d",
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301809 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1810 roamResult, roamStatus);
1811
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301812 /* inform connect result to nl80211 */
1813 cfg80211_connect_result(dev, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001814 reqRsnIe, reqRsnLength,
1815 rspRsnIe, rspRsnLength,
1816 WLAN_STATUS_SUCCESS,
1817 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301818 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001819 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301821 if ( !hddDisconInProgress )
1822 {
1823 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07001824#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301825 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07001826#endif
1827 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301828 // Register the Station with TL after associated...
1829 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001830 pRoamInfo,
1831 pHddStaCtx->conn_info.staId[ 0 ],
1832 NULL,
1833 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301834 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001835 }
1836 else
1837 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001838 /* wpa supplicant expecting WPA/RSN IE in connect result */
1839 /* in case of reassociation also need to indicate it to supplicant */
1840 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1841 pAdapter->sessionId,
1842 &reqRsnLength,
1843 reqRsnIe);
1844
1845 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001846 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301847 if( pRoamInfo->fAuthRequired )
1848 {
1849 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1850 pHddStaCtx->conn_info.staId[ 0 ],
1851 WLANTL_STA_CONNECTED );
1852 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1853 }
1854 else
1855 {
1856 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1857 "%s: staId: %d Changing TL state to AUTHENTICATED",
1858 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1859 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1860 pHddStaCtx->conn_info.staId[ 0 ],
1861 WLANTL_STA_AUTHENTICATED );
1862 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301863 hdd_postTLPacketPendingInd(pAdapter,
1864 pHddStaCtx->conn_info.staId[0]);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301865 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001866 }
1867
1868 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1869 {
1870 // perform any WMM-related association processing
1871 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1872 }
1873 else
1874 {
1875 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001876 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 vosStatus, vosStatus );
1878 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001879#ifdef WLAN_FEATURE_11W
1880 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1881 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1882#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301883
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05301885 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301886 {
1887 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05301888 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301889 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301890 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1891 {
1892 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
1893 }
Padma, Santhosh Kumar0d576542016-02-18 12:22:51 +05301894#ifdef FEATURE_WLAN_TDLS
1895 wlan_hdd_tdls_connection_callback(pAdapter);
1896#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001897 }
1898 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001899 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1901
1902 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001903 if (pRoamInfo)
Deepthi Gowri1d3aa3c2015-12-28 15:43:17 +05301904 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1905 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
1906 MAC_ADDR_ARRAY(pRoamInfo->bssid), roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001907 else
Deepthi Gowri1d3aa3c2015-12-28 15:43:17 +05301908 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1909 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
Arif Hussain24bafea2013-11-15 15:10:03 -08001910 MAC_ADDR_ARRAY(pWextState->req_bssId),
1911 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001912
Sachin Ahuja674c5112015-10-14 13:16:49 +05301913 if (( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
1914 ((roamResult != eCSR_ROAM_RESULT_ASSOCIATED) &&
1915 (eCSR_ROAM_ASSOCIATION_COMPLETION == roamStatus)))
Abhishek Singh611295e2015-07-09 11:11:54 +05301916 wlan_hdd_get_frame_logs(pAdapter,
Siddharth Bhalda0d1622015-04-24 15:47:49 +05301917 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
1918
Abhishek Singhf4669da2014-05-26 15:07:49 +05301919 /* Set connection state to eConnectionState_NotConnected only when CSR
1920 * has completed operation - with a ASSOCIATION_FAILURE status
1921 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301922 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05301923 {
1924 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1925 "%s: Set HDD connState to eConnectionState_NotConnected",
1926 __func__);
1927 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1928 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05301929 if((pHddCtx->concurrency_mode <= 1) &&
1930 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07001931 {
1932 pHddCtx->isAmpAllowed = VOS_TRUE;
1933 }
1934
1935 //If the Device Mode is Station
1936 // and the P2P Client is Connected
1937 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001938
1939 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001940 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001941 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1942 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05301943 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07001944 {
1945 //Enable BMPS only of other Session is P2P Client
1946 hdd_context_t *pHddCtx = NULL;
1947 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1948
1949 if (NULL != pVosContext)
1950 {
1951 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1952
1953 if(NULL != pHddCtx)
1954 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301955 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301956 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1957 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301958 {
1959 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001960 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301961 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001962 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301963 hdd_enable_bmps_imps(pHddCtx);
1964 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001965 }
1966 }
1967 }
1968
James Zmudafbf5ffc2013-03-25 12:45:35 -07001969 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001970 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301971 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07001972 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301973
1974 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1975 {
1976 hddLog(LOG1,
1977 FL("Assoication Failure for P2P client and we are trying to re-enable TDLS"));
1978 wlan_hdd_tdls_reenable(pHddCtx);
1979 }
1980
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301981 if (pRoamInfo)
1982 hddLog(VOS_TRACE_LEVEL_ERROR,
1983 "%s: send connect failure to nl80211:"
1984 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301985 " result:%d and Status:%d reasonCode %d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301986 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301987 roamResult, roamStatus, pRoamInfo->reasonCode);
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301988 else
1989 hddLog(VOS_TRACE_LEVEL_ERROR,
1990 "%s: connect failed:"
1991 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301992 " result:%d and Status:%d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301993 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
1994 roamResult, roamStatus);
1995
James Zmudafbf5ffc2013-03-25 12:45:35 -07001996 /* inform association failure event to nl80211 */
1997 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1998 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001999 if (pRoamInfo)
2000 cfg80211_connect_result ( dev, pRoamInfo->bssid,
2001 NULL, 0, NULL, 0,
2002 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
2003 GFP_KERNEL );
2004 else
2005 cfg80211_connect_result ( dev, pWextState->req_bssId,
2006 NULL, 0, NULL, 0,
2007 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
2008 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07002009 }
2010 else
2011 {
Wu Gao2d18b3d2016-02-01 19:45:45 +08002012 reason_code = WLAN_STATUS_UNSPECIFIED_FAILURE;
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302013
Wu Gao2d18b3d2016-02-01 19:45:45 +08002014 if (pRoamInfo && pRoamInfo->reasonCode)
2015 reason_code = (tANI_U16)pRoamInfo->reasonCode;
Sushant Kaushik21f28232014-12-18 11:42:46 +05302016
Wu Gao2d18b3d2016-02-01 19:45:45 +08002017 cfg80211_connect_result(dev, pWextState->req_bssId,
2018 NULL, 0, NULL, 0, reason_code, GFP_KERNEL);
James Zmudafbf5ffc2013-03-25 12:45:35 -07002019 }
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302020 /*Clear the roam profile*/
2021 hdd_clearRoamProfileIe( pAdapter );
Jeff Johnsone7245742012-09-05 17:12:55 -07002022 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002023
Kumar Anand82c009f2014-05-29 00:29:42 -07002024 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07002025
c_hpothu24f40982014-04-18 18:00:36 +05302026 if (pRoamInfo)
2027 {
2028 WLANTL_AssocFailed(pRoamInfo->staId);
2029 }
Mihir Sheteb7337272014-04-11 15:53:08 +05302030
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302031 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002032 netif_tx_disable(dev);
2033 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002034
Jeff Johnson295189b2012-06-20 16:38:30 -07002035 }
2036
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302037 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302038 {
2039 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
2040 if (pHostapdAdapter != NULL)
2041 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302042 /* Restart SAP if its operating channel is different
2043 * from AP channel.
2044 */
2045 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
2046 (int)pRoamInfo->pBssDesc->channelId)
2047 {
2048 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
2049 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
2050 (int)pRoamInfo->pBssDesc->channelId);
Deepthi Gowric9c777d2014-12-10 16:17:11 +05302051 hdd_hostapd_stop(pHostapdAdapter->dev);
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302052 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302053 }
2054 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 return eHAL_STATUS_SUCCESS;
2056}
2057
2058/**============================================================================
2059 *
Jeff Johnson81c17882013-05-03 09:53:35 -07002060 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07002061 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07002062
Jeff Johnson295189b2012-06-20 16:38:30 -07002063 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07002064static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
2065 tCsrRoamInfo *pRoamInfo,
2066 tANI_U32 roamId,
2067 eRoamCmdStatus roamStatus,
2068 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07002069{
Katya Nigam47528772015-02-11 12:24:49 +05302070 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2071 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2072 struct cfg80211_bss *bss;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302073 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Katya Nigam47528772015-02-11 12:24:49 +05302074
Jeff Johnson81c17882013-05-03 09:53:35 -07002075 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
2076 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
2077
Jeff Johnson295189b2012-06-20 16:38:30 -07002078 switch( roamResult )
2079 {
2080 // both IBSS Started and IBSS Join should come in here.
2081 case eCSR_ROAM_RESULT_IBSS_STARTED:
2082 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002083 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07002084 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002085 if (NULL == pRoamInfo)
2086 {
2087 VOS_ASSERT(0);
2088 return;
2089 }
2090
2091 /* When IBSS Started comes from CSR, we need to move
2092 * connection state to IBSS Disconnected (meaning no peers
2093 * are in the IBSS).
2094 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05302095 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2096 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
2097 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07002098 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2099 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302100 /*notify wmm */
2101 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002102 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002103
Jeff Johnson81c17882013-05-03 09:53:35 -07002104 if (pRoamInfo->pBssDesc)
2105 {
Anand N Sunkadfec40682015-07-29 09:51:17 +05302106#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2107 struct ieee80211_channel *chan;
2108 int chan_no;
2109 unsigned int freq;
2110#endif
Katya Nigam47528772015-02-11 12:24:49 +05302111 hdd_ibss_RegisterSTA (pAdapter, pRoamInfo,
2112 IBSS_BROADCAST_STAID,
2113 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson81c17882013-05-03 09:53:35 -07002114
2115 /* we created the IBSS, notify supplicant */
2116 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
2117 MAC_ADDRESS_STR,
2118 __func__, pAdapter->dev->name,
2119 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2120
2121 /* we must first give cfg80211 the BSS information */
2122 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2123 if (NULL == bss)
2124 {
2125 hddLog(VOS_TRACE_LEVEL_ERROR,
2126 "%s: %s: unable to create IBSS entry",
2127 __func__, pAdapter->dev->name);
2128 return;
2129 }
Abhishek Singh7cd040e2016-01-07 10:51:04 +05302130#ifdef WLAN_FEATURE_RMC
2131 netif_carrier_on(pAdapter->dev);
2132 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
2133 netif_tx_start_all_queues(pAdapter->dev);
2134#endif
Anand N Sunkadfec40682015-07-29 09:51:17 +05302135#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2136 chan_no = pRoamInfo->pBssDesc->channelId;
Jeff Johnson81c17882013-05-03 09:53:35 -07002137
Anand N Sunkadfec40682015-07-29 09:51:17 +05302138 if (chan_no <= 14)
2139 freq = ieee80211_channel_to_frequency(chan_no,
2140 IEEE80211_BAND_2GHZ);
2141 else
2142 freq = ieee80211_channel_to_frequency(chan_no,
2143 IEEE80211_BAND_5GHZ);
2144
2145 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
2146
2147 if (chan)
2148 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
2149 chan, GFP_KERNEL);
2150 else
2151 hddLog(LOGE, FL("%s: chanId: %d, can't find channel"),
2152 pAdapter->dev->name,
2153 (int)pRoamInfo->pBssDesc->channelId);
2154#else
Jeff Johnson81c17882013-05-03 09:53:35 -07002155 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302156#endif
Yue Maf49ba872013-08-19 12:04:25 -07002157 cfg80211_put_bss(
2158#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2159 pHddCtx->wiphy,
2160#endif
2161 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07002162 }
Katya Nigam47528772015-02-11 12:24:49 +05302163 else
2164 {
2165 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2166 "%s: NULL Bss Desc",__func__);
2167 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05302168
2169 /* Set Broadcast key again in case IBSS_COALESCED as DEL BSS,
2170 * in IBSS_COALESCED will remove the BC key.
2171 */
2172 if ((eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) &&
2173 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY
2174 == pHddStaCtx->ibss_enc_key.encType
2175 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY
2176 == pHddStaCtx->ibss_enc_key.encType
2177 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2178 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType ))
2179 {
2180 u8 grpmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2181 VOS_STATUS vosStatus;
2182
2183 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2184
2185 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2186 grpmacaddr, WNI_CFG_BSSID_LEN);
2187 hddLog(VOS_TRACE_LEVEL_INFO,
2188 FL(" SET GTK in case of COALESCED"));
2189 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2190 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2191 if ( VOS_STATUS_SUCCESS != vosStatus )
2192 {
2193 hddLog(VOS_TRACE_LEVEL_ERROR,
2194 FL("sme_RoamSetKey failed, returned %d"),vosStatus);
2195 }
2196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 break;
2198 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002199
Jeff Johnson295189b2012-06-20 16:38:30 -07002200 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
2201 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002202 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
2203 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07002204 break;
2205 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002206
Jeff Johnson295189b2012-06-20 16:38:30 -07002207 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07002208 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
2209 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002211 }
2212
Jeff Johnson81c17882013-05-03 09:53:35 -07002213 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002214}
2215
2216/**============================================================================
2217 *
2218 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
2219 This information is passed to iwconfig later. The peer that joined
2220 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002221 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002222 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002223
Jeff Johnson295189b2012-06-20 16:38:30 -07002224 ===========================================================================*/
Nirav Shah7e3c8132015-06-22 23:51:42 +05302225static int roamSaveIbssStation(hdd_adapter_t *pAdapter, v_U8_t staId, v_MACADDR_t *peerMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07002226{
2227 int fSuccess = FALSE;
2228 int idx = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302229 VOS_STATUS status;
2230 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002231
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2233 {
2234 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
2235 {
2236 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002237
Jeff Johnson295189b2012-06-20 16:38:30 -07002238 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002239
Jeff Johnson295189b2012-06-20 16:38:30 -07002240 fSuccess = TRUE;
2241 break;
2242 }
2243 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002244
Nirav Shah7e3c8132015-06-22 23:51:42 +05302245 status = hdd_sta_id_hash_add_entry(pAdapter, staId, peerMacAddress);
2246 if (status != VOS_STATUS_SUCCESS) {
2247 hddLog(VOS_TRACE_LEVEL_ERROR,
2248 FL("Not able to add staid hash %d"), staId);
2249 return FALSE;
2250 }
2251
2252 hddLog(VOS_TRACE_LEVEL_INFO,
2253 FL("New station added sta_id %d mac:"
2254 MAC_ADDRESS_STR), staId,
2255 MAC_ADDR_ARRAY(peerMacAddress->bytes));
2256
Shailender Karmuchia734f332013-04-19 14:02:48 -07002257 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07002258}
2259/**============================================================================
2260 *
2261 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002262 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002263 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002264
Jeff Johnson295189b2012-06-20 16:38:30 -07002265 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07002266static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07002267{
2268 int fSuccess = FALSE;
2269 int idx = 0;
2270 v_U8_t valid_idx = 0;
2271 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07002272 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002273 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Nirav Shah7e3c8132015-06-22 23:51:42 +05302274 VOS_STATUS status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002275
Jeff Johnson295189b2012-06-20 16:38:30 -07002276 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2277 {
2278 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
2279 {
2280 pHddStaCtx->conn_info.staId[ idx ] = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302281 status = hdd_sta_id_hash_remove_entry(pAdapter,
2282 staId, &pHddStaCtx->conn_info.peerMacAddress[idx]);
2283 if (status != VOS_STATUS_SUCCESS) {
2284 hddLog(VOS_TRACE_LEVEL_ERROR,
2285 FL("Not able to remove staid hash %d"), staId );
2286 fSuccess = FALSE;
2287 } else {
2288 hddLog(VOS_TRACE_LEVEL_INFO,
2289 FL("station removed sta_id %d mac:"
2290 MAC_ADDRESS_STR), staId,
2291 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[idx].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07002292
Nirav Shah7e3c8132015-06-22 23:51:42 +05302293 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002294
Nirav Shah7e3c8132015-06-22 23:51:42 +05302295 fSuccess = TRUE;
2296 // Note the deleted Index, if its 0 we need special handling
2297 del_idx = idx;
2298 empty_slots++;
2299 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 }
2301 else
2302 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002303 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002304 {
2305 valid_idx = idx;
2306 }
Ravi Joshi8a934352013-09-25 16:46:58 -07002307 else
2308 {
2309 // Found an empty slot
2310 empty_slots++;
2311 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 }
2313 }
2314
Ravi Joshi8a934352013-09-25 16:46:58 -07002315 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
2316 {
2317 // Last peer departed, set the IBSS state appropriately
2318 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002319 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07002320 "Last IBSS Peer Departed!!!" );
2321 }
2322
Jeff Johnson295189b2012-06-20 16:38:30 -07002323 // Find next active staId, to have a valid sta trigger for TL.
2324 if (fSuccess == TRUE)
2325 {
2326 if (del_idx == 0)
2327 {
2328 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
2329 {
2330 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
2331 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
2332 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
2333
2334 pHddStaCtx->conn_info.staId[valid_idx] = 0;
2335 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
2336 }
2337 }
2338 }
2339 return( fSuccess );
2340}
2341
2342/**============================================================================
2343 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002344 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07002345 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002346
Jeff Johnson295189b2012-06-20 16:38:30 -07002347 ===========================================================================*/
2348static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
2349{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002350 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05302351 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2352 "%s: IBSS Connect Indication from SME!!! "
2353 "Set HDD connState to eConnectionState_IbssConnected",
2354 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
2356 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
2357
2358 // Save the connection info from CSR...
2359 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
2360
2361 // Send the bssid address to the wext.
2362 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002363 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002364 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2365 if (NULL == bss)
2366 {
2367 hddLog(VOS_TRACE_LEVEL_ERROR,
2368 "%s: %s: unable to create IBSS entry",
2369 __func__, pAdapter->dev->name);
2370 return eHAL_STATUS_FAILURE;
2371 }
Yue Maf49ba872013-08-19 12:04:25 -07002372 cfg80211_put_bss(
2373#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2374 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
2375#endif
2376 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07002377
2378 return( eHAL_STATUS_SUCCESS );
2379}
2380/**============================================================================
2381 *
Mukul Sharmad2589a52014-04-23 21:06:25 +05302382 @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
2383 suspend related data which was cleared during roaming in FWR.
2384
2385 ===========================================================================*/
2386static void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
2387{
2388 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
2389 hdd_adapter_t *pAdapter;
2390 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
2391 ENTER();
2392
2393 spin_lock(&pHddCtx->filter_lock);
2394 if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
2395 {
2396 pHddCtx->sus_res_mcastbcast_filter =
2397 pHddCtx->configuredMcastBcastFilter;
2398 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
2399 hddLog(VOS_TRACE_LEVEL_INFO, FL("offload: callback to associated"));
2400 hddLog(VOS_TRACE_LEVEL_INFO,
2401 FL("saving configuredMcastBcastFilter = %d"),
2402 pHddCtx->configuredMcastBcastFilter);
2403 hddLog(VOS_TRACE_LEVEL_INFO,
2404 FL("offload: calling hdd_conf_mcastbcast_filter"));
2405 }
2406 spin_unlock(&pHddCtx->filter_lock);
2407
2408 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
2409 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
2410 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
2411
2412 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
2413 //No need to configure GTK Offload from here because it might possible
2414 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
2415 //be handled as part of cfg80211_set_rekey_data processing.
2416 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
2417 {
2418 pAdapter = pAdapterNode->pAdapter;
2419 if( pAdapter &&
2420 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
2421 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
2422 {
2423 if (pHddCtx->cfg_ini->fhostArpOffload)
2424 {
2425 //Configure ARPOFFLOAD
2426 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
2427 if (!VOS_IS_STATUS_SUCCESS(vstatus))
2428 {
2429 hddLog(VOS_TRACE_LEVEL_ERROR,
2430 FL("Failed to disable ARPOffload Feature %d"), vstatus);
2431 }
2432 }
2433#ifdef WLAN_NS_OFFLOAD
2434 //Configure NSOFFLOAD
2435 if (pHddCtx->cfg_ini->fhostNSOffload)
2436 {
2437 hdd_conf_ns_offload(pAdapter, TRUE);
2438 }
2439#endif
Mukul Sharma25e70c32014-05-22 12:50:24 +05302440#ifdef WLAN_FEATURE_PACKET_FILTERING
2441 /* During suspend, configure MC Addr list filter to the firmware
2442 * function takes care of checking necessary conditions before
2443 * configuring.
2444 */
2445 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
2446#endif
Mukul Sharmad2589a52014-04-23 21:06:25 +05302447 }
2448 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2449 pAdapterNode = pNext;
2450 }
2451 EXIT();
2452}
2453
2454/**============================================================================
2455 *
Jeff Johnson295189b2012-06-20 16:38:30 -07002456 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002457
Jeff Johnson295189b2012-06-20 16:38:30 -07002458 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002459static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2460 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 eCsrRoamResult roamResult )
2462{
2463 eCsrEncryptionType connectedCipherAlgo;
2464 v_BOOL_t fConnected = FALSE;
2465 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2466 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Bhargav Shaha805ef22015-07-29 17:31:38 +05302467 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002468 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302469 WLANTL_STAStateType prevTLState = WLANTL_STA_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07002471
2472 if (NULL == pRoamInfo)
2473 {
2474 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
2475 return eHAL_STATUS_FAILURE;
2476 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002478 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07002479 // not require upper layer authentication) we can put TL directly into 'authenticated'
2480 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002481 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2482 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
2483 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002484
Jeff Johnson295189b2012-06-20 16:38:30 -07002485 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2486 if( fConnected )
2487 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002488 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
2489 {
2490 v_U8_t staId;
2491
2492 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2493
2494 if ( 0 == memcmp( pRoamInfo->peerMac,
2495 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
2496 {
2497 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2498 IBSS_BROADCAST_STAID);
Abhishek Singhb25e8442015-06-23 14:28:05 +05302499 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2500 "WLAN TL STA GTK Installed for STAID=%d", IBSS_BROADCAST_STAID);
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002501 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2502 }
2503 else
2504 {
2505 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
2506 (v_MACADDR_t*)pRoamInfo->peerMac,
2507 &staId);
2508 if ( VOS_STATUS_SUCCESS == vosStatus )
2509 {
2510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2511 "WLAN TL STA Ptk Installed for STAID=%d", staId);
2512 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2513 staId);
2514 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2515 }
2516 }
2517 }
2518 else
2519 {
Bhargav Shaha805ef22015-07-29 17:31:38 +05302520 WLANTL_GetSTAState(pHddCtx->pvosContext,
2521 pHddStaCtx->conn_info.staId[0],
2522 &prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302523 // TODO: Considering getting a state machine in HDD later.
2524 // This routine is invoked twice. 1)set PTK 2)set GTK.
2525 // The folloing if statement will be TRUE when setting GTK.
2526 // At this time we don't handle the state in detail.
2527 // Related CR: 174048 - TL not in authenticated state
2528 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
2529 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
2530 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302531
2532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
2533 "for StaId=%d. Changing TL state to AUTHENTICATED from"
2534 " state:%d", pHddStaCtx->conn_info.staId[0], prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302535
2536 // Connections that do not need Upper layer authentication,
2537 // transition TL to 'Authenticated' state after the keys are set.
2538 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2539 pHddStaCtx->conn_info.staId[ 0 ],
2540 WLANTL_STA_AUTHENTICATED );
2541
2542 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302543
2544 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2545 hdd_postTLPacketPendingInd(pAdapter,
2546 pHddStaCtx->conn_info.staId[0]);
Mukul Sharmad2589a52014-04-23 21:06:25 +05302547 //Need to call offload because when roaming happen at that time fwr
2548 //clean offload info as part of the DelBss
2549 // No need to configure offload if host was not suspended
2550 spin_lock(&pHddCtx->filter_lock);
2551 if(pHddCtx->hdd_wlan_suspended)
2552 {
2553 spin_unlock(&pHddCtx->filter_lock);
2554 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
2555 }
2556 else
2557 {
2558 spin_unlock(&pHddCtx->filter_lock);
2559 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302560 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2561 {
2562 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
2563 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302564 }
2565 else
2566 {
2567 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2568 pHddStaCtx->conn_info.staId[ 0 ]);
Bhargav Shaha805ef22015-07-29 17:31:38 +05302569
2570 /* In case of OSEN move TL to 'Authenticated' after PTK is set */
2571 if (pWextState->roamProfile.bOSENAssociation == VOS_TRUE)
2572 {
2573 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "PTK set"
2574 " for StaId=%d. Due to OSEN, Changing TL state to"
2575 "AUTHENTICATED from state:%d",
2576 pHddStaCtx->conn_info.staId[0], prevTLState);
2577
2578 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2579 pHddStaCtx->conn_info.staId[ 0 ],
2580 WLANTL_STA_AUTHENTICATED );
2581
2582 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
2583
2584 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2585 hdd_postTLPacketPendingInd(pAdapter,
2586 pHddStaCtx->conn_info.staId[0]);
2587 }
2588
2589
2590
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302591 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2592 {
2593 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
2594 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302595 }
2596
2597 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002598 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002599 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302600 else
2601 {
2602 // possible disassoc after issuing set key and waiting set key complete
2603 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2604 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002605
Jeff Johnson295189b2012-06-20 16:38:30 -07002606 EXIT();
2607 return( eHAL_STATUS_SUCCESS );
2608}
2609/**============================================================================
2610 *
2611 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2612 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002613static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002615{
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2617
2618 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2619 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2620 {
2621 struct iw_michaelmicfailure msg;
2622 union iwreq_data wreq;
2623 memset(&msg, '\0', sizeof(msg));
2624 msg.src_addr.sa_family = ARPHRD_ETHER;
2625 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002626 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2627 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002628
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2630 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002631 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 msg.flags = IW_MICFAILURE_PAIRWISE;
2633 memset(&wreq, 0, sizeof(wreq));
2634 wreq.data.length = sizeof(msg);
2635 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002636 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002637 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002638 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2639 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2640 NL80211_KEYTYPE_GROUP :
2641 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002642 pRoamInfo->u.pMICFailureInfo->keyId,
2643 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002644 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002645
Jeff Johnson295189b2012-06-20 16:38:30 -07002646 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002647
Jeff Johnson295189b2012-06-20 16:38:30 -07002648 return( eHAL_STATUS_SUCCESS );
2649}
2650
2651/**============================================================================
2652 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002653 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002654 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002655
Jeff Johnson295189b2012-06-20 16:38:30 -07002656 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002657static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2658 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 eCsrRoamResult roamResult )
2660{
2661 VOS_STATUS vosStatus;
2662
2663 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2664 switch( roamResult )
2665 {
2666 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2667 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002668 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002669 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002670
Deepthi Gowri1d3aa3c2015-12-28 15:43:17 +05302671 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2672 "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 -07002673 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2674 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002675 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002676
Jeff Johnson295189b2012-06-20 16:38:30 -07002677 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2678
Shailender Karmuchia734f332013-04-19 14:02:48 -07002679 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2680 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2681 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2682
2683 // Register the Station with TL for the new peer.
Katya Nigam47528772015-02-11 12:24:49 +05302684 vosStatus = hdd_ibss_RegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002685 pRoamInfo,
2686 pRoamInfo->staId,
2687 (v_MACADDR_t *)pRoamInfo->peerMac,
2688 pRoamInfo->pBssDesc );
2689 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2690 {
2691 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002692 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002693 vosStatus, vosStatus );
2694 }
Abhishek Singh4b025022016-02-09 11:53:58 +05302695 if (!roamSaveIbssStation(pAdapter,
2696 pRoamInfo->staId,
2697 (v_MACADDR_t *)pRoamInfo->peerMac))
2698 {
2699 hddLog(LOGW, FL("Not Able to add sta in sta hash"));
2700 break;
2701 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002702 pHddStaCtx->ibss_sta_generation++;
2703 memset(&staInfo, 0, sizeof(staInfo));
2704 staInfo.filled = 0;
2705 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2706
2707 cfg80211_new_sta(pAdapter->dev,
2708 (const u8 *)pRoamInfo->peerMac,
2709 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002710
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002711 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2712 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2713 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2714 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2715 {
2716 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302717
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002718 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2719 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2720
2721 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002722 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002723 pHddStaCtx->ibss_enc_key.encType);
2724
2725 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2726 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2727
2728 if ( VOS_STATUS_SUCCESS != vosStatus )
2729 {
2730 hddLog(VOS_TRACE_LEVEL_ERROR,
2731 "%s: sme_RoamSetKey failed, returned %d",
2732 __func__, vosStatus);
2733 return VOS_STATUS_E_FAILURE;
2734 }
2735 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 netif_carrier_on(pAdapter->dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302737 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002738 netif_tx_start_all_queues(pAdapter->dev);
2739 break;
2740 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002741
Jeff Johnson295189b2012-06-20 16:38:30 -07002742 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2743 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002744
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002746
Jeff Johnson295189b2012-06-20 16:38:30 -07002747 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002748 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002749 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2750 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002751 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002752
Ravi Joshicc57ed42013-10-12 16:31:25 -07002753 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 {
2755 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2756 "IBSS peer departed by cannot find peer in our registration table with TL" );
2757 }
2758
Deepthi Gowri1d3aa3c2015-12-28 15:43:17 +05302759 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2760 "IBSS Peer Departed from SME with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002761 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2762 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2763 pRoamInfo->staId );
2764
Katya Nigam47528772015-02-11 12:24:49 +05302765 hdd_ibss_DeregisterSTA( pAdapter, pRoamInfo->staId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002766
2767 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002768 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002769
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002770 cfg80211_del_sta(pAdapter->dev,
2771 (const u8 *)&pRoamInfo->peerMac,
2772 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002773 break;
2774 }
2775 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2776 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002777 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2778 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002779 // Stop only when we are inactive
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302780 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 netif_tx_disable(pAdapter->dev);
2782 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05302783 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2784 "%s: Set HDD connState to eConnectionState_NotConnected",
2785 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002787
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 // Send the bssid address to the wext.
2789 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2790 // clean up data path
2791 hdd_disconnect_tx_rx(pAdapter);
2792 break;
2793 }
2794 default:
2795 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002796
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002798
Jeff Johnson295189b2012-06-20 16:38:30 -07002799 return( eHAL_STATUS_SUCCESS );
2800}
2801
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002802#ifdef FEATURE_WLAN_TDLS
2803/**============================================================================
2804 *
2805 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2806 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2807 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002808
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002809 ===========================================================================*/
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05302810VOS_STATUS hdd_roamRegisterTDLSSTA(hdd_adapter_t *pAdapter,
2811#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
2812 const tANI_U8 *peerMac,
2813#else
2814 tANI_U8 *peerMac,
2815#endif
2816 tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002817{
2818 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002819 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002820 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2821 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002822 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2823 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002824 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2825 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002826
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002827 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2828 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002829 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002830 "%s not connected. ignored", __func__);
2831 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002832 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002833
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002834 /*
2835 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2836 * be peer MAC, here we are wokrking on direct Link
2837 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002838 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002839
2840 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002841
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002842 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002843 sizeof(tSirMacAddr) );
2844
2845 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2846 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2847
2848 /* set the QoS field appropriately ..*/
2849 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2850 : (staDesc.ucQosEnabled = 0) ;
2851
2852 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002853 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002854
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002855 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002856
2857 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002858 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002859
Shailender Karmuchia734f332013-04-19 14:02:48 -07002860 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002861 * UMA is ready we inform TL to do frame translation.
2862 */
2863 staDesc.ucSwFrameTXXlation = 1;
2864 staDesc.ucSwFrameRXXlation = 1;
2865 staDesc.ucAddRmvLLC = 1;
2866
2867 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002868 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002869
2870 /* tdls Direct Link do not need bcastSig */
2871 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002872
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002873#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2874 if(staDesc.ucProtectedFrame)
2875 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2876 else
2877 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2878#endif
2879
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302880 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002881
Shailender Karmuchia734f332013-04-19 14:02:48 -07002882 /* Register the Station with TL... */
2883 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2884 hdd_rx_packet_cbk,
2885 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002886 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002887
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002888 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2889 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002890 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002891 "%s: WLANTL_RegisterSTAClient() failed to register. "
2892 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002893 return vosStatus;
2894 }
2895
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002896 if ( cfg_param->dynSplitscan &&
2897 ( VOS_TIMER_STATE_RUNNING !=
2898 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2899 {
2900 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2901 cfg_param->trafficMntrTmrForSplitScan);
2902 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002903 return( vosStatus );
2904}
2905
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05302906VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002907{
2908 VOS_STATUS vosStatus;
2909 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2910 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2911 {
2912 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2913 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002914 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002915 __func__, staId, vosStatus, vosStatus );
2916 }
2917 return( vosStatus );
2918}
2919
2920
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002921/*
2922 * HDD interface between SME and TL to ensure TDLS client registration with
2923 * TL in case of new TDLS client is added and deregistration at the time
2924 * TDLS client is deleted.
2925 */
2926
Shailender Karmuchia734f332013-04-19 14:02:48 -07002927eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2928 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002929 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002930 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002931 eCsrRoamResult roamResult)
2932{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002933 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002934 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002935 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002936
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002938 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2939 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2940 "ADD_TDLS_PEER" :
2941 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2942 "DEL_TDLS_PEER" :
2943 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2944 "DEL_TDLS_PEER_IND" :
2945 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2946 "DEL_ALL_TDLS_PEER_IND" :
2947 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2948 "UPDATE_TDLS_PEER" :
2949 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
Masti, Narayanraddi764dd912016-01-06 16:07:34 +05302950 "LINK_ESTABLISH_REQ_RSP" :
2951 roamResult == eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP ?
2952 "CHANNEL_SWITCH_REQ_RSP" : "UNKNOWN",
Arif Hussain24bafea2013-11-15 15:10:03 -08002953 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002954 switch( roamResult )
2955 {
2956 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2957 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002958 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2959 {
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +05302960 hddTdlsPeer_t *curr_peer;
2961
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002963 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05302964 wlan_hdd_tdls_check_bmps(pAdapter);
Masti, Narayanraddi255d8c52016-01-07 16:26:06 +05302965
2966 mutex_lock(&pHddCtx->tdls_lock);
2967 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
2968 pRoamInfo->peerMac, FALSE);
2969 if (NULL != curr_peer)
2970 curr_peer->link_status = eTDLS_LINK_TEARING;
2971 else
2972 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2973 "%s %d curr_peer is Null", __func__,__LINE__);
2974 mutex_unlock(&pHddCtx->tdls_lock);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002975 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002976 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002977 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002978
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002979 /* check if there is available index for this new TDLS STA */
2980 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2981 {
2982 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2983 {
2984 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2985 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2986
2987 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002988 ("TDLS: STA IDX at %d is %d "
2989 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002990 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002991 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002992
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002993 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002994 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2995 status = eHAL_STATUS_SUCCESS ;
2996 break ;
2997 }
2998 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002999 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003000 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003001 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003002 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3003 "wlan_hdd_tdls_set_sta_id() failed");
3004 return VOS_FALSE;
3005 }
3006
3007 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303008 /* store the ucast signature , if required for further reference. */
3009
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003010 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303011 /* start TDLS client registration with TL */
3012 status = hdd_roamRegisterTDLSSTA( pAdapter,
3013 pRoamInfo->peerMac,
3014 pRoamInfo->staId,
3015 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303016 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003017 }
3018 else
3019 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003020 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003021 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07003022 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003023 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003024 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003025 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003026 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003027 break ;
3028 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003029 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3030 {
3031 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3032 {
3033 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3034 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
3035 }
3036 /* store the ucast signature which will be used later when
3037 * registering to TL
3038 */
3039 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3040 complete(&pAdapter->tdls_add_station_comp);
3041 break;
3042 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303043 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3044 {
3045 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3046 {
Masti, Narayanraddie1892a52015-12-15 15:01:01 +05303047 hddTdlsPeer_t *curr_peer;
3048
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303049 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3050 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
Masti, Narayanraddie1892a52015-12-15 15:01:01 +05303051
3052 mutex_lock(&pHddCtx->tdls_lock);
3053 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3054 pRoamInfo->peerMac, FALSE);
3055 if (curr_peer)
3056 curr_peer->link_status = eTDLS_LINK_TEARING;
3057 else
3058 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3059 "%s %d curr_peer is Null",__func__,__LINE__);
3060 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303061 }
3062 complete(&pAdapter->tdls_link_establish_req_comp);
3063 break;
3064 }
Masti, Narayanraddi764dd912016-01-06 16:07:34 +05303065 case eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP:
3066 {
3067 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3069 "%s: Channel switch request failed. %d", __func__,
3070 pRoamInfo->statusCode);
3071 else
3072 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3073 "%s: Channel switch request Success", __func__);
3074 break;
3075 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003076 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003077 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003078 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003079 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003080 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003081 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3082 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003083 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003085 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
3086
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303087 mutex_lock(&pHddCtx->tdls_lock);
3088 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3089 pRoamInfo->peerMac, FALSE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303090 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003091 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303092 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3093 " Current status for peer" MAC_ADDRESS_STR "is %d",
3094 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303095 if (TDLS_IS_CONNECTED(curr_peer) ||
3096 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303097 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303098 mutex_unlock(&pHddCtx->tdls_lock);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303099 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
3100 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303101 else
3102 mutex_unlock(&pHddCtx->tdls_lock);
3103
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303104 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003105 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303106 else
3107 mutex_unlock(&pHddCtx->tdls_lock);
3108
Masti, Narayanraddi81412a72015-10-17 16:05:15 +05303109 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003110 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Masti, Narayanraddi81412a72015-10-17 16:05:15 +05303111 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003112
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003113 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3114 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
3115 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003116 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003117 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003118 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003119 break ;
3120 }
3121 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003122 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003123 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003124 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003125 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3126 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003127 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003128 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3129 "%s: Sending teardown to supplicant with reason code %u",
3130 __func__, pRoamInfo->reasonCode);
3131
3132#ifdef CONFIG_TDLS_IMPLICIT
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303133 mutex_lock(&pHddCtx->tdls_lock);
3134 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac,
3135 FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003136 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Abhishek Singhff7c2f92016-01-05 15:28:12 +05303137 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3138 curr_peer->peerMac);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303139 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003140#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003141 status = eHAL_STATUS_SUCCESS ;
3142 break ;
3143 }
3144 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3145 {
3146 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003147 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003148 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003149 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3150 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003151 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003153 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003154 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003155 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Masti, Narayanraddi81412a72015-10-17 16:05:15 +05303156
3157 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003158 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
Masti, Narayanraddi81412a72015-10-17 16:05:15 +05303159 mutex_unlock(&pHddCtx->tdls_lock);
3160
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003161 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3162 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003163
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003164 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003165 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003166 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3167 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003168
3169 status = eHAL_STATUS_SUCCESS ;
3170 }
3171 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303172 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003173 break ;
3174 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003175 default:
3176 {
3177 break ;
3178 }
3179 }
3180
3181 return status ;
3182}
3183#endif
3184
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05303185void iw_full_power_cbfn (void *pContext, eHalStatus status)
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003186{
3187 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3188 hdd_context_t *pHddCtx = NULL;
3189 int ret;
3190
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303191 ENTER();
3192
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003193 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3194 {
3195 hddLog(VOS_TRACE_LEVEL_ERROR,
3196 "%s: Bad param, pAdapter [%p]",
3197 __func__, pAdapter);
3198 return;
3199 }
3200
3201 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3202 ret = wlan_hdd_validate_context(pHddCtx);
3203 if (0 != ret)
3204 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003205 return;
3206 }
3207
3208 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3209 {
3210 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
3211 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303212
3213 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003214}
3215
Shailender Karmuchia734f332013-04-19 14:02:48 -07003216eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
3218{
3219 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
3220 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303221 hdd_wext_state_t *pWextState = NULL;
3222 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003223 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07003224 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003225
3226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003227 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003228 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003229
3230 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303231 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003232 {
3233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303234 "invalid adapter or adapter has invalid magic");
3235 return eHAL_STATUS_FAILURE;
3236 }
3237
3238 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3239 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3240
3241 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3242 {
3243 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3244 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003245 return eHAL_STATUS_FAILURE;
3246 }
3247
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05303248 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
3249 pAdapter->sessionId, roamStatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003250 switch( roamStatus )
3251 {
3252 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki41d95e22015-08-28 12:51:32 +05303253 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
3254 complete(&pAdapter->session_open_comp_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003256
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003257#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
3258 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07003260 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 * interface down */
3262 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303263 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
3264 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05303265 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003266 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3267 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
3268 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003269 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3270 }
3271 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05303272 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003273 break;
3274
3275 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003276 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07003278 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 // eCSR_ROAM_SHOULD_ROAM will be received.
3280 // Where in we will not mark the link down
3281 // Also we want to stop tx at this point when we will be
3282 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003283 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 {
3285 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303286 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003287 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303288 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3289 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3290 {
3291 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
3292 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003293 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303294 * Deregister this STA with TL, but do not flush the packets
3295 * for this STA from wmm_tx_queue. Since there is no valid STA
3296 * for these packets they will not be transmitted. Eventually
3297 * after the reassociation is successful, these packets will be
3298 * transmitted after registering STA with TL again. This ensures
3299 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003300 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303301 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
3302 pHddStaCtx->conn_info.staId[0]);
3303 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003304 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303305 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3306 FL("WLANTL_ClearSTAClient failed for staID %d."
3307 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
3308 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003309 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003310 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 }
3312 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003313 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003314 break;
3315#endif
3316
3317 case eCSR_ROAM_SHOULD_ROAM:
3318 // Dont need to do anything
3319 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003320 struct net_device *dev = pAdapter->dev;
3321 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3322 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303323 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003325#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003326 if (pHddStaCtx->ft_carrier_on == FALSE)
3327 {
3328#endif
3329 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003330#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003331 }
3332#endif
3333
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003334#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 //We should clear all sta register with TL, for now, only one.
3336 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
3337 if ( !VOS_IS_STATUS_SUCCESS(status ) )
3338 {
3339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3340 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
3341 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003342 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003343 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003344#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 }
3346 break;
3347 case eCSR_ROAM_LOSTLINK:
3348 case eCSR_ROAM_DISASSOCIATED:
3349 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003350 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3351 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05303352 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003353 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3354 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07003355 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3356 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303357 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07003358 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08003359
3360 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
3361 pHddCtx->configuredMcastBcastFilter =
3362 pHddCtx->sus_res_mcastbcast_filter;
3363 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
3364 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303365
Amar Singhald53568e2013-09-26 11:03:45 -07003366 hddLog(VOS_TRACE_LEVEL_INFO,
3367 "offload: disassociation happening, restoring configuredMcastBcastFilter");
3368 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
3369 pHddCtx->configuredMcastBcastFilter);
3370 hddLog(VOS_TRACE_LEVEL_INFO,
3371 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3373 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003374#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303375 /* Call to clear any MC Addr List filter applied after
3376 * successful connection.
3377 */
3378 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003379#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003380 }
3381 break;
3382 case eCSR_ROAM_IBSS_LEAVE:
3383 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3384 "****eCSR_ROAM_IBSS_LEAVE****");
3385 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3386 break;
3387 case eCSR_ROAM_ASSOCIATION_COMPLETION:
3388 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3389 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303390 // To Do - address probable memory leak with WEP encryption upon successful association
3391 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303393 //Clear saved connection information in HDD
3394 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303396 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003397
3398 break;
3399 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003400 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 pRoamInfo, roamId, roamStatus, roamResult );
3402 break;
3403 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07003404 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
3405 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 break;
3407
3408 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
3409 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003410 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003411
3412 case eCSR_ROAM_MIC_ERROR_IND:
3413 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3414 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05303415 case eCSR_ROAM_LOST_LINK_PARAMS_IND:
3416 {
3417 /*
3418 * The RSSI will be subtracted from 100 as FW is sending the RSSI by
3419 * adding the 100 value.
3420 */
3421 pAdapter->rssi_on_disconnect = pRoamInfo->u.pLostLinkParams->rssi - 100;
3422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3423 "%s : Rssi on Disconnect : %d",
3424 __func__, pAdapter->rssi_on_disconnect);
3425 break;
3426 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003427 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003428 {
3429 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
3430
3431 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003432 (TRUE == pHddCtx->hdd_wlan_suspended) &&
Padma, Santhosh Kumar1c1b9ec2016-02-17 19:58:28 +05303433 ((eCSR_ROAM_RESULT_NONE == roamResult)||
Padma, Santhosh Kumar28d54e02016-02-25 18:36:46 +05303434 (pRoamInfo && pRoamInfo->is11rAssoc)))
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003435 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003436 /* Send DTIM period to the FW; only if the wlan is already
3437 in suspend. This is the case with roaming (reassoc),
3438 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
3439 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
3440 before the ENTER_BMPS_REQ ensures Listen Interval is
3441 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003442 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003443
3444 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003445 if due to unexpected scenario, if we are in BMPS,
3446 then trigger Exit and Enter BMPS to take DTIM period
3447 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003448 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
3449 {
3450 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
3451
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003452 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3453 iw_full_power_cbfn, pAdapter,
3454 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003455 }
3456 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303457
3458 if ((pHddCtx) &&
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303459 (FULL_POWER == pmcGetPmcState(pHddCtx->hHal)) &&
3460 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
Padma, Santhosh Kumar1c1b9ec2016-02-17 19:58:28 +05303461 ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumar28d54e02016-02-25 18:36:46 +05303462 (pRoamInfo && pRoamInfo->is11rAssoc)))
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303463 {
3464 hddLog( LOG1, FL("Device in full power."
3465 "Stop and start traffic timer for roaming"));
3466 pmcStopTrafficTimer(pHddCtx->hHal);
3467 if (pmcStartTrafficTimer(pHddCtx->hHal,
3468 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
3469 {
3470 hddLog(LOGP, FL("Cannot start traffic timer"));
3471 }
3472 }
3473
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003474 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Padma, Santhosh Kumar1c1b9ec2016-02-17 19:58:28 +05303475 if ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumar28d54e02016-02-25 18:36:46 +05303476 (pRoamInfo && pRoamInfo->is11rAssoc))
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303477 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003478 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 break;
3480#ifdef WLAN_FEATURE_VOWIFI_11R
3481 case eCSR_ROAM_FT_RESPONSE:
3482 hdd_SendFTEvent(pAdapter);
3483 break;
3484#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07003485#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003486 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003487 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07003488 {
3489 /* Notify the supplicant of a new candidate */
3490 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
3491 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003492 break;
3493#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003494
Yue Maef608272013-04-08 23:09:17 -07003495#ifdef FEATURE_WLAN_LFR_METRICS
3496 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
3497 /* This event is to notify pre-auth initiation */
3498 if (VOS_STATUS_SUCCESS !=
3499 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
3500 {
3501 halStatus = eHAL_STATUS_FAILURE;
3502 }
3503 break;
3504 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
3505 /* This event will notify pre-auth completion in case of success */
3506 if (VOS_STATUS_SUCCESS !=
3507 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3508 pRoamInfo, 1))
3509 {
3510 halStatus = eHAL_STATUS_FAILURE;
3511 }
3512 break;
3513 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
3514 /* This event will notify pre-auth completion in case of failure. */
3515 if (VOS_STATUS_SUCCESS !=
3516 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3517 pRoamInfo, 0))
3518 {
3519 halStatus = eHAL_STATUS_FAILURE;
3520 }
3521 break;
3522 case eCSR_ROAM_HANDOVER_SUCCESS:
3523 /* This event is to notify handover success.
3524 It will be only invoked on success */
3525 if (VOS_STATUS_SUCCESS !=
3526 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
3527 {
3528 halStatus = eHAL_STATUS_FAILURE;
3529 }
3530 break;
3531#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 case eCSR_ROAM_REMAIN_CHAN_READY:
3533 hdd_remainChanReadyHandler( pAdapter );
3534 break;
3535 case eCSR_ROAM_SEND_ACTION_CNF:
3536 hdd_sendActionCnf( pAdapter,
3537 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
3538 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003539#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08003540 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003541 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08003542 roamId, roamStatus, roamResult );
3543 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003544 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
3545 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
3546 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003547#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003548#ifdef WLAN_FEATURE_11W
3549 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
3550 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
3551 pRoamInfo->pbFrames,
3552 pRoamInfo->frameType);
3553 break;
3554#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003555#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003556 case eCSR_ROAM_TSM_IE_IND:
3557 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
3558 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
3559 break;
3560
3561 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
3562 {
3563 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
3564 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
3565 {
3566 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
3567 }
3568 break;
3569 }
3570
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003571 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003572 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003573 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003574 break;
3575 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003576
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003577 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003578 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003579 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003580 break;
3581 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003582#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05303583 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
3584 {
3585 pAdapter->maxRateFlags = roamResult;
3586 break;
3587 }
3588 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07003589 break;
3590 }
3591 return( halStatus );
3592}
Shailender Karmuchia734f332013-04-19 14:02:48 -07003593eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003594{
3595 eCsrAuthType auth_type;
3596 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003597 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003598 {
3599 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003600 } else
3601 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003602 {
3603 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003604 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003605#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003606 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003607 {
3608 // Check for 11r FT Authentication with PSK
3609 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003610 } else
3611 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 {
3613 // Check for 11R FT Authentication with 802.1X
3614 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003615 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003616#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003617#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003618 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003619 {
3620 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
3621 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003622#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07003623#ifdef WLAN_FEATURE_11W
3624 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
3625 {
3626 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3627 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303628 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
3629 {
3630 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3631 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003632#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003633 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3635 }
3636 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003637}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003638
Shailender Karmuchia734f332013-04-19 14:02:48 -07003639eCsrAuthType
3640hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003641{
3642 eCsrAuthType auth_type;
3643 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003644 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 {
3646 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003647 } else
3648 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 {
3650 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003651 } else
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 , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003654 {
3655 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003656 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003657#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003658 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003659 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3660 }
3661 hddLog(LOG1, FL("auth_type: %d"), auth_type);
3662 return auth_type;
3663}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003664
Shailender Karmuchia734f332013-04-19 14:02:48 -07003665eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003666hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003667{
3668 eCsrEncryptionType cipher_type;
3669 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003670 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003671 {
3672 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003673 }
3674 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003675 {
3676 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003677 }
3678 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003679 {
3680 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003681 }
3682 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 {
3684 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003685 }
3686 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
3687 {
3688 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3689 }
3690 else
3691 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003692 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3693 }
3694 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3695 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003696}
Jeff Johnson295189b2012-06-20 16:38:30 -07003697/* To find if the MAC address is NULL */
3698static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3699{
3700 int i;
3701 for (i = 0; i < length; i++)
3702 {
3703 if (0x00 != (macAddr[i]))
3704 {
3705 return FALSE;
3706 }
3707 }
3708 return TRUE;
3709} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003710
Shailender Karmuchia734f332013-04-19 14:02:48 -07003711eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003712hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003713{
3714 eCsrEncryptionType cipher_type;
3715 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003716 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003717 {
3718 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003719 } else
3720 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003721 {
3722 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003723 } else
3724 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003725 {
3726 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003727 } else
3728 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003729 {
3730 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003731 } else
3732 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003733 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003734 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3735 } else
3736 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3738 }
3739 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3740 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003741}
Jeff Johnson295189b2012-06-20 16:38:30 -07003742
Shailender Karmuchia734f332013-04-19 14:02:48 -07003743static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3744 struct ether_addr *pBssid,
3745 eCsrEncryptionType *pEncryptType,
3746 eCsrEncryptionType *mcEncryptType,
3747 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003748#ifdef WLAN_FEATURE_11W
3749 u_int8_t *pMfpRequired,
3750 u_int8_t *pMfpCapable,
3751#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003752 u_int16_t gen_ie_len,
3753 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003754{
3755 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003756 eHalStatus result;
3757 tDot11fIERSN dot11RSNIE;
3758 tDot11fIEWPA dot11WPAIE;
3759 tANI_U32 i;
3760 tANI_U8 *pRsnIe;
3761 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003762 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003763 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003764
3765 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3766 flag to 0 */
3767 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3768 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3769
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003771 if ( gen_ie[0] == DOT11F_EID_RSN)
3772 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003773 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003774 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003775 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3776 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303777 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3778 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003779 return -EINVAL;
3780 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003781 // Skip past the EID byte and length byte
3782 pRsnIe = gen_ie + 2;
3783 RSNIeLen = gen_ie_len - 2;
3784 // Unpack the RSN IE
3785 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3786 pRsnIe,
3787 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003789 // Copy out the encryption and authentication types
3790 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003791 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003792 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003793 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003794 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003795 but probably I suspect we can do something different*/
3796 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003797 // Just translate the FIRST one
3798 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3799 //dot11RSNIE.pwise_cipher_suite_count
3800 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3801 //dot11RSNIE.gp_cipher_suite_count
3802 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003803#ifdef WLAN_FEATURE_11W
3804 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3805 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3806#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003807 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003808 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003809 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003810 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303812 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 break;
3814 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003815 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003816 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303817 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 break;
3819 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003820 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 // For right now, I assume setASSOCIATE() has passed in the bssid.
3822 vos_mem_copy(PMKIDCache[i].BSSID,
3823 pBssid, ETHER_ADDR_LEN);
3824 vos_mem_copy(PMKIDCache[i].PMKID,
3825 dot11RSNIE.pmkid[i],
3826 CSR_RSN_PMKID_SIZE);
3827 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003828
3829 if (updatePMKCache)
3830 {
3831 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003832 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003833 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003834 // Finally set the PMKSA ID Cache in CSR
3835 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3836 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05303837 dot11RSNIE.pmkid_count,
3838 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07003839 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003840 }
3841 else if (gen_ie[0] == DOT11F_EID_WPA)
3842 {
3843 // Validity checks
3844 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3845 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3846 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303847 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3848 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003849 return -EINVAL;
3850 }
3851 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003852 pRsnIe = gen_ie + 2 + 4;
3853 RSNIeLen = gen_ie_len - (2 + 4);
3854 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3856 pRsnIe,
3857 RSNIeLen,
3858 &dot11WPAIE);
3859 // Copy out the encryption and authentication types
3860 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003861 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003863 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 //dot11WPAIE.auth_suite_count
3865 // Just translate the FIRST one
3866 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3867 //dot11WPAIE.unicast_cipher_count
3868 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3869 //dot11WPAIE.unicast_cipher_count
3870 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3871 }
3872 else
3873 {
3874 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003875 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003876 }
3877 return 0;
3878}
3879int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3880{
3881 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3882 v_U32_t status = 0;
3883 eCsrEncryptionType RSNEncryptType;
3884 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003885#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303886 u_int8_t RSNMfpRequired = 0;
3887 u_int8_t RSNMfpCapable = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07003888#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003889 struct ether_addr bSsid; // MAC address of assoc peer
3890 // MAC address of assoc peer
3891 // But, this routine is only called when we are NOT associated.
3892 vos_mem_copy(bSsid.ether_addr_octet,
3893 pWextState->roamProfile.BSSIDs.bssid,
3894 sizeof(bSsid.ether_addr_octet));
3895 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3896 {
3897 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003898 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 else
3900 {
3901 return 0;
3902 }
3903 // The actual processing may eventually be more extensive than this.
3904 // Right now, just consume any PMKIDs that are sent in by the app.
3905 status = hdd_ProcessGENIE(pAdapter,
3906 &bSsid, // MAC address of assoc peer
3907 &RSNEncryptType,
3908 &mcRSNEncryptType,
3909 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003910#ifdef WLAN_FEATURE_11W
3911 &RSNMfpRequired,
3912 &RSNMfpCapable,
3913#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 pWextState->WPARSNIE[1]+2,
3915 pWextState->WPARSNIE);
3916 if (status == 0)
3917 {
3918 // Now copy over all the security attributes you have parsed out
3919 pWextState->roamProfile.EncryptionType.numEntries = 1;
3920 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003921
Jeff Johnson295189b2012-06-20 16:38:30 -07003922 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3923 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003924
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003925 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3926 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3927 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3928 {
3929 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3930 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3931 either AES/TKIP based on group cipher configuration
3932 mentioned in the wpa_supplicant.conf.*/
3933
3934 /*Set the unicast cipher same as multicast cipher*/
3935 pWextState->roamProfile.EncryptionType.encryptionType[0]
3936 = mcRSNEncryptType;
3937 }
3938
Chet Lanctot186b5732013-03-18 10:26:30 -07003939#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303940 hddLog( LOG1, FL("RSNMfpRequired = %d, RSNMfpCapable = %d"),
3941 RSNMfpRequired, RSNMfpCapable);
Chet Lanctot186b5732013-03-18 10:26:30 -07003942 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3943 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3944#endif
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303945 hddLog( LOG1,
3946 FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d"),
3947 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003948 }
3949 return 0;
3950}
3951int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3952{
3953 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3954 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3955 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3956 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003957
Jeff Johnson295189b2012-06-20 16:38:30 -07003958 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003959 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003960
Jeff Johnson295189b2012-06-20 16:38:30 -07003961 switch( pHddStaCtx->conn_info.authType)
3962 {
3963 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003964#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003965 case eCSR_AUTH_TYPE_CCKM_WPA:
3966 case eCSR_AUTH_TYPE_CCKM_RSN:
3967#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003968 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3969
Jeff Johnson295189b2012-06-20 16:38:30 -07003970 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003971 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003972 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003973
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003974#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003975 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3976 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3977 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003978 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003979 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3980 } else
3981 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003982 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003983 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 } else
3985#endif
3986 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3987 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003988 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3989 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3991 == IW_AUTH_KEY_MGMT_PSK) {
3992 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003993 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003994 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003995 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 }
3997 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003998#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003999 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
4000 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4001 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004002 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004003 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004004 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004005 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004006 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004007 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004008 } else
4009#endif
4010
4011#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004012 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
4013 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004015 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07004016 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004017 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004018 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4019 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004020 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 } else
4022#endif
4023
Chet Lanctot186b5732013-03-18 10:26:30 -07004024#ifdef WLAN_FEATURE_11W
4025 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
4026 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4027 } else
Abhishek Singhae408032014-09-25 17:22:04 +05304028 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
4029 pRoamProfile->AuthType.authType[0] =
4030 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4031 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07004032#endif
4033
Shailender Karmuchia734f332013-04-19 14:02:48 -07004034 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004036 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
4037 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004038 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4039 == IW_AUTH_KEY_MGMT_PSK) {
4040 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004041 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004043 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004045 break;
4046
Jeff Johnson295189b2012-06-20 16:38:30 -07004047 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004048
4049 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 break;
4051 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004052
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004053#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08004054 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004055#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004056 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
4057 break;
4058 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004059
Jeff Johnson295189b2012-06-20 16:38:30 -07004060 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004061 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004062
Jeff Johnson295189b2012-06-20 16:38:30 -07004063 EXIT();
4064 return 0;
4065}
4066
4067/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004068
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304069 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004070 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07004071 to the CSR roam profile.
4072
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 \param - dev - Pointer to the net device.
4074 - info - Pointer to the iw_request_info.
4075 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004076 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004078
Jeff Johnson295189b2012-06-20 16:38:30 -07004079 --------------------------------------------------------------------------*/
4080
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304081int __iw_set_essid(struct net_device *dev,
4082 struct iw_request_info *info,
4083 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004084{
4085 v_U32_t status = 0;
4086 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304087 hdd_adapter_t *pAdapter;
4088 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 v_U32_t roamId;
4090 tCsrRoamProfile *pRoamProfile;
4091 eMib_dot11DesiredBssType connectedBssType;
4092 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304093 tHalHandle hHal;
4094 hdd_station_ctx_t *pHddStaCtx;
4095 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004096
Jeff Johnson295189b2012-06-20 16:38:30 -07004097 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304098 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4099 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004100 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304102 "%s: Adapter is NULL",__func__);
4103 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004104 }
4105
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304106 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4107 ret = wlan_hdd_validate_context(pHddCtx);
4108 if (0 != ret)
4109 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304110 return ret;
4111 }
4112
4113 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4114 if (NULL == hHal)
4115 {
4116 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4117 "%s: Hal Context is NULL",__func__);
4118 return -EINVAL;
4119 }
4120 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4121 if (NULL == pHddStaCtx)
4122 {
4123 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4124 "%s: STA Context is NULL",__func__);
4125 return -EINVAL;
4126 }
4127 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4128 if (NULL == pWextState)
4129 {
4130 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4131 "%s: pWextState is NULL",__func__);
4132 return -EINVAL;
4133 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004134 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
4135 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
4136 return -EBUSY;
4137 }
4138 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
4139 return -EINVAL;
4140 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004141 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004142 {
4143 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
4144 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
4145 {
4146 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004147 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07004148 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4149 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
4150
4151 if(VOS_STATUS_SUCCESS == vosStatus)
4152 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
4153 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4154 }
4155 }
4156 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004157 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004158 {
4159 return -EINVAL;
4160 }
4161 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004162 /** when cfg80211 defined, wpa_supplicant wext driver uses
4163 zero-length, null-string ssid for force disconnection.
4164 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 driver MUST return success */
4166 if ( 0 == wrqu->essid.length ) {
4167 return 0;
4168 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004169
4170 status = hdd_wmm_get_uapsd_mask(pAdapter,
4171 &pWextState->roamProfile.uapsd_mask);
4172 if (VOS_STATUS_SUCCESS != status)
4173 {
4174 pWextState->roamProfile.uapsd_mask = 0;
4175 }
4176 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004177
Jeff Johnson295189b2012-06-20 16:38:30 -07004178 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004179
4180 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004181 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
4182 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
4183 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004184
Jeff Johnson295189b2012-06-20 16:38:30 -07004185 //set gen ie
4186 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
4187
4188 //set auth
4189 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
4190 }
4191#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004192 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004193 if (pAdapter->wapi_info.nWapiMode)
4194 {
4195 switch (pAdapter->wapi_info.wapiAuthMode)
4196 {
4197 case WAPI_AUTH_MODE_PSK:
4198 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004199 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004200 pRoamProfile->AuthType.numEntries = 1;
4201 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4202 break;
4203 }
4204 case WAPI_AUTH_MODE_CERT:
4205 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004206 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004207 pRoamProfile->AuthType.numEntries = 1;
4208 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4209 break;
4210 }
4211 } // End of switch
4212 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
4213 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
4214 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004215 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004216 pRoamProfile->EncryptionType.numEntries = 1;
4217 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4218 pRoamProfile->mcEncryptionType.numEntries = 1;
4219 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4220 }
4221 }
4222#endif /* FEATURE_WLAN_WAPI */
4223 /* if previous genIE is not NULL, update AssocIE */
4224 if (0 != pWextState->genIE.length)
4225 {
4226 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
4227 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
4228 pWextState->genIE.length);
4229 pWextState->assocAddIE.length = pWextState->genIE.length;
4230 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
4231 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
4232
4233 /* clear previous genIE after use it */
4234 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
4235 }
4236
4237 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
4238 pWextState->roamProfile.bWPSAssociation = FALSE;
4239
4240 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
4241 pWextState->roamProfile.nAddIEAssocLength))
4242 pWextState->roamProfile.bWPSAssociation = TRUE;
4243
4244
4245 // Disable auto BMPS entry by PMC until DHCP is done
4246 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
4247
Shailender Karmuchia734f332013-04-19 14:02:48 -07004248 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004249 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004250
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004251 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
4252 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004253 hdd_select_cbmode(pAdapter,
4254 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
4255 }
Agarwal Ashish40f9b872015-09-01 16:17:35 +05304256 /*
4257 * Change conn_state to connecting before sme_RoamConnect(),
4258 * because sme_RoamConnect() has a direct path to call
4259 * hdd_smeRoamCallback(), which will change the conn_state
4260 * If direct path, conn_state will be accordingly changed
4261 * to NotConnected or Associated by either
4262 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
4263 * in sme_RoamCallback()
4264 * if sme_RomConnect is to be queued,
4265 * Connecting state will remain until it is completed.
4266 *
4267 * If connection state is not changed,
4268 * connection state will remain in eConnectionState_NotConnected state.
4269 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
4270 * if conn state is eConnectionState_NotConnected.
4271 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
4272 * informed of connect result indication which is an issue.
4273 */
4274 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
4275 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
4276 {
4277 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4278 FL("Set HDD connState to eConnectionState_Connecting"));
4279 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
4280 eConnectionState_Connecting);
4281 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004282 status = sme_RoamConnect( hHal,pAdapter->sessionId,
4283 &(pWextState->roamProfile), &roamId);
Agarwal Ashish40f9b872015-09-01 16:17:35 +05304284
4285 if ((eHAL_STATUS_SUCCESS != status) &&
4286 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
4287 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4288 {
4289 hddLog(VOS_TRACE_LEVEL_ERROR,
4290 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
4291 pAdapter->sessionId, status);
4292 /* change back to NotAssociated */
4293 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
4294 eConnectionState_NotConnected);
4295 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004296 pRoamProfile->ChannelInfo.ChannelList = NULL;
4297 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004298
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004299 EXIT();
4300 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004301}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004302
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304303int iw_set_essid(struct net_device *dev,
4304 struct iw_request_info *info,
4305 union iwreq_data *wrqu, char *extra)
4306{
4307 int ret;
4308
4309 vos_ssr_protect(__func__);
4310 ret = __iw_set_essid(dev, info, wrqu, extra);
4311 vos_ssr_unprotect(__func__);
4312
4313 return ret;
4314}
4315
Jeff Johnson295189b2012-06-20 16:38:30 -07004316/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004317
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304318 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004319 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004320
Jeff Johnson295189b2012-06-20 16:38:30 -07004321 \param - dev - Pointer to the net device.
4322 - info - Pointer to the iw_request_info.
4323 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004324 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004325 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004326
Jeff Johnson295189b2012-06-20 16:38:30 -07004327 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304328int __iw_get_essid(struct net_device *dev,
4329 struct iw_request_info *info,
4330 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004331{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304332 hdd_adapter_t *pAdapter;
4333 hdd_context_t *pHddCtx;
4334 hdd_wext_state_t *wextBuf;
4335 hdd_station_ctx_t *pHddStaCtx;
4336 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304337
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 ENTER();
4339
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304340 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4341 if (NULL == pAdapter)
4342 {
4343 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4344 "%s: Adapter is NULL",__func__);
4345 return -EINVAL;
4346 }
4347
4348 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4349 ret = wlan_hdd_validate_context(pHddCtx);
4350 if (0 != ret)
4351 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304352 return ret;
4353 }
4354
4355 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4356 if (NULL == pHddStaCtx)
4357 {
4358 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4359 "%s: STA Context is NULL",__func__);
4360 return -EINVAL;
4361 }
4362
4363 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4364 if (NULL == wextBuf)
4365 {
4366 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4367 "%s: wextBuf is NULL",__func__);
4368 return -EINVAL;
4369 }
4370
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
4372 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
4373 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
4374 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
4375 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
4376 {
4377 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
4378 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
4379 dwrq->flags = 1;
4380 } else {
4381 memset(extra, 0, dwrq->length);
4382 dwrq->length = 0;
4383 dwrq->flags = 0;
4384 }
4385 EXIT();
4386 return 0;
4387}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304388
4389int iw_get_essid(struct net_device *dev,
4390 struct iw_request_info *info,
4391 struct iw_point *dwrq, char *extra)
4392{
4393 int ret;
4394
4395 vos_ssr_protect(__func__);
4396 ret = __iw_get_essid(dev, info, dwrq, extra);
4397 vos_ssr_unprotect(__func__);
4398
4399 return ret;
4400}
Jeff Johnson295189b2012-06-20 16:38:30 -07004401/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004402
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304403 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004404 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004405
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 \param - dev - Pointer to the net device.
4407 - info - Pointer to the iw_request_info.
4408 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004409 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004410 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004411
Jeff Johnson295189b2012-06-20 16:38:30 -07004412 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304413int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
4414 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004415{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304416 hdd_adapter_t *pAdapter;
4417 hdd_context_t *pHddCtx;
4418 hdd_wext_state_t *pWextState;
4419 hdd_station_ctx_t *pHddStaCtx;
4420 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004421 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304423 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004424
Jeff Johnson295189b2012-06-20 16:38:30 -07004425 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004426
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304427 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4428 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004429 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304430 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4431 "%s: Adapter is NULL",__func__);
4432 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004433 }
4434
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304435 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4436 ret = wlan_hdd_validate_context(pHddCtx);
4437 if (0 != ret)
4438 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304439 return ret;
4440 }
4441
4442 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4443 if (NULL == pHddStaCtx)
4444 {
4445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4446 "%s: STA Context is NULL",__func__);
4447 return -EINVAL;
4448 }
4449
4450 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4451 if (NULL == pWextState)
4452 {
4453 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4454 "%s: pWextState is NULL",__func__);
4455 return -EINVAL;
4456 }
4457
4458 pRoamProfile = &pWextState->roamProfile;
4459
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 switch(wrqu->param.flags & IW_AUTH_INDEX)
4461 {
4462 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004463
Jeff Johnson295189b2012-06-20 16:38:30 -07004464 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004465
Jeff Johnson295189b2012-06-20 16:38:30 -07004466 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004467
Jeff Johnson295189b2012-06-20 16:38:30 -07004468 case IW_AUTH_CIPHER_PAIRWISE:
4469 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004470 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004471 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004472 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004473 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4474 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004475 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
4477 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004478 }
4479
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004481
4482 if( (IW_AUTH_KEY_MGMT_802_1X
4483 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004484 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
4485 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004486 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07004487 else
4488 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004489 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4490 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004491 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004492
4493 if( ( IW_AUTH_KEY_MGMT_802_1X
4494 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004495 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4496 /*Dynamic WEP key*/
4497 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4498 else
4499 /*Static WEP key*/
4500 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004501
Jeff Johnson295189b2012-06-20 16:38:30 -07004502 }
4503 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004504
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004506 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004507 return -EINVAL;
4508 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004509
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 pRoamProfile->EncryptionType.numEntries = 1;
4511 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004512 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 break;
4514 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004515 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004516 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
4517 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4518 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004519
Jeff Johnson295189b2012-06-20 16:38:30 -07004520 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4521 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
4522 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004523
4524 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004525 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
4526 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004527
Jeff Johnson295189b2012-06-20 16:38:30 -07004528 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004529
4530 if( ( IW_AUTH_KEY_MGMT_802_1X
4531 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
4532 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4533
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004535
4536 else
4537 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004539
4540 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
4541 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004542 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004543 if( ( IW_AUTH_KEY_MGMT_802_1X
4544 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07004545 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4546 {
4547 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4548 }
4549 else
4550 {
4551 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4552 }
4553 }
4554 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004555
Jeff Johnson295189b2012-06-20 16:38:30 -07004556 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004557 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 return -EINVAL;
4559 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004560
Jeff Johnson295189b2012-06-20 16:38:30 -07004561 pRoamProfile->mcEncryptionType.numEntries = 1;
4562 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
4563 }
4564 break;
4565
4566 case IW_AUTH_80211_AUTH_ALG:
4567 {
4568 /*Save the auth algo here and set auth type to SME Roam profile
4569 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004570 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07004571 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004572
Jeff Johnson295189b2012-06-20 16:38:30 -07004573 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
4574 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
4575
4576 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
4577 /*Not supported*/
4578 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4579 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
4580 }
4581 break;
4582
4583 case IW_AUTH_KEY_MGMT:
4584 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004585#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004586#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
4587 /*Check for CCKM AKM type */
4588 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004589 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
4590 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004591 /* Set the CCKM bit in authKeyMgmt */
4592 /* Right now, this breaks all ref to authKeyMgmt because our
4593 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07004594 */
4595 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
4596 /*Set the key management to 802.1X*/
4597 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004598 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004599 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4600 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
4601 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
4602 /*Save the key management*/
4603 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
4604 //pWextState->authKeyMgmt = wrqu->param.value;
4605 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4606 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4607 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
4608 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
4609 /*Save the key management anyway*/
4610 pWextState->authKeyMgmt = wrqu->param.value;
4611 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
4612 /*Save the key management*/
4613 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
4614 //pWextState->authKeyMgmt = wrqu->param.value;
4615 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4616 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4617 }
4618#else
4619 /*Save the key management*/
4620 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004621#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 }
4623 break;
4624
4625 case IW_AUTH_TKIP_COUNTERMEASURES:
4626 {
4627 if(wrqu->param.value) {
4628 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4629 "Counter Measure started %d", wrqu->param.value);
4630 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
4631 }
4632 else {
4633 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4634 "Counter Measure stopped=%d", wrqu->param.value);
4635 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
4636 }
4637 }
4638 break;
4639 case IW_AUTH_DROP_UNENCRYPTED:
4640 case IW_AUTH_WPA_ENABLED:
4641 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
4642 case IW_AUTH_ROAMING_CONTROL:
4643 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004644
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004646
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004647 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004648 wrqu->param.flags & IW_AUTH_INDEX);
4649 break;
4650 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004651
Jeff Johnson295189b2012-06-20 16:38:30 -07004652 EXIT();
4653 return 0;
4654}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304655
4656int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
4657 union iwreq_data *wrqu, char *extra)
4658{
4659 int ret;
4660
4661 vos_ssr_protect(__func__);
4662 ret = __iw_set_auth(dev, info, wrqu, extra);
4663 vos_ssr_unprotect(__func__);
4664
4665 return ret;
4666}
4667
Jeff Johnson295189b2012-06-20 16:38:30 -07004668/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004669
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304670 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004672
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 \param - dev - Pointer to the net device.
4674 - info - Pointer to the iw_request_info.
4675 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004676 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004677 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004678
Jeff Johnson295189b2012-06-20 16:38:30 -07004679 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304680int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4681 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004682{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304683 hdd_adapter_t* pAdapter;
4684 hdd_wext_state_t *pWextState;
4685 tCsrRoamProfile *pRoamProfile;
4686 hdd_context_t *pHddCtx;
4687 int ret = 0;
4688
Jeff Johnson295189b2012-06-20 16:38:30 -07004689 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004690
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304691 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4692 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004693 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304694 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4695 "%s: Adapter is NULL",__func__);
4696 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004697 }
4698
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304699 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4700 ret = wlan_hdd_validate_context(pHddCtx);
4701 if (0 != ret)
4702 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304703 return ret;
4704 }
4705
4706 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4707 if (NULL == pWextState)
4708 {
4709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4710 "%s: pWextState is NULL",__func__);
4711 return -EINVAL;
4712 }
4713 pRoamProfile = &pWextState->roamProfile;
4714
Jeff Johnson295189b2012-06-20 16:38:30 -07004715 switch(pRoamProfile->negotiatedAuthType)
4716 {
4717 case eCSR_AUTH_TYPE_WPA_NONE:
4718 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4719 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
4720 break;
4721 case eCSR_AUTH_TYPE_WPA:
4722 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4723 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
4724 break;
4725#ifdef WLAN_FEATURE_VOWIFI_11R
4726 case eCSR_AUTH_TYPE_FT_RSN:
4727#endif
4728 case eCSR_AUTH_TYPE_RSN:
4729 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4730 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
4731 break;
4732 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4733 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4734 break;
4735 case eCSR_AUTH_TYPE_SHARED_KEY:
4736 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
4737 break;
4738 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004739 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004740 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4741 break;
4742 case eCSR_AUTH_TYPE_AUTOSWITCH:
4743 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4744 break;
4745 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304746 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004747 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4748 return -EIO;
4749#ifdef WLAN_FEATURE_VOWIFI_11R
4750 case eCSR_AUTH_TYPE_FT_RSN_PSK:
4751#endif
4752 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07004753#ifdef WLAN_FEATURE_11W
4754 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05304755 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07004756#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05304757 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004758 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4759 return -EIO;
4760 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304761 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004762 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4763 return -EIO;
4764 }
4765 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
4766 {
4767 switch(pRoamProfile->negotiatedUCEncryptionType)
4768 {
4769 case eCSR_ENCRYPT_TYPE_NONE:
4770 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4771 break;
4772 case eCSR_ENCRYPT_TYPE_WEP40:
4773 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4774 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4775 break;
4776 case eCSR_ENCRYPT_TYPE_TKIP:
4777 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4778 break;
4779 case eCSR_ENCRYPT_TYPE_WEP104:
4780 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4781 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4782 break;
4783 case eCSR_ENCRYPT_TYPE_AES:
4784 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4785 break;
4786 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304787 hddLog(LOG1, "%s called with unknown auth type %d ",
4788 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004789 return -EIO;
4790 }
4791 }
4792
Shailender Karmuchia734f332013-04-19 14:02:48 -07004793 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07004794 {
4795 switch(pRoamProfile->negotiatedMCEncryptionType)
4796 {
4797 case eCSR_ENCRYPT_TYPE_NONE:
4798 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4799 break;
4800 case eCSR_ENCRYPT_TYPE_WEP40:
4801 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4802 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4803 break;
4804 case eCSR_ENCRYPT_TYPE_TKIP:
4805 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4806 break;
4807 case eCSR_ENCRYPT_TYPE_WEP104:
4808 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4809 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4810 break;
4811 case eCSR_ENCRYPT_TYPE_AES:
4812 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4813 break;
4814 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304815 hddLog(LOG1, "%s called with unknown auth type %d ",
4816 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004817 return -EIO;
4818 }
4819 }
4820
4821 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004822 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004823 EXIT();
4824 return 0;
4825}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304826
4827int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4828 union iwreq_data *wrqu,char *extra)
4829{
4830 int ret;
4831
4832 vos_ssr_protect(__func__);
4833 ret = __iw_get_auth(dev, info, wrqu, extra);
4834 vos_ssr_unprotect(__func__);
4835
4836 return ret;
4837}
4838
Jeff Johnson295189b2012-06-20 16:38:30 -07004839/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004840
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304841 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07004842 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07004843 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004844
Jeff Johnson295189b2012-06-20 16:38:30 -07004845 \param - dev - Pointer to the net device.
4846 - info - Pointer to the iw_request_info.
4847 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004848 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004850
Jeff Johnson295189b2012-06-20 16:38:30 -07004851 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304852int __iw_set_ap_address(struct net_device *dev,
4853 struct iw_request_info *info,
4854 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004855{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304856 hdd_station_ctx_t *pHddStaCtx;
4857 hdd_adapter_t *pAdapter;
4858 hdd_context_t *pHddCtx;
4859 v_U8_t *pMacAddress = NULL;
4860 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304861
Jeff Johnson295189b2012-06-20 16:38:30 -07004862 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304863
4864 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4865 if (NULL == pAdapter)
4866 {
4867 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4868 "%s: Adapter is NULL", __func__);
4869 return -EINVAL;
4870 }
4871 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4872 ret = wlan_hdd_validate_context(pHddCtx);
4873 if (0 != ret)
4874 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304875 return ret;
4876 }
4877 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4878 if (NULL == pHddStaCtx)
4879 {
4880 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4881 "%s: pHddStaCtx is NULL", __func__);
4882 return -EINVAL;
4883 }
4884
Jeff Johnson295189b2012-06-20 16:38:30 -07004885 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08004886 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
4887 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07004888 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07004889
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304890 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004891 return 0;
4892}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304893
4894int iw_set_ap_address(struct net_device *dev,
4895 struct iw_request_info *info,
4896 union iwreq_data *wrqu, char *extra)
4897{
4898 int ret;
4899
4900 vos_ssr_protect(__func__);
4901 ret = __iw_set_ap_address(dev, info, wrqu, extra);
4902 vos_ssr_unprotect(__func__);
4903
4904 return ret;
4905}
4906
Jeff Johnson295189b2012-06-20 16:38:30 -07004907/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004908
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304909 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004910 This function returns the BSSID to the wpa_supplicant
4911 \param - dev - Pointer to the net device.
4912 - info - Pointer to the iw_request_info.
4913 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004914 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004916
Jeff Johnson295189b2012-06-20 16:38:30 -07004917 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304918int __iw_get_ap_address(struct net_device *dev,
4919 struct iw_request_info *info,
4920 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004921{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304922 hdd_station_ctx_t *pHddStaCtx;
4923 hdd_adapter_t *pAdapter;
4924 hdd_context_t *pHddCtx;
4925 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304926
Jeff Johnson295189b2012-06-20 16:38:30 -07004927 ENTER();
4928
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304929 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4930 if (NULL == pAdapter)
4931 {
4932 hddLog(VOS_TRACE_LEVEL_ERROR,
4933 "%s: Adapter is NULL", __func__);
4934 return -EINVAL;
4935 }
4936 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4937 ret = wlan_hdd_validate_context(pHddCtx);
4938 if (0 != ret)
4939 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304940 return ret;
4941 }
4942 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4943 if (NULL == pHddStaCtx)
4944 {
4945 hddLog(VOS_TRACE_LEVEL_ERROR,
4946 "%s: pHddStaCtx is NULL", __func__);
4947 return -EINVAL;
4948 }
4949
Jeff Johnson295189b2012-06-20 16:38:30 -07004950 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
4951 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
4952 {
Jeff Johnson4416a782013-03-25 14:17:50 -07004953 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07004954 }
4955 else
4956 {
4957 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4958 }
4959 EXIT();
4960 return 0;
4961}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004962
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304963int iw_get_ap_address(struct net_device *dev,
4964 struct iw_request_info *info,
4965 union iwreq_data *wrqu, char *extra)
4966{
4967 int ret;
4968
4969 vos_ssr_protect(__func__);
4970 ret = __iw_get_ap_address(dev, info, wrqu, extra);
4971 vos_ssr_unprotect(__func__);
4972
4973 return ret;
4974}
4975
Chet Lanctot186b5732013-03-18 10:26:30 -07004976#ifdef WLAN_FEATURE_11W
4977/**---------------------------------------------------------------------------
4978
4979 \brief hdd_indicateUnprotMgmtFrame -
4980 This function forwards the unprotected management frame to the supplicant
4981 \param - pAdapter - Pointer to HDD adapter
4982 - nFrameLength - Length of the unprotected frame being passed
4983 - pbFrames - Pointer to the frame buffer
4984 - frameType - 802.11 frame type
4985 \return - nothing
4986
4987 --------------------------------------------------------------------------*/
4988void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
4989 tANI_U32 nFrameLength,
4990 tANI_U8* pbFrames,
4991 tANI_U8 frameType )
4992{
4993 tANI_U8 type = 0;
4994 tANI_U8 subType = 0;
4995
4996 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
4997 __func__, frameType, nFrameLength);
4998
4999 /* Sanity Checks */
5000 if (NULL == pAdapter)
5001 {
5002 hddLog( LOGE, FL("pAdapter is NULL"));
5003 return;
5004 }
5005
5006 if (NULL == pAdapter->dev)
5007 {
5008 hddLog( LOGE, FL("pAdapter->dev is NULL"));
5009 return;
5010 }
5011
5012 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
5013 {
5014 hddLog( LOGE, FL("pAdapter has invalid magic"));
5015 return;
5016 }
5017
5018 if( !nFrameLength )
5019 {
5020 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
5021 return;
5022 }
5023
5024 if (NULL == pbFrames) {
5025 hddLog( LOGE, FL("pbFrames is NULL"));
5026 return;
5027 }
5028
5029 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
5030 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
5031
5032 /* Get pAdapter from Destination mac address of the frame */
5033 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
5034 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305035#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5036 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5037#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005038 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305039#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005040 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
5041 }
5042 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
5043 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305044#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5045 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5046#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005047 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305048#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005049 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
5050 }
5051 else
5052 {
5053 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
5054 return;
5055 }
5056}
5057#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005058
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005059#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005060void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
5061 tANI_U8 state,
5062 tANI_U16 measInterval )
5063{
5064 union iwreq_data wrqu;
5065 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005066 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005067
5068 if (NULL == pAdapter)
5069 return;
5070
5071 // create the event
5072 memset(&wrqu, '\0', sizeof(wrqu));
5073 memset(buf, '\0', sizeof(buf));
5074
5075 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
5076 tid, state, measInterval);
5077
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005078 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005079
5080 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005081 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005082 // send the event
5083 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5084}
5085
5086void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
5087{
5088 union iwreq_data wrqu;
5089 char buf[IW_CUSTOM_MAX + 1];
5090 char *pos = buf;
5091 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5092
5093 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5094 return;
5095
5096 // create the event
5097 memset(&wrqu, '\0', sizeof(wrqu));
5098 memset(buf, '\0', sizeof(buf));
5099
5100 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305101 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
5102 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
5103 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
5104 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005105
5106 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
5107 pos += nBytes;
5108 freeBytes -= nBytes;
5109
5110 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
5111 pos += WNI_CFG_BSSID_LEN;
5112 freeBytes -= WNI_CFG_BSSID_LEN;
5113
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005114 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
5115 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005116
5117 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005118 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005119
5120 // send the event
5121 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5122}
5123
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005124void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005125{
5126 union iwreq_data wrqu;
5127 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005128 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005129
5130 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5131 return;
5132
5133 // create the event
5134 memset(&wrqu, '\0', sizeof(wrqu));
5135 memset(buf, '\0', sizeof(buf));
5136
5137 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
5138
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005139 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005140
5141 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005142 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005143
5144 // send the event
5145 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5146}
5147
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005148void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
5149 const tANI_U16 measurementToken,
5150 const tANI_BOOLEAN flag,
5151 const tANI_U8 numBss)
5152{
5153 union iwreq_data wrqu;
5154 char buf[IW_CUSTOM_MAX];
5155 char *pos = buf;
5156 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5157
5158 memset(&wrqu, '\0', sizeof(wrqu));
5159 memset(buf, '\0', sizeof(buf));
5160
5161 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
5162 numBss);
5163
5164 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
5165 flag, numBss);
5166
5167 wrqu.data.pointer = buf;
5168 wrqu.data.length = nBytes;
5169 // send the event
5170 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5171}
5172
5173
5174static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005175 const tCsrRoamInfo *pRoamInfo)
5176{
5177 union iwreq_data wrqu;
5178 char buf[IW_CUSTOM_MAX + 1];
5179 char *pos = buf;
5180 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5181 tANI_U8 i = 0, len = 0;
5182 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
5183 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005184 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
5185 tANI_U8 ieLenByte = 1;
5186 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
5187#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005188
5189 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5190 return;
5191
5192 /* Custom event can pass maximum of 256 bytes of data,
5193 based on the IE len we need to identify how many BSS info can
5194 be filled in to custom event data */
5195 /*
5196 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
5197 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
5198 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
5199 */
5200
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005201 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005202 {
5203 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
5204 /* If the measurement is none and no scan results found,
5205 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005206 hdd_indicateEseBcnReportNoResults(pAdapter,
5207 pRoamInfo->pEseBcnReportRsp->measurementToken,
5208 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005209 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005210 }
5211 else
5212 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005213 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005214 {
5215 memset(&wrqu, '\0', sizeof(wrqu));
5216 memset(buf, '\0', sizeof(buf));
5217 tot_bcn_ieLen = 0;
5218 sendBss = 0;
5219 pos = buf;
5220 freeBytes = IW_CUSTOM_MAX;
5221
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005222 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005223 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005224 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
5225 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005226 {
5227 break;
5228 }
5229 tot_bcn_ieLen += len;
5230 sendBss++;
5231 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
5232 "IeLength(%d) Length of Ie(%d) totLen(%d)",
5233 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005234 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005235 tot_bcn_ieLen);
5236 }
5237
5238 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
5239 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005240 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5241 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005242
5243 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005244 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5245 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005246 pos += nBytes;
5247 freeBytes -= nBytes;
5248
5249 /* Copy total Beacon report data length */
5250 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
5251 pos += sizeof(tot_bcn_ieLen);
5252 freeBytes -= sizeof(tot_bcn_ieLen);
5253
5254 for (i = 0; i < sendBss; i++)
5255 {
5256 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305257 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
5258 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005259 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005260 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
5261 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
5262 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
5263 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
5264 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
5265 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
5266 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
5267 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
5268 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
5269 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
5270 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
5271 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
5272 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
5273 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
5274 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
5275 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005276
5277 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005278 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
5279 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005280 pos += len;
5281 freeBytes -= len;
5282
5283 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005284 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005285 vos_mem_copy(pos, (char*)&len, sizeof(len));
5286 pos += sizeof(len);
5287 freeBytes -= sizeof(len);
5288
5289 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005290 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005291 pos += len;
5292 freeBytes -= len;
5293 }
5294
5295 wrqu.data.pointer = buf;
5296 wrqu.data.length = strlen(buf);
5297
5298 // send the event
5299 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5300 lastSent += sendBss;
5301 }
5302 }
5303}
5304
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005305#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005306