blob: 4956bb4cbfe8137bbc60c0b0ceaf3034632050e9 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302 * Copyright (c) 2012-2015 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
678 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
679 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
680 * and fFTEnable is TRUE */
681#ifdef WLAN_FEATURE_VOWIFI_11R
682 // Send FT Keys to the supplicant when FT is enabled
683 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700684 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800685#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700686 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
687 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
688#endif
689 )
690 {
691 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
692 }
693#endif
694 }
695 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
696 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530697 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -0700698 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 type = WLAN_STA_ASSOC_DONE_IND;
Arif Hussain24bafea2013-11-15 15:10:03 -0800700 pr_info("wlan: new IBSS connection to " MAC_ADDRESS_STR"\n",
701 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700702 }
703 else /* Not Associated */
704 {
705 pr_info("wlan: disconnected\n");
706 type = WLAN_STA_DISASSOC_DONE_IND;
707 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
708 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700709 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700710
711 msg = NULL;
712 /*During the WLAN uninitialization,supplicant is stopped before the
713 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530714 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700715 {
716 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800717#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700718 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700719 {
720 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
721 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700722 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
723 }
724#endif
725 }
726 send_btc_nlink_msg(type, 0);
727}
728
729void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
730{
731 // Remove staId, bssId and peerMacAddress
732 pHddStaCtx->conn_info.staId [ 0 ] = 0;
733 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
734 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
735
736 // Clear all security settings
737 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
738 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
739 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
740
741 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700742 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700743
744 // Set not-connected state
745 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -0700746
747 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
748}
Katya Nigam47528772015-02-11 12:24:49 +0530749
750VOS_STATUS hdd_ibss_deinit_tx_rx_sta ( hdd_adapter_t *pAdapter, v_U8_t STAId )
751{
Katya Nigam1fd24402015-02-16 14:52:19 +0530752 v_U8_t ac;
753 /**Track whether OS TX queue has been disabled.*/
754 v_BOOL_t txSuspended[NUM_TX_QUEUES];
755 v_U8_t tlAC;
Katya Nigam47528772015-02-11 12:24:49 +0530756 v_U8_t i;
757 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
758 hdd_ibss_peer_info_t *pPeerInfo;
759
760 if( NULL == pHddStaCtx )
761 {
762 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
763 "%s: HDD station context NULL ",__func__);
764 return VOS_STATUS_E_FAILURE;
765 }
Katya Nigam1fd24402015-02-16 14:52:19 +0530766
Katya Nigam47528772015-02-11 12:24:49 +0530767 pPeerInfo = &pHddStaCtx->ibss_peer_info;
768 if (FALSE == pPeerInfo->ibssStaInfo[STAId].isUsed)
769 {
770 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
771 "%s: Deinit station not inited %d", __func__, STAId );
772 return VOS_STATUS_E_FAILURE;
773 }
774
775 hdd_flush_ibss_tx_queues(pAdapter, STAId);
Katya Nigam1fd24402015-02-16 14:52:19 +0530776
777 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
778 {
779 tlAC = hdd_QdiscAcToTlAC[ac];
780 txSuspended[ac] = pPeerInfo->ibssStaInfo[STAId].txSuspended[tlAC];
781 }
782
Katya Nigam47528772015-02-11 12:24:49 +0530783 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
784
Katya Nigam1fd24402015-02-16 14:52:19 +0530785 /* re-init hdd list, since netdev can still open adapter until
786 * driver gets unloaded
787 */
788 for (i = 0; i < NUM_TX_QUEUES; i ++)
789 {
790 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i],
791 HDD_TX_QUEUE_MAX_LEN);
792 }
793
794 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
795 {
796 if (txSuspended[ac])
797 {
798 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
799 "%s: TX queue re-enabled", __func__);
800 netif_wake_subqueue(pAdapter->dev, ac);
801 }
802 }
Katya Nigam47528772015-02-11 12:24:49 +0530803 return VOS_STATUS_SUCCESS;
804}
805
806static VOS_STATUS hdd_ibss_DeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
807{
808 VOS_STATUS vosStatus;
809
810 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
811 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
812 {
813 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
814 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
815 "Status= %d [0x%08X]",
816 __func__, staId, vosStatus, vosStatus );
817 }
818
819 vosStatus = hdd_ibss_deinit_tx_rx_sta ( pAdapter, staId );
820 if( VOS_STATUS_E_FAILURE == vosStatus )
821 {
822 VOS_TRACE ( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
823 "hdd_ibss_deinit_tx_rx_sta() failed for staID %d. "
824 "Status = %d [0x%08X]",
825 staId, vosStatus, vosStatus );
826 }
827
828 return( vosStatus );
829}
830
831VOS_STATUS hdd_ibss_init_tx_rx_sta( hdd_adapter_t *pAdapter, v_U8_t STAId, v_MACADDR_t *pmacAddrSTA)
832{
833 v_U8_t i = 0;
834 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
835 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
836
837 if (pPeerInfo->ibssStaInfo[STAId].isUsed)
838 {
839 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
840 "%s: Reinit station %d", __func__, STAId );
841 return VOS_STATUS_E_FAILURE;
842 }
843
844 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
845 for (i = 0; i < NUM_TX_QUEUES; i ++)
846 {
847 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i], HDD_TX_QUEUE_MAX_LEN);
848 }
849
850 pPeerInfo->ibssStaInfo[STAId].isUsed = VOS_TRUE;
851 pPeerInfo->ibssStaInfo[STAId].isDeauthInProgress = VOS_FALSE;
852 vos_copy_macaddr( &pPeerInfo->ibssStaInfo[STAId].macAddrSTA, pmacAddrSTA);
853
854 return VOS_STATUS_SUCCESS;
855}
856
857static VOS_STATUS hdd_ibss_RegisterSTA( hdd_adapter_t *pAdapter,
858 tCsrRoamInfo *pRoamInfo,
859 v_U8_t staId,
860 v_MACADDR_t *pPeerMacAddress,
861 tSirBssDescription *pBssDesc )
862{
863 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
864 WLAN_STADescType staDesc = {0};
865 eCsrEncryptionType connectedCipherAlgo;
866 v_BOOL_t fConnected;
867 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
868 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
869 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
870
871 if ( pPeerInfo->ibssStaInfo[staId].isUsed )
872 {
873 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
874 "clean up old entry for STA %d", staId);
875 hdd_ibss_DeregisterSTA( pAdapter, staId );
876 }
877
878 staDesc.ucSTAId = staId;
879 staDesc.wSTAType = WLAN_STA_IBSS;
880
881 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
882 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
883 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
884 // pass when making an Infrastructure connection.
885 vos_mem_copy(staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes));
886 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId, 6 );
887 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
888
889 if (hdd_wmm_is_active(pAdapter))
890 {
891 staDesc.ucQosEnabled = 1;
892 }
893 else
894 {
895 staDesc.ucQosEnabled = 0;
896 }
897 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
898 "HDD SOFTAP register TL QoS_enabled=%d",
899 staDesc.ucQosEnabled );
900
901 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
902 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
903 {
904 staDesc.ucProtectedFrame = 1;
905 }
906 else
907 {
908 staDesc.ucProtectedFrame = 0;
909
910 }
911
912 hdd_ibss_init_tx_rx_sta(pAdapter, staId, &staDesc.vSTAMACAddress);
913
914 // UMA is Not ready yet, Xlation will be done by TL
915 staDesc.ucSwFrameTXXlation = 1;
916 staDesc.ucSwFrameRXXlation = 1;
917 staDesc.ucAddRmvLLC = 1;
918 // Initialize signatures and state
919 staDesc.ucUcastSig = pRoamInfo->ucastSig;
920 staDesc.ucBcastSig = pRoamInfo->bcastSig;
921 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED;
922
923 staDesc.ucIsReplayCheckValid = VOS_FALSE;
924
925 // Register the Station with TL.
926 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
927 hdd_rx_packet_cbk,
928 hdd_tx_complete_cbk,
929 hdd_ibss_tx_fetch_packet_cbk, &staDesc,
930 pBssDesc->rssi );
931 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
932 {
933 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
934 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
935 vosStatus, vosStatus );
936 return vosStatus;
937 }
938
939 //Timer value should be in milliseconds
940 if ( pHddCtx->cfg_ini->dynSplitscan &&
941 ( VOS_TIMER_STATE_RUNNING !=
942 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
943 {
944 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
945 pHddCtx->cfg_ini->trafficMntrTmrForSplitScan);
946 }
947
948 pPeerInfo->ibssStaInfo[staId].ucSTAId = staId;
949 pPeerInfo->ibssStaInfo[staId].isQosEnabled = staDesc.ucQosEnabled;
950
951 vosStatus = WLANTL_ChangeSTAState( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staDesc.ucSTAId,
952 WLANTL_STA_AUTHENTICATED );
953
954 pPeerInfo->ibssStaInfo[staId].tlSTAState = WLANTL_STA_AUTHENTICATED;
955 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
956
957 return( vosStatus );
958}
959
Jeff Johnson295189b2012-06-20 16:38:30 -0700960/* TODO Revist this function. and data path */
961static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
962{
963 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700964
Katya Nigam47528772015-02-11 12:24:49 +0530965 hdd_disconnect_tx_rx(pAdapter);
Ravi Joshif9520d62013-10-18 04:11:46 -0700966
Jeff Johnson295189b2012-06-20 16:38:30 -0700967 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
968 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
969 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530970 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700971 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700972 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700973 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700974 }
975 return( vosStatus );
976}
977
978
979static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
980 tANI_U32 roamId, eRoamCmdStatus roamStatus,
981 eCsrRoamResult roamResult )
982{
983 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700984 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700985 struct net_device *dev = pAdapter->dev;
986 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
987 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700988 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530989 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700990
991 // Sanity check
992 if(dev == NULL)
993 {
Agarwal Ashish971c2882013-10-30 20:11:12 +0530994 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700995 "%s: net_dev is released return", __func__);
996 return eHAL_STATUS_FAILURE;
997 }
998
Jeff Johnson295189b2012-06-20 16:38:30 -0700999 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301000 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001001 netif_tx_disable(dev);
1002 netif_carrier_off(dev);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +05301003 //TxTimeoutCount need to reset in case of disconnect handler
1004 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001005
Jeff Johnsone7245742012-09-05 17:12:55 -07001006 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301007 /* If only STA mode is on */
1008 if((pHddCtx->concurrency_mode <= 1) &&
1009 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
1010 {
1011 pHddCtx->isAmpAllowed = VOS_TRUE;
1012 }
1013
Agarwal Ashish47d18112014-08-04 19:55:07 +05301014 /* Need to apply spin lock before decreasing active sessions
1015 * as there can be chance for double decrement if context switch
1016 * Calls wlan_hdd_disconnect.
1017 */
1018
1019 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singh087de602015-10-21 17:18:55 +05301020
1021 /* HDD has initiated disconnect, do not send disconnect indication
1022 * to kernel. Sending disconnected event to kernel for userspaces
1023 * initiated disconnect will be handled by hdd_DisConnectHandler call
1024 * to cfg80211_disconnected.
1025 */
1026 if ((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
1027 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301028 {
1029 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1030 FL(" HDD has initiated a disconnect, no need to send"
1031 " disconnect indication to kernel"));
1032 sendDisconInd = FALSE;
1033 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301034 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -07001035 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301036 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singh087de602015-10-21 17:18:55 +05301037 FL("Set HDD connState to eConnectionState_Disconnecting from %d "),
Agarwal Ashish47d18112014-08-04 19:55:07 +05301038 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301039 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
1040 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001041 }
Agarwal Ashish47d18112014-08-04 19:55:07 +05301042 spin_unlock_bh(&pAdapter->lock_for_active_session);
1043
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -07001045
1046 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07001047
1048 // indicate 'disconnect' status to wpa_supplicant...
1049 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001050 /* indicate disconnected event to nl80211 */
1051 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
1052 {
1053 /*During the WLAN uninitialization,supplicant is stopped before the
1054 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301055 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 {
Sushant Kaushik0b343422015-05-25 17:15:55 +05301057 if (sendDisconInd)
1058 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1059 "%s: sent disconnected event to nl80211",
1060 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001061#ifdef WLAN_FEATURE_P2P_DEBUG
1062 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1063 {
1064 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
1065 {
1066 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
1067 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
1068 "and moved to disconnected state");
1069 }
1070 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
1071 {
1072 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
1073 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
1074 "and moved to inactive state");
1075 }
1076 }
1077#endif
Sushant Kaushikbad61892015-07-10 16:43:28 +05301078 if ((roamStatus == eCSR_ROAM_LOSTLINK) &&
1079 !pRoamInfo->reasonCode)
1080 wlan_hdd_get_frame_logs(pAdapter,
1081 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301082 /*Only send indication to kernel if not initiated by kernel*/
1083 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -07001084 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301085 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
1086 if ( eCSR_ROAM_LOSTLINK == roamStatus )
1087 {
1088 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
1089 }
1090 else
1091 {
1092 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
1093 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001094 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301095
1096 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1097 {
1098 hddLog(LOG1,
1099 FL("P2P client is getting removed and we are tryig to re-enable TDLS"));
1100 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301101 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301102
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 //If the Device Mode is Station
1104 // and the P2P Client is Connected
1105 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001106
1107 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001108 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07001109 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -07001110 {
1111 //Enable BMPS only of other Session is P2P Client
1112 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001113 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001114
1115 if (NULL != pVosContext)
1116 {
1117 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1118
1119 if(NULL != pHddCtx)
1120 {
1121 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301122 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1123 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001124 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301125 if (pHddCtx->hdd_wlan_suspended)
1126 {
1127 hdd_set_pwrparams(pHddCtx);
1128 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001129 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301130 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001131 }
1132 }
1133 }
1134 }
1135 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001136
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +05301137 hdd_wmm_adapter_clear(pAdapter);
Mukul Sharmac159c432014-01-15 15:42:46 +05301138#if defined(WLAN_FEATURE_VOWIFI_11R)
1139 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
1140#endif
Katya Nigam63ce1772014-09-26 15:53:49 +05301141
1142 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
1143 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301144 v_U8_t i;
1145
Katya Nigam63ce1772014-09-26 15:53:49 +05301146 sta_id = IBSS_BROADCAST_STAID;
Katya Nigam47528772015-02-11 12:24:49 +05301147 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Katya Nigam63ce1772014-09-26 15:53:49 +05301148 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1149 {
1150 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301151 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1152 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +05301153 sta_id, status, status );
1154
1155 status = eHAL_STATUS_FAILURE;
1156 }
Katya Nigam63ce1772014-09-26 15:53:49 +05301157 pHddCtx->sta_to_adapter[sta_id] = NULL;
1158
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301159 /*Clear all the peer sta register with TL.*/
1160 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
1161 {
1162 if (0 != pHddStaCtx->conn_info.staId[i])
1163 {
1164 sta_id = pHddStaCtx->conn_info.staId[i];
1165
1166 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1167 FL("Deregister StaID %d"),sta_id);
Katya Nigam47528772015-02-11 12:24:49 +05301168 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301169 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1170 {
1171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1172 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1173 "Status= %d [0x%x]"),
1174 sta_id, status, status );
1175 status = eHAL_STATUS_FAILURE;
1176 }
1177
Nirav Shah7e3c8132015-06-22 23:51:42 +05301178 vstatus = hdd_sta_id_hash_remove_entry(pAdapter,
1179 sta_id, &pHddStaCtx->conn_info.peerMacAddress[i]);
1180 if (vstatus != VOS_STATUS_SUCCESS) {
1181 hddLog(VOS_TRACE_LEVEL_ERROR,
1182 FL("Not able to remove staid hash %d"),
1183 sta_id);
1184 status = eHAL_STATUS_FAILURE;
1185 } else {
1186 hddLog(VOS_TRACE_LEVEL_INFO,
1187 FL("ibss station removed sta_id %d mac:"
1188 MAC_ADDRESS_STR), sta_id,
1189 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[i].bytes));
1190 }
1191
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301192 /*set the staid and peer mac as 0, all other reset are
1193 * done in hdd_connRemoveConnectInfo.
1194 */
1195 pHddStaCtx->conn_info.staId[i]= 0;
1196 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
1197
1198 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1199 pHddCtx->sta_to_adapter[sta_id] = NULL;
1200 }
1201 }
1202
Katya Nigam63ce1772014-09-26 15:53:49 +05301203 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301204 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001205 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301206 sta_id = pHddStaCtx->conn_info.staId[0];
1207
1208 //We should clear all sta register with TL, for now, only one.
1209 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
1210 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1211 {
1212 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1213 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1214 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -07001215 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001216
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301217 status = eHAL_STATUS_FAILURE;
1218 }
1219
1220 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 }
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301222
1223#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1224 if (VOS_STATUS_SUCCESS !=
1225 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1226 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE_AC))
1227 {
1228 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1229 "WLANTL_ClearInterfaceStats Failed", __func__);
1230 }
1231 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1232 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1233 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1234 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1235#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1236
Jeff Johnson295189b2012-06-20 16:38:30 -07001237 // Clear saved connection information in HDD
1238 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhf4669da2014-05-26 15:07:49 +05301239 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1240 "%s: Set HDD connState to eConnectionState_NotConnected",
1241 __func__);
1242 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301243#ifdef WLAN_FEATURE_GTK_OFFLOAD
1244 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1245 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1246 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301247 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1248 sizeof (tSirGtkOffloadParams));
1249 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301250 }
1251#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001252
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001253#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001254 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1255 {
1256 wlan_hdd_tdls_disconnection_callback(pAdapter);
1257 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001258#endif
1259
Jeff Johnson295189b2012-06-20 16:38:30 -07001260 //Unblock anyone waiting for disconnect to complete
1261 complete(&pAdapter->disconnect_comp_var);
1262 return( status );
1263}
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301264
1265static void hdd_postTLPacketPendingInd(hdd_adapter_t *pAdapter,
1266 v_U8_t staId)
1267{
1268 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1269 v_SINT_t i;
1270 v_SIZE_t size;
1271 VOS_STATUS status;
1272 v_BOOL_t granted = VOS_FALSE;
1273
1274 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1275 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ||
1276 (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE))
1277 {
1278 //Indicate to TL that there is pending data if a queue is non empty
1279 for (i = WLANTL_AC_HIGH_PRIO; i>=0; --i)
1280 {
1281 size = 0;
1282 hdd_list_size(&pAdapter->wmm_tx_queue[i], &size);
1283 if (size > 0)
1284 {
1285 if (i != WLANTL_AC_HIGH_PRIO)
1286 {
1287 if (VOS_FALSE ==
1288 pAdapter->hddWmmStatus.wmmAcStatus[i].wmmAcAccessAllowed)
1289 {
1290 hdd_wmm_acquire_access(pAdapter,
1291 (WLANTL_ACEnumType)i, &granted);
1292 pAdapter->psbChanged |= (1 << i);
1293 }
1294 else
1295 granted = VOS_TRUE;
1296 }
1297
1298 if (granted || (i == WLANTL_AC_HIGH_PRIO))
1299 {
1300 status = WLANTL_STAPktPending(pHddCtx->pvosContext,
1301 staId, (WLANTL_ACEnumType)i);
1302 if (!VOS_IS_STATUS_SUCCESS(status))
1303 {
1304 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1305 "%s: Failure in indicating pkt to TL for QID=%d",
1306 __func__, i);
1307 }
1308 }
1309 }
1310 }
1311 }
1312}
1313
Jeff Johnson295189b2012-06-20 16:38:30 -07001314static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
1315 tCsrRoamInfo *pRoamInfo,
1316 v_U8_t staId,
1317 v_MACADDR_t *pPeerMacAddress,
1318 tSirBssDescription *pBssDesc )
1319{
1320 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1321 WLAN_STADescType staDesc = {0};
1322 eCsrEncryptionType connectedCipherAlgo;
1323 v_BOOL_t fConnected;
1324 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1325 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001326 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001327
1328 if ( NULL == pBssDesc)
1329 {
1330 return VOS_STATUS_E_FAILURE;
1331 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001332 // Get the Station ID from the one saved during the assocation.
1333 staDesc.ucSTAId = staId;
1334
Katya Nigam47528772015-02-11 12:24:49 +05301335 staDesc.wSTAType = WLAN_STA_INFRA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001336
Katya Nigam47528772015-02-11 12:24:49 +05301337 // grab the bssid from the connection info in the adapter structure and hand that
1338 // over to TL when registering.
1339 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,
1340 sizeof(pHddStaCtx->conn_info.bssId) );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001341
Jeff Johnson295189b2012-06-20 16:38:30 -07001342 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1343
1344 // set the QoS field appropriately
1345 if (hdd_wmm_is_active(pAdapter))
1346 {
1347 staDesc.ucQosEnabled = 1;
1348 }
1349 else
1350 {
1351 staDesc.ucQosEnabled = 0;
1352 }
1353
1354 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1355 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1356 {
1357 staDesc.ucProtectedFrame = 1;
1358 }
1359 else
1360 {
1361 staDesc.ucProtectedFrame = 0;
1362
1363 }
1364
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001365#ifdef FEATURE_WLAN_ESE
1366 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
1367#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001368
1369#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1370 /* check whether replay check is valid for the station or not */
1371 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
1372 {
1373 /* Encryption mode is either TKIP or AES
1374 and replay check is valid for only these
1375 two encryption modes */
1376 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1377 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1378 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1379 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001380
Jeff Johnson295189b2012-06-20 16:38:30 -07001381 else
1382 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001383 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001384 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001385 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001386 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1387 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1388 }
1389#endif
1390
1391#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001392 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001393 if (pAdapter->wapi_info.fIsWapiSta)
1394 {
1395 staDesc.ucIsWapiSta = 1;
1396 }
1397 else
1398 {
1399 staDesc.ucIsWapiSta = 0;
1400 }
1401#endif /* FEATURE_WLAN_WAPI */
1402
1403 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1404 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1405
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 // UMA is Not ready yet, Xlation will be done by TL
1407 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001408 staDesc.ucSwFrameRXXlation = 1;
1409 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001410 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001411 staDesc.ucQosEnabled );
1412 // Initialize signatures and state
1413 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1414 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1415 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1416 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001417 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001418 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 -07001419 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1420 hdd_rx_packet_cbk,
1421 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001422 hdd_tx_fetch_packet_cbk, &staDesc,
1423 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001424
Jeff Johnson295189b2012-06-20 16:38:30 -07001425 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1426 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001427 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001428 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001429 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001430 return vosStatus;
1431 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001432
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001433 if ( cfg_param->dynSplitscan &&
1434 ( VOS_TIMER_STATE_RUNNING !=
1435 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1436 {
1437 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1438 cfg_param->trafficMntrTmrForSplitScan);
1439 }
1440
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301441 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1442 // then go to 'authenticated'. For all other authentication types
1443 // (those that donot require upper layer authentication) we can put
1444 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001445 if (staDesc.wSTAType != WLAN_STA_IBSS)
1446 VOS_ASSERT( fConnected );
1447
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301448 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001449 {
1450 // Connections that do not need Upper layer auth, transition TL directly
1451 // to 'Authenticated' state.
1452 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1453 WLANTL_STA_AUTHENTICATED );
1454
1455 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301456
1457 hdd_postTLPacketPendingInd(pAdapter, staDesc.ucSTAId);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001458 }
1459 else
1460 {
1461 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301462 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1463 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001464 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301465 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001466 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001468 return( vosStatus );
1469}
1470
Jeff Johnson295189b2012-06-20 16:38:30 -07001471static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1472 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1473{
1474 unsigned int len = 0;
1475 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001476 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001477 tANI_U32 rspRsnLength = 0;
1478 struct ieee80211_channel *chan;
1479
Agarwal Ashish51325b52014-06-16 16:50:49 +05301480 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001481 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001482 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001483 }
1484
Agarwal Ashish51325b52014-06-16 16:50:49 +05301485 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001486 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1487 goto done;
1488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001489
Agarwal Ashish51325b52014-06-16 16:50:49 +05301490 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001491 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1492 goto done;
1493 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001494
1495 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1496 pCsrRoamInfo->nAssocReqLength);
1497 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001498 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001499
1500 //pFTAssocRsp needs to point to the IEs
1501 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001502 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001503 (unsigned int)pFTAssocRsp[0],
1504 (unsigned int)pFTAssocRsp[1]);
1505
1506 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001507 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001509 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001510 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001511
1512 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1513 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1514 reqRsnIe, reqRsnLength,
1515 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001516
1517done:
1518 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001519}
Jeff Johnson295189b2012-06-20 16:38:30 -07001520
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301521void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1522{
1523 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1524 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1525 tCsrRoamInfo roamInfo;
1526 roamInfo.fAuthRequired = FALSE;
1527 vos_mem_copy(roamInfo.bssid,
1528 pHddStaCtx->roam_info.bssid,
1529 WNI_CFG_BSSID_LEN);
1530 vos_mem_copy(roamInfo.peerMac,
1531 pHddStaCtx->roam_info.peerMac,
1532 WNI_CFG_BSSID_LEN);
1533
1534 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1535 &roamInfo,
1536 pHddStaCtx->roam_info.roamId,
1537 pHddStaCtx->roam_info.roamStatus,
1538 eCSR_ROAM_RESULT_AUTHENTICATED);
1539 if (halStatus != eHAL_STATUS_SUCCESS)
1540 {
1541 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1542 }
1543 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1544}
1545
Shailender Karmuchia734f332013-04-19 14:02:48 -07001546static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1547 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001548 eCsrRoamResult roamResult )
1549{
1550 struct net_device *dev = pAdapter->dev;
1551 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1552 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301553 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05301554 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001555 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1556 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001557#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001558 int ft_carrier_on = FALSE;
1559#endif
1560 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301561 v_BOOL_t hddDisconInProgress = FALSE;
1562
1563 /* HDD has initiated disconnect, do not send connect result indication
1564 * to kernel as it will be handled by __cfg80211_disconnect.
1565 */
Agarwal Ashishc089cec2015-08-10 13:10:04 +05301566 if (((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
1567 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)) &&
1568 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
1569 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301570 {
1571 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1572 FL(" Disconnect from HDD in progress "));
1573 hddDisconInProgress = TRUE;
1574 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001575
Jeff Johnson295189b2012-06-20 16:38:30 -07001576 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1577 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301578 if ( !hddDisconInProgress )
1579 {
1580 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05301581 "%s: Set HDD connState to eConnectionState_Associated",
1582 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301583 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1584 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001585
c_hpothu44ff4e02014-05-08 00:13:57 +05301586 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001587 // Save the connection info from CSR...
1588 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1589#ifdef FEATURE_WLAN_WAPI
1590 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1591 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1592 {
1593 pAdapter->wapi_info.fIsWapiSta = 1;
1594 }
1595 else
1596 {
1597 pAdapter->wapi_info.fIsWapiSta = 0;
1598 }
1599#endif /* FEATURE_WLAN_WAPI */
1600
1601 // indicate 'connect' status to userspace
1602 hdd_SendAssociationEvent(dev,pRoamInfo);
1603
1604
Shailender Karmuchia734f332013-04-19 14:02:48 -07001605 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001606 INIT_COMPLETION(pAdapter->linkup_event_var);
1607
1608 /*
1609 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1610 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 -07001611 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 know that the device is getting activated properly.
1613 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001614#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05301615 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07001616 {
1617#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001618 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001619 pAdapter->isLinkUpSvcNeeded = TRUE;
1620
Shailender Karmuchia734f332013-04-19 14:02:48 -07001621 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001622 pAdapter->isLinkUpSvcNeeded = TRUE;
1623
1624 // Switch on the Carrier to activate the device
1625 netif_carrier_on(dev);
1626
1627 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1628 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1629 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001630 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 {
1632 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1633 }
1634
1635 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1636 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001637#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001638 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001639 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001640 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001641 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001642 }
1643#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05301644 /* Check for STAID */
1645 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
1646 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1647 else
1648 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001649
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001650#ifdef FEATURE_WLAN_TDLS
1651 wlan_hdd_tdls_connection_callback(pAdapter);
1652#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001653 //For reassoc, the station is already registered, all we need is to change the state
1654 //of the STA in TL.
1655 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05301656 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07001657 if( !pRoamInfo->fReassocReq )
1658 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001659 struct cfg80211_bss *bss;
1660#ifdef WLAN_FEATURE_VOWIFI_11R
1661 u8 *pFTAssocRsp = NULL;
1662 unsigned int assocRsplen = 0;
1663 u8 *pFTAssocReq = NULL;
1664 unsigned int assocReqlen = 0;
1665 struct ieee80211_channel *chan;
1666#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001667 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001669
1670 /* add bss_id to cfg80211 data base */
1671 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1672 if (NULL == bss)
1673 {
1674 pr_err("wlan: Not able to create BSS entry\n");
Katya Nigam346d4e92014-09-02 16:16:12 +05301675 netif_carrier_off(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001676 return eHAL_STATUS_FAILURE;
1677 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001678#ifdef WLAN_FEATURE_VOWIFI_11R
1679 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001680 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001681 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001682
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001683 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001684 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001685 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001686 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001687 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001688 // pFTAssocRsp needs to point to the IEs
1689 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1690 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1691 (unsigned int)pFTAssocRsp[0],
1692 (unsigned int)pFTAssocRsp[1]);
1693 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001694 }
1695 else
1696 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001697 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1698 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001699 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001700
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001701 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001702 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001703 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001704 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001705 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001706 if(!ft_carrier_on)
1707 {
1708 // pFTAssocReq needs to point to the IEs
1709 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1710 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1711 (unsigned int)pFTAssocReq[0],
1712 (unsigned int)pFTAssocReq[1]);
1713 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1714 }
1715 else
1716 {
1717 /* This should contain only the FTIEs */
1718 assocReqlen = pRoamInfo->nAssocReqLength;
1719 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001720 }
1721 else
1722 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001723 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1724 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001725 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001726
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001727 if(ft_carrier_on)
1728 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301729 if ( !hddDisconInProgress )
1730 {
1731 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001732 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301733 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001734 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301735 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001736 assocRsplen);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301737 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1738 {
1739 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1740 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301741 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001742 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1743 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301744 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301745 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1746 {
1747 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1748 pRoamInfo->fAuthRequired = FALSE;
1749
1750 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1751 pRoamInfo->bssid,
1752 HDD_MAC_ADDR_LEN);
1753 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1754 pRoamInfo->peerMac,
1755 HDD_MAC_ADDR_LEN);
1756 pHddStaCtx->roam_info.roamId = roamId;
1757 pHddStaCtx->roam_info.roamStatus = roamStatus;
1758 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1759 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001760 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301761 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001762 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001763 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001764 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001765 cfg80211_connect_result(dev, pRoamInfo->bssid,
1766 pFTAssocReq, assocReqlen,
1767 pFTAssocRsp, assocRsplen,
1768 WLAN_STATUS_SUCCESS,
1769 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001770 }
1771 }
1772 else
1773#endif
1774 {
1775 /* wpa supplicant expecting WPA/RSN IE in connect result */
1776 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1777 pAdapter->sessionId,
1778 &reqRsnLength,
1779 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001780
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001781 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1782 pAdapter->sessionId,
1783 &rspRsnLength,
1784 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301785 if ( !hddDisconInProgress )
1786 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001787#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301788 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05301789 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301790 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301791 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1792 {
1793 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1794 }
Mukul Sharma84f27252014-07-14 18:11:42 +05301795 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301796 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001797#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001798
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301799 {
1800 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301801 "%s: sending connect indication to nl80211:"
1802 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301803 " result:%d and Status:%d",
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301804 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1805 roamResult, roamStatus);
1806
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301807 /* inform connect result to nl80211 */
1808 cfg80211_connect_result(dev, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001809 reqRsnIe, reqRsnLength,
1810 rspRsnIe, rspRsnLength,
1811 WLAN_STATUS_SUCCESS,
1812 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301813 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001814 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001815 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301816 if ( !hddDisconInProgress )
1817 {
1818 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07001819#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301820 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07001821#endif
1822 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301823 // Register the Station with TL after associated...
1824 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001825 pRoamInfo,
1826 pHddStaCtx->conn_info.staId[ 0 ],
1827 NULL,
1828 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301829 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001830 }
1831 else
1832 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001833 /* wpa supplicant expecting WPA/RSN IE in connect result */
1834 /* in case of reassociation also need to indicate it to supplicant */
1835 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1836 pAdapter->sessionId,
1837 &reqRsnLength,
1838 reqRsnIe);
1839
1840 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301842 if( pRoamInfo->fAuthRequired )
1843 {
1844 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1845 pHddStaCtx->conn_info.staId[ 0 ],
1846 WLANTL_STA_CONNECTED );
1847 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1848 }
1849 else
1850 {
1851 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1852 "%s: staId: %d Changing TL state to AUTHENTICATED",
1853 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1854 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1855 pHddStaCtx->conn_info.staId[ 0 ],
1856 WLANTL_STA_AUTHENTICATED );
1857 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301858 hdd_postTLPacketPendingInd(pAdapter,
1859 pHddStaCtx->conn_info.staId[0]);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 }
1862
1863 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1864 {
1865 // perform any WMM-related association processing
1866 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1867 }
1868 else
1869 {
1870 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001871 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001872 vosStatus, vosStatus );
1873 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001874#ifdef WLAN_FEATURE_11W
1875 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1876 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1877#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301878
Jeff Johnson295189b2012-06-20 16:38:30 -07001879 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05301880 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301881 {
1882 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05301883 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301884 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301885 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1886 {
1887 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
1888 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001889 }
1890 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001891 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001892 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1893
1894 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001895 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001896 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301897 " result:%d and Status:%d",
Arif Hussain24bafea2013-11-15 15:10:03 -08001898 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1899 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001900 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001901 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301902 " result:%d and Status:%d",
Arif Hussain24bafea2013-11-15 15:10:03 -08001903 MAC_ADDR_ARRAY(pWextState->req_bssId),
1904 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001905
Sachin Ahuja674c5112015-10-14 13:16:49 +05301906 if (( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus) ||
1907 ((roamResult != eCSR_ROAM_RESULT_ASSOCIATED) &&
1908 (eCSR_ROAM_ASSOCIATION_COMPLETION == roamStatus)))
Abhishek Singh611295e2015-07-09 11:11:54 +05301909 wlan_hdd_get_frame_logs(pAdapter,
Siddharth Bhalda0d1622015-04-24 15:47:49 +05301910 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
1911
Abhishek Singhf4669da2014-05-26 15:07:49 +05301912 /* Set connection state to eConnectionState_NotConnected only when CSR
1913 * has completed operation - with a ASSOCIATION_FAILURE status
1914 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301915 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05301916 {
1917 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1918 "%s: Set HDD connState to eConnectionState_NotConnected",
1919 __func__);
1920 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1921 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05301922 if((pHddCtx->concurrency_mode <= 1) &&
1923 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07001924 {
1925 pHddCtx->isAmpAllowed = VOS_TRUE;
1926 }
1927
1928 //If the Device Mode is Station
1929 // and the P2P Client is Connected
1930 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001931
1932 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001933 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001934 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1935 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05301936 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 {
1938 //Enable BMPS only of other Session is P2P Client
1939 hdd_context_t *pHddCtx = NULL;
1940 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1941
1942 if (NULL != pVosContext)
1943 {
1944 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1945
1946 if(NULL != pHddCtx)
1947 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301948 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301949 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1950 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301951 {
1952 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001953 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301954 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001955 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301956 hdd_enable_bmps_imps(pHddCtx);
1957 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001958 }
1959 }
1960 }
1961
James Zmudafbf5ffc2013-03-25 12:45:35 -07001962 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001963 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301964 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07001965 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301966
1967 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1968 {
1969 hddLog(LOG1,
1970 FL("Assoication Failure for P2P client and we are trying to re-enable TDLS"));
1971 wlan_hdd_tdls_reenable(pHddCtx);
1972 }
1973
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301974 if (pRoamInfo)
1975 hddLog(VOS_TRACE_LEVEL_ERROR,
1976 "%s: send connect failure to nl80211:"
1977 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301978 " result:%d and Status:%d reasonCode %d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301979 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301980 roamResult, roamStatus, pRoamInfo->reasonCode);
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301981 else
1982 hddLog(VOS_TRACE_LEVEL_ERROR,
1983 "%s: connect failed:"
1984 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05301985 " result:%d and Status:%d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301986 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
1987 roamResult, roamStatus);
1988
James Zmudafbf5ffc2013-03-25 12:45:35 -07001989 /* inform association failure event to nl80211 */
1990 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1991 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001992 if (pRoamInfo)
1993 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1994 NULL, 0, NULL, 0,
1995 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1996 GFP_KERNEL );
1997 else
1998 cfg80211_connect_result ( dev, pWextState->req_bssId,
1999 NULL, 0, NULL, 0,
2000 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
2001 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07002002 }
2003 else
2004 {
Sushant Kaushik21f28232014-12-18 11:42:46 +05302005 if (pRoamInfo){
2006 eCsrAuthType authType =
2007 pWextState->roamProfile.AuthType.authType[0];
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302008 eCsrEncryptionType encryptionType =
2009 pWextState->roamProfile.EncryptionType.encryptionType[0];
2010 v_BOOL_t isWep =
2011 (((authType == eCSR_AUTH_TYPE_OPEN_SYSTEM) ||
2012 (authType == eCSR_AUTH_TYPE_SHARED_KEY)) &&
2013 ((encryptionType == eCSR_ENCRYPT_TYPE_WEP40) ||
2014 (encryptionType == eCSR_ENCRYPT_TYPE_WEP104) ||
2015 (encryptionType ==
2016 eCSR_ENCRYPT_TYPE_WEP40_STATICKEY) ||
2017 (encryptionType ==
2018 eCSR_ENCRYPT_TYPE_WEP104_STATICKEY)));
2019
Sushant Kaushik21f28232014-12-18 11:42:46 +05302020
2021 /* In case of OPEN-WEP or SHARED-WEP authentication,
2022 * send exact protocol reason code. This enables user
2023 * applications to reconnect the station with correct
2024 * configuration.
2025 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002026 cfg80211_connect_result ( dev, pRoamInfo->bssid,
2027 NULL, 0, NULL, 0,
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302028 (isWep && pRoamInfo->reasonCode) ?
2029 pRoamInfo->reasonCode :
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002030 WLAN_STATUS_UNSPECIFIED_FAILURE,
2031 GFP_KERNEL );
Sushant Kaushik21f28232014-12-18 11:42:46 +05302032 } else
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002033 cfg80211_connect_result ( dev, pWextState->req_bssId,
2034 NULL, 0, NULL, 0,
2035 WLAN_STATUS_UNSPECIFIED_FAILURE,
2036 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07002037 }
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302038 /*Clear the roam profile*/
2039 hdd_clearRoamProfileIe( pAdapter );
Jeff Johnsone7245742012-09-05 17:12:55 -07002040 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002041
Kumar Anand82c009f2014-05-29 00:29:42 -07002042 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07002043
c_hpothu24f40982014-04-18 18:00:36 +05302044 if (pRoamInfo)
2045 {
2046 WLANTL_AssocFailed(pRoamInfo->staId);
2047 }
Mihir Sheteb7337272014-04-11 15:53:08 +05302048
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302049 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002050 netif_tx_disable(dev);
2051 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002052
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 }
2054
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302055 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302056 {
2057 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
2058 if (pHostapdAdapter != NULL)
2059 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302060 /* Restart SAP if its operating channel is different
2061 * from AP channel.
2062 */
2063 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
2064 (int)pRoamInfo->pBssDesc->channelId)
2065 {
2066 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
2067 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
2068 (int)pRoamInfo->pBssDesc->channelId);
Deepthi Gowric9c777d2014-12-10 16:17:11 +05302069 hdd_hostapd_stop(pHostapdAdapter->dev);
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302070 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302071 }
2072 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 return eHAL_STATUS_SUCCESS;
2074}
2075
2076/**============================================================================
2077 *
Jeff Johnson81c17882013-05-03 09:53:35 -07002078 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07002079 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07002080
Jeff Johnson295189b2012-06-20 16:38:30 -07002081 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07002082static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
2083 tCsrRoamInfo *pRoamInfo,
2084 tANI_U32 roamId,
2085 eRoamCmdStatus roamStatus,
2086 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07002087{
Katya Nigam47528772015-02-11 12:24:49 +05302088 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2089 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2090 struct cfg80211_bss *bss;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302091 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Katya Nigam47528772015-02-11 12:24:49 +05302092
Jeff Johnson81c17882013-05-03 09:53:35 -07002093 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
2094 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
2095
Jeff Johnson295189b2012-06-20 16:38:30 -07002096 switch( roamResult )
2097 {
2098 // both IBSS Started and IBSS Join should come in here.
2099 case eCSR_ROAM_RESULT_IBSS_STARTED:
2100 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002101 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07002102 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002103 if (NULL == pRoamInfo)
2104 {
2105 VOS_ASSERT(0);
2106 return;
2107 }
2108
2109 /* When IBSS Started comes from CSR, we need to move
2110 * connection state to IBSS Disconnected (meaning no peers
2111 * are in the IBSS).
2112 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05302113 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2114 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
2115 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07002116 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2117 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302118 /*notify wmm */
2119 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002120 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002121
Jeff Johnson81c17882013-05-03 09:53:35 -07002122 if (pRoamInfo->pBssDesc)
2123 {
Anand N Sunkadfec40682015-07-29 09:51:17 +05302124#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2125 struct ieee80211_channel *chan;
2126 int chan_no;
2127 unsigned int freq;
2128#endif
Katya Nigam47528772015-02-11 12:24:49 +05302129 hdd_ibss_RegisterSTA (pAdapter, pRoamInfo,
2130 IBSS_BROADCAST_STAID,
2131 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson81c17882013-05-03 09:53:35 -07002132
2133 /* we created the IBSS, notify supplicant */
2134 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
2135 MAC_ADDRESS_STR,
2136 __func__, pAdapter->dev->name,
2137 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2138
2139 /* we must first give cfg80211 the BSS information */
2140 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2141 if (NULL == bss)
2142 {
2143 hddLog(VOS_TRACE_LEVEL_ERROR,
2144 "%s: %s: unable to create IBSS entry",
2145 __func__, pAdapter->dev->name);
2146 return;
2147 }
Anand N Sunkadfec40682015-07-29 09:51:17 +05302148#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2149 chan_no = pRoamInfo->pBssDesc->channelId;
Jeff Johnson81c17882013-05-03 09:53:35 -07002150
Anand N Sunkadfec40682015-07-29 09:51:17 +05302151 if (chan_no <= 14)
2152 freq = ieee80211_channel_to_frequency(chan_no,
2153 IEEE80211_BAND_2GHZ);
2154 else
2155 freq = ieee80211_channel_to_frequency(chan_no,
2156 IEEE80211_BAND_5GHZ);
2157
2158 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
2159
2160 if (chan)
2161 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
2162 chan, GFP_KERNEL);
2163 else
2164 hddLog(LOGE, FL("%s: chanId: %d, can't find channel"),
2165 pAdapter->dev->name,
2166 (int)pRoamInfo->pBssDesc->channelId);
2167#else
Jeff Johnson81c17882013-05-03 09:53:35 -07002168 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302169#endif
Yue Maf49ba872013-08-19 12:04:25 -07002170 cfg80211_put_bss(
2171#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2172 pHddCtx->wiphy,
2173#endif
2174 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07002175 }
Katya Nigam47528772015-02-11 12:24:49 +05302176 else
2177 {
2178 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2179 "%s: NULL Bss Desc",__func__);
2180 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05302181
2182 /* Set Broadcast key again in case IBSS_COALESCED as DEL BSS,
2183 * in IBSS_COALESCED will remove the BC key.
2184 */
2185 if ((eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) &&
2186 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY
2187 == pHddStaCtx->ibss_enc_key.encType
2188 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY
2189 == pHddStaCtx->ibss_enc_key.encType
2190 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2191 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType ))
2192 {
2193 u8 grpmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2194 VOS_STATUS vosStatus;
2195
2196 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2197
2198 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2199 grpmacaddr, WNI_CFG_BSSID_LEN);
2200 hddLog(VOS_TRACE_LEVEL_INFO,
2201 FL(" SET GTK in case of COALESCED"));
2202 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2203 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2204 if ( VOS_STATUS_SUCCESS != vosStatus )
2205 {
2206 hddLog(VOS_TRACE_LEVEL_ERROR,
2207 FL("sme_RoamSetKey failed, returned %d"),vosStatus);
2208 }
2209 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 break;
2211 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002212
Jeff Johnson295189b2012-06-20 16:38:30 -07002213 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
2214 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002215 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
2216 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 break;
2218 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002219
Jeff Johnson295189b2012-06-20 16:38:30 -07002220 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07002221 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
2222 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002224 }
2225
Jeff Johnson81c17882013-05-03 09:53:35 -07002226 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002227}
2228
2229/**============================================================================
2230 *
2231 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
2232 This information is passed to iwconfig later. The peer that joined
2233 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002234 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002235 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002236
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 ===========================================================================*/
Nirav Shah7e3c8132015-06-22 23:51:42 +05302238static int roamSaveIbssStation(hdd_adapter_t *pAdapter, v_U8_t staId, v_MACADDR_t *peerMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07002239{
2240 int fSuccess = FALSE;
2241 int idx = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302242 VOS_STATUS status;
2243 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002244
Jeff Johnson295189b2012-06-20 16:38:30 -07002245 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2246 {
2247 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
2248 {
2249 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002250
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002252
Jeff Johnson295189b2012-06-20 16:38:30 -07002253 fSuccess = TRUE;
2254 break;
2255 }
2256 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002257
Nirav Shah7e3c8132015-06-22 23:51:42 +05302258 status = hdd_sta_id_hash_add_entry(pAdapter, staId, peerMacAddress);
2259 if (status != VOS_STATUS_SUCCESS) {
2260 hddLog(VOS_TRACE_LEVEL_ERROR,
2261 FL("Not able to add staid hash %d"), staId);
2262 return FALSE;
2263 }
2264
2265 hddLog(VOS_TRACE_LEVEL_INFO,
2266 FL("New station added sta_id %d mac:"
2267 MAC_ADDRESS_STR), staId,
2268 MAC_ADDR_ARRAY(peerMacAddress->bytes));
2269
Shailender Karmuchia734f332013-04-19 14:02:48 -07002270 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07002271}
2272/**============================================================================
2273 *
2274 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002275 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002276 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002277
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07002279static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07002280{
2281 int fSuccess = FALSE;
2282 int idx = 0;
2283 v_U8_t valid_idx = 0;
2284 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07002285 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002286 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Nirav Shah7e3c8132015-06-22 23:51:42 +05302287 VOS_STATUS status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002288
Jeff Johnson295189b2012-06-20 16:38:30 -07002289 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2290 {
2291 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
2292 {
2293 pHddStaCtx->conn_info.staId[ idx ] = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302294 status = hdd_sta_id_hash_remove_entry(pAdapter,
2295 staId, &pHddStaCtx->conn_info.peerMacAddress[idx]);
2296 if (status != VOS_STATUS_SUCCESS) {
2297 hddLog(VOS_TRACE_LEVEL_ERROR,
2298 FL("Not able to remove staid hash %d"), staId );
2299 fSuccess = FALSE;
2300 } else {
2301 hddLog(VOS_TRACE_LEVEL_INFO,
2302 FL("station removed sta_id %d mac:"
2303 MAC_ADDRESS_STR), staId,
2304 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[idx].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07002305
Nirav Shah7e3c8132015-06-22 23:51:42 +05302306 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002307
Nirav Shah7e3c8132015-06-22 23:51:42 +05302308 fSuccess = TRUE;
2309 // Note the deleted Index, if its 0 we need special handling
2310 del_idx = idx;
2311 empty_slots++;
2312 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002313 }
2314 else
2315 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002316 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002317 {
2318 valid_idx = idx;
2319 }
Ravi Joshi8a934352013-09-25 16:46:58 -07002320 else
2321 {
2322 // Found an empty slot
2323 empty_slots++;
2324 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 }
2326 }
2327
Ravi Joshi8a934352013-09-25 16:46:58 -07002328 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
2329 {
2330 // Last peer departed, set the IBSS state appropriately
2331 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002332 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07002333 "Last IBSS Peer Departed!!!" );
2334 }
2335
Jeff Johnson295189b2012-06-20 16:38:30 -07002336 // Find next active staId, to have a valid sta trigger for TL.
2337 if (fSuccess == TRUE)
2338 {
2339 if (del_idx == 0)
2340 {
2341 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
2342 {
2343 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
2344 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
2345 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
2346
2347 pHddStaCtx->conn_info.staId[valid_idx] = 0;
2348 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
2349 }
2350 }
2351 }
2352 return( fSuccess );
2353}
2354
2355/**============================================================================
2356 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002357 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07002358 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002359
Jeff Johnson295189b2012-06-20 16:38:30 -07002360 ===========================================================================*/
2361static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
2362{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002363 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05302364 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2365 "%s: IBSS Connect Indication from SME!!! "
2366 "Set HDD connState to eConnectionState_IbssConnected",
2367 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002368 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
2369 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
2370
2371 // Save the connection info from CSR...
2372 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
2373
2374 // Send the bssid address to the wext.
2375 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002376 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002377 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2378 if (NULL == bss)
2379 {
2380 hddLog(VOS_TRACE_LEVEL_ERROR,
2381 "%s: %s: unable to create IBSS entry",
2382 __func__, pAdapter->dev->name);
2383 return eHAL_STATUS_FAILURE;
2384 }
Yue Maf49ba872013-08-19 12:04:25 -07002385 cfg80211_put_bss(
2386#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2387 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
2388#endif
2389 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07002390
2391 return( eHAL_STATUS_SUCCESS );
2392}
2393/**============================================================================
2394 *
Mukul Sharmad2589a52014-04-23 21:06:25 +05302395 @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
2396 suspend related data which was cleared during roaming in FWR.
2397
2398 ===========================================================================*/
2399static void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
2400{
2401 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
2402 hdd_adapter_t *pAdapter;
2403 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
2404 ENTER();
2405
2406 spin_lock(&pHddCtx->filter_lock);
2407 if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
2408 {
2409 pHddCtx->sus_res_mcastbcast_filter =
2410 pHddCtx->configuredMcastBcastFilter;
2411 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
2412 hddLog(VOS_TRACE_LEVEL_INFO, FL("offload: callback to associated"));
2413 hddLog(VOS_TRACE_LEVEL_INFO,
2414 FL("saving configuredMcastBcastFilter = %d"),
2415 pHddCtx->configuredMcastBcastFilter);
2416 hddLog(VOS_TRACE_LEVEL_INFO,
2417 FL("offload: calling hdd_conf_mcastbcast_filter"));
2418 }
2419 spin_unlock(&pHddCtx->filter_lock);
2420
2421 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
2422 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
2423 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
2424
2425 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
2426 //No need to configure GTK Offload from here because it might possible
2427 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
2428 //be handled as part of cfg80211_set_rekey_data processing.
2429 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
2430 {
2431 pAdapter = pAdapterNode->pAdapter;
2432 if( pAdapter &&
2433 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
2434 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
2435 {
2436 if (pHddCtx->cfg_ini->fhostArpOffload)
2437 {
2438 //Configure ARPOFFLOAD
2439 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
2440 if (!VOS_IS_STATUS_SUCCESS(vstatus))
2441 {
2442 hddLog(VOS_TRACE_LEVEL_ERROR,
2443 FL("Failed to disable ARPOffload Feature %d"), vstatus);
2444 }
2445 }
2446#ifdef WLAN_NS_OFFLOAD
2447 //Configure NSOFFLOAD
2448 if (pHddCtx->cfg_ini->fhostNSOffload)
2449 {
2450 hdd_conf_ns_offload(pAdapter, TRUE);
2451 }
2452#endif
Mukul Sharma25e70c32014-05-22 12:50:24 +05302453#ifdef WLAN_FEATURE_PACKET_FILTERING
2454 /* During suspend, configure MC Addr list filter to the firmware
2455 * function takes care of checking necessary conditions before
2456 * configuring.
2457 */
2458 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
2459#endif
Mukul Sharmad2589a52014-04-23 21:06:25 +05302460 }
2461 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2462 pAdapterNode = pNext;
2463 }
2464 EXIT();
2465}
2466
2467/**============================================================================
2468 *
Jeff Johnson295189b2012-06-20 16:38:30 -07002469 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002470
Jeff Johnson295189b2012-06-20 16:38:30 -07002471 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002472static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2473 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 eCsrRoamResult roamResult )
2475{
2476 eCsrEncryptionType connectedCipherAlgo;
2477 v_BOOL_t fConnected = FALSE;
2478 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2479 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Bhargav Shaha805ef22015-07-29 17:31:38 +05302480 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002481 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302482 WLANTL_STAStateType prevTLState = WLANTL_STA_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07002483 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07002484
2485 if (NULL == pRoamInfo)
2486 {
2487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
2488 return eHAL_STATUS_FAILURE;
2489 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002490 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002491 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07002492 // not require upper layer authentication) we can put TL directly into 'authenticated'
2493 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002494 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2495 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
2496 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002497
Jeff Johnson295189b2012-06-20 16:38:30 -07002498 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2499 if( fConnected )
2500 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002501 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
2502 {
2503 v_U8_t staId;
2504
2505 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2506
2507 if ( 0 == memcmp( pRoamInfo->peerMac,
2508 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
2509 {
2510 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2511 IBSS_BROADCAST_STAID);
Abhishek Singhb25e8442015-06-23 14:28:05 +05302512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2513 "WLAN TL STA GTK Installed for STAID=%d", IBSS_BROADCAST_STAID);
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002514 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2515 }
2516 else
2517 {
2518 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
2519 (v_MACADDR_t*)pRoamInfo->peerMac,
2520 &staId);
2521 if ( VOS_STATUS_SUCCESS == vosStatus )
2522 {
2523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2524 "WLAN TL STA Ptk Installed for STAID=%d", staId);
2525 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2526 staId);
2527 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2528 }
2529 }
2530 }
2531 else
2532 {
Bhargav Shaha805ef22015-07-29 17:31:38 +05302533 WLANTL_GetSTAState(pHddCtx->pvosContext,
2534 pHddStaCtx->conn_info.staId[0],
2535 &prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302536 // TODO: Considering getting a state machine in HDD later.
2537 // This routine is invoked twice. 1)set PTK 2)set GTK.
2538 // The folloing if statement will be TRUE when setting GTK.
2539 // At this time we don't handle the state in detail.
2540 // Related CR: 174048 - TL not in authenticated state
2541 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
2542 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
2543 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302544
2545 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
2546 "for StaId=%d. Changing TL state to AUTHENTICATED from"
2547 " state:%d", pHddStaCtx->conn_info.staId[0], prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302548
2549 // Connections that do not need Upper layer authentication,
2550 // transition TL to 'Authenticated' state after the keys are set.
2551 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2552 pHddStaCtx->conn_info.staId[ 0 ],
2553 WLANTL_STA_AUTHENTICATED );
2554
2555 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302556
2557 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2558 hdd_postTLPacketPendingInd(pAdapter,
2559 pHddStaCtx->conn_info.staId[0]);
Mukul Sharmad2589a52014-04-23 21:06:25 +05302560 //Need to call offload because when roaming happen at that time fwr
2561 //clean offload info as part of the DelBss
2562 // No need to configure offload if host was not suspended
2563 spin_lock(&pHddCtx->filter_lock);
2564 if(pHddCtx->hdd_wlan_suspended)
2565 {
2566 spin_unlock(&pHddCtx->filter_lock);
2567 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
2568 }
2569 else
2570 {
2571 spin_unlock(&pHddCtx->filter_lock);
2572 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302573 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2574 {
2575 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
2576 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302577 }
2578 else
2579 {
2580 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2581 pHddStaCtx->conn_info.staId[ 0 ]);
Bhargav Shaha805ef22015-07-29 17:31:38 +05302582
2583 /* In case of OSEN move TL to 'Authenticated' after PTK is set */
2584 if (pWextState->roamProfile.bOSENAssociation == VOS_TRUE)
2585 {
2586 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "PTK set"
2587 " for StaId=%d. Due to OSEN, Changing TL state to"
2588 "AUTHENTICATED from state:%d",
2589 pHddStaCtx->conn_info.staId[0], prevTLState);
2590
2591 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2592 pHddStaCtx->conn_info.staId[ 0 ],
2593 WLANTL_STA_AUTHENTICATED );
2594
2595 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
2596
2597 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2598 hdd_postTLPacketPendingInd(pAdapter,
2599 pHddStaCtx->conn_info.staId[0]);
2600 }
2601
2602
2603
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302604 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2605 {
2606 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
2607 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302608 }
2609
2610 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002612 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302613 else
2614 {
2615 // possible disassoc after issuing set key and waiting set key complete
2616 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2617 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002618
Jeff Johnson295189b2012-06-20 16:38:30 -07002619 EXIT();
2620 return( eHAL_STATUS_SUCCESS );
2621}
2622/**============================================================================
2623 *
2624 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2625 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002626static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002628{
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2630
2631 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2632 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2633 {
2634 struct iw_michaelmicfailure msg;
2635 union iwreq_data wreq;
2636 memset(&msg, '\0', sizeof(msg));
2637 msg.src_addr.sa_family = ARPHRD_ETHER;
2638 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002639 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2640 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002641
Jeff Johnson295189b2012-06-20 16:38:30 -07002642 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2643 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002644 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 msg.flags = IW_MICFAILURE_PAIRWISE;
2646 memset(&wreq, 0, sizeof(wreq));
2647 wreq.data.length = sizeof(msg);
2648 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002649 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002650 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2652 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2653 NL80211_KEYTYPE_GROUP :
2654 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002655 pRoamInfo->u.pMICFailureInfo->keyId,
2656 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002657 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002658
Jeff Johnson295189b2012-06-20 16:38:30 -07002659 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002660
Jeff Johnson295189b2012-06-20 16:38:30 -07002661 return( eHAL_STATUS_SUCCESS );
2662}
2663
2664/**============================================================================
2665 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002666 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002667 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002668
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002670static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2671 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 eCsrRoamResult roamResult )
2673{
2674 VOS_STATUS vosStatus;
2675
2676 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2677 switch( roamResult )
2678 {
2679 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2680 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002681 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002682 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002683
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002684 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002685 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2686 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2687 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002688 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002689
Nirav Shah7e3c8132015-06-22 23:51:42 +05302690 if ( !roamSaveIbssStation( pAdapter, pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 {
2692 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2693 "New IBSS peer but we already have the max we can handle. Can't register this one" );
2694 break;
2695 }
2696
2697 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2698
Shailender Karmuchia734f332013-04-19 14:02:48 -07002699 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2700 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2701 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2702
2703 // Register the Station with TL for the new peer.
Katya Nigam47528772015-02-11 12:24:49 +05302704 vosStatus = hdd_ibss_RegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002705 pRoamInfo,
2706 pRoamInfo->staId,
2707 (v_MACADDR_t *)pRoamInfo->peerMac,
2708 pRoamInfo->pBssDesc );
2709 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2710 {
2711 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002712 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002713 vosStatus, vosStatus );
2714 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002715 pHddStaCtx->ibss_sta_generation++;
2716 memset(&staInfo, 0, sizeof(staInfo));
2717 staInfo.filled = 0;
2718 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2719
2720 cfg80211_new_sta(pAdapter->dev,
2721 (const u8 *)pRoamInfo->peerMac,
2722 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002723
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002724 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2725 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2726 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2727 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2728 {
2729 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302730
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002731 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2732 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2733
2734 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002735 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002736 pHddStaCtx->ibss_enc_key.encType);
2737
2738 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2739 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2740
2741 if ( VOS_STATUS_SUCCESS != vosStatus )
2742 {
2743 hddLog(VOS_TRACE_LEVEL_ERROR,
2744 "%s: sme_RoamSetKey failed, returned %d",
2745 __func__, vosStatus);
2746 return VOS_STATUS_E_FAILURE;
2747 }
2748 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002749 netif_carrier_on(pAdapter->dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302750 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 netif_tx_start_all_queues(pAdapter->dev);
2752 break;
2753 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002754
Jeff Johnson295189b2012-06-20 16:38:30 -07002755 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2756 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002757
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002759
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002761 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002762 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2763 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002764 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002765
Ravi Joshicc57ed42013-10-12 16:31:25 -07002766 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002767 {
2768 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2769 "IBSS peer departed by cannot find peer in our registration table with TL" );
2770 }
2771
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002772 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002773 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2774 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2775 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2776 pRoamInfo->staId );
2777
Katya Nigam47528772015-02-11 12:24:49 +05302778 hdd_ibss_DeregisterSTA( pAdapter, pRoamInfo->staId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002779
2780 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002781 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002782
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002783 cfg80211_del_sta(pAdapter->dev,
2784 (const u8 *)&pRoamInfo->peerMac,
2785 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 break;
2787 }
2788 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2789 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002790 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2791 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002792 // Stop only when we are inactive
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302793 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002794 netif_tx_disable(pAdapter->dev);
2795 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05302796 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2797 "%s: Set HDD connState to eConnectionState_NotConnected",
2798 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002799 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002800
Jeff Johnson295189b2012-06-20 16:38:30 -07002801 // Send the bssid address to the wext.
2802 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2803 // clean up data path
2804 hdd_disconnect_tx_rx(pAdapter);
2805 break;
2806 }
2807 default:
2808 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002809
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002811
Jeff Johnson295189b2012-06-20 16:38:30 -07002812 return( eHAL_STATUS_SUCCESS );
2813}
2814
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002815#ifdef FEATURE_WLAN_TDLS
2816/**============================================================================
2817 *
2818 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2819 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2820 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002821
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002822 ===========================================================================*/
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05302823VOS_STATUS hdd_roamRegisterTDLSSTA(hdd_adapter_t *pAdapter,
2824#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
2825 const tANI_U8 *peerMac,
2826#else
2827 tANI_U8 *peerMac,
2828#endif
2829 tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002830{
2831 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002832 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002833 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2834 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002835 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2836 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002837 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2838 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002839
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002840 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2841 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002842 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002843 "%s not connected. ignored", __func__);
2844 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002845 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002846
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002847 /*
2848 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2849 * be peer MAC, here we are wokrking on direct Link
2850 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002851 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002852
2853 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002854
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002855 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002856 sizeof(tSirMacAddr) );
2857
2858 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2859 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2860
2861 /* set the QoS field appropriately ..*/
2862 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2863 : (staDesc.ucQosEnabled = 0) ;
2864
2865 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002866 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002867
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002868 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002869
2870 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002871 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002872
Shailender Karmuchia734f332013-04-19 14:02:48 -07002873 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002874 * UMA is ready we inform TL to do frame translation.
2875 */
2876 staDesc.ucSwFrameTXXlation = 1;
2877 staDesc.ucSwFrameRXXlation = 1;
2878 staDesc.ucAddRmvLLC = 1;
2879
2880 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002881 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002882
2883 /* tdls Direct Link do not need bcastSig */
2884 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002885
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002886#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2887 if(staDesc.ucProtectedFrame)
2888 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2889 else
2890 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2891#endif
2892
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302893 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002894
Shailender Karmuchia734f332013-04-19 14:02:48 -07002895 /* Register the Station with TL... */
2896 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2897 hdd_rx_packet_cbk,
2898 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002899 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002900
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002901 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2902 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002903 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002904 "%s: WLANTL_RegisterSTAClient() failed to register. "
2905 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002906 return vosStatus;
2907 }
2908
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002909 if ( cfg_param->dynSplitscan &&
2910 ( VOS_TIMER_STATE_RUNNING !=
2911 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2912 {
2913 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2914 cfg_param->trafficMntrTmrForSplitScan);
2915 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002916 return( vosStatus );
2917}
2918
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05302919VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002920{
2921 VOS_STATUS vosStatus;
2922 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2923 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2924 {
2925 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2926 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002927 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002928 __func__, staId, vosStatus, vosStatus );
2929 }
2930 return( vosStatus );
2931}
2932
2933
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002934/*
2935 * HDD interface between SME and TL to ensure TDLS client registration with
2936 * TL in case of new TDLS client is added and deregistration at the time
2937 * TDLS client is deleted.
2938 */
2939
Shailender Karmuchia734f332013-04-19 14:02:48 -07002940eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2941 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002942 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002943 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002944 eCsrRoamResult roamResult)
2945{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002946 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002947 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002948 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002949
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002951 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2952 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2953 "ADD_TDLS_PEER" :
2954 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2955 "DEL_TDLS_PEER" :
2956 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2957 "DEL_TDLS_PEER_IND" :
2958 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2959 "DEL_ALL_TDLS_PEER_IND" :
2960 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2961 "UPDATE_TDLS_PEER" :
2962 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2963 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2964 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002965 switch( roamResult )
2966 {
2967 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2968 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002969 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2970 {
2971 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002972 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05302973 wlan_hdd_tdls_check_bmps(pAdapter);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002974 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002975 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002976 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002977
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002978 /* check if there is available index for this new TDLS STA */
2979 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2980 {
2981 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2982 {
2983 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2984 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2985
2986 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002987 ("TDLS: STA IDX at %d is %d "
2988 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002989 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002990 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002991
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002992 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002993 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2994 status = eHAL_STATUS_SUCCESS ;
2995 break ;
2996 }
2997 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002998 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002999 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003000 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003001 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3002 "wlan_hdd_tdls_set_sta_id() failed");
3003 return VOS_FALSE;
3004 }
3005
3006 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303007 /* store the ucast signature , if required for further reference. */
3008
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003009 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303010 /* start TDLS client registration with TL */
3011 status = hdd_roamRegisterTDLSSTA( pAdapter,
3012 pRoamInfo->peerMac,
3013 pRoamInfo->staId,
3014 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303015 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003016 }
3017 else
3018 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003019 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003020 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07003021 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003022 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003023 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003024 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003025 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003026 break ;
3027 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003028 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3029 {
3030 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3031 {
3032 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3033 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
3034 }
3035 /* store the ucast signature which will be used later when
3036 * registering to TL
3037 */
3038 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3039 complete(&pAdapter->tdls_add_station_comp);
3040 break;
3041 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303042 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3043 {
3044 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3045 {
3046 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3047 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
3048 }
3049 complete(&pAdapter->tdls_link_establish_req_comp);
3050 break;
3051 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003052 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003053 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003054 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003055 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003056 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003057 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3058 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003059 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003060 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003061 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
3062
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303063 mutex_lock(&pHddCtx->tdls_lock);
3064 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3065 pRoamInfo->peerMac, FALSE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303066 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003067 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303068 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3069 " Current status for peer" MAC_ADDRESS_STR "is %d",
3070 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303071 if (TDLS_IS_CONNECTED(curr_peer) ||
3072 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303073 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303074 mutex_unlock(&pHddCtx->tdls_lock);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303075 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
3076 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303077 else
3078 mutex_unlock(&pHddCtx->tdls_lock);
3079
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303080 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003081 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303082 else
3083 mutex_unlock(&pHddCtx->tdls_lock);
3084
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003085 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003086
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003087 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3088 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
3089 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003090 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003091 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003092 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003093 break ;
3094 }
3095 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003096 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003097 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003098 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003099 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3100 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003101 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003102 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3103 "%s: Sending teardown to supplicant with reason code %u",
3104 __func__, pRoamInfo->reasonCode);
3105
3106#ifdef CONFIG_TDLS_IMPLICIT
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303107 mutex_lock(&pHddCtx->tdls_lock);
3108 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac,
3109 FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003110 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303111 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003112#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003113 status = eHAL_STATUS_SUCCESS ;
3114 break ;
3115 }
3116 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3117 {
3118 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003119 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003120 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003121 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3122 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003123 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003124 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003125 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003126 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003127 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003128 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
3129 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3130 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003131
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003132 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003133 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003134 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3135 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003136
3137 status = eHAL_STATUS_SUCCESS ;
3138 }
3139 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303140 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003141 break ;
3142 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003143 default:
3144 {
3145 break ;
3146 }
3147 }
3148
3149 return status ;
3150}
3151#endif
3152
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05303153void iw_full_power_cbfn (void *pContext, eHalStatus status)
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003154{
3155 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3156 hdd_context_t *pHddCtx = NULL;
3157 int ret;
3158
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303159 ENTER();
3160
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003161 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3162 {
3163 hddLog(VOS_TRACE_LEVEL_ERROR,
3164 "%s: Bad param, pAdapter [%p]",
3165 __func__, pAdapter);
3166 return;
3167 }
3168
3169 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3170 ret = wlan_hdd_validate_context(pHddCtx);
3171 if (0 != ret)
3172 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003173 return;
3174 }
3175
3176 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3177 {
3178 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
3179 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303180
3181 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003182}
3183
Shailender Karmuchia734f332013-04-19 14:02:48 -07003184eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003185 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
3186{
3187 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
3188 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303189 hdd_wext_state_t *pWextState = NULL;
3190 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003191 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07003192 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003193
3194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003195 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003196 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003197
3198 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303199 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003200 {
3201 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303202 "invalid adapter or adapter has invalid magic");
3203 return eHAL_STATUS_FAILURE;
3204 }
3205
3206 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3207 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3208
3209 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3210 {
3211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3212 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003213 return eHAL_STATUS_FAILURE;
3214 }
3215
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05303216 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
3217 pAdapter->sessionId, roamStatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 switch( roamStatus )
3219 {
3220 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki41d95e22015-08-28 12:51:32 +05303221 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
3222 complete(&pAdapter->session_open_comp_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07003223 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003224
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003225#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
3226 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003227 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07003228 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07003229 * interface down */
3230 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303231 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
3232 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05303233 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003234 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3235 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
3236 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003237 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3238 }
3239 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05303240 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003241 break;
3242
3243 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003244 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07003245 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07003246 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07003247 // eCSR_ROAM_SHOULD_ROAM will be received.
3248 // Where in we will not mark the link down
3249 // Also we want to stop tx at this point when we will be
3250 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003251 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 {
3253 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303254 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303256 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3257 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3258 {
3259 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
3260 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003261 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303262 * Deregister this STA with TL, but do not flush the packets
3263 * for this STA from wmm_tx_queue. Since there is no valid STA
3264 * for these packets they will not be transmitted. Eventually
3265 * after the reassociation is successful, these packets will be
3266 * transmitted after registering STA with TL again. This ensures
3267 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003268 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303269 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
3270 pHddStaCtx->conn_info.staId[0]);
3271 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003272 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303273 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3274 FL("WLANTL_ClearSTAClient failed for staID %d."
3275 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
3276 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003277 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003278 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003279 }
3280 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003281 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 break;
3283#endif
3284
3285 case eCSR_ROAM_SHOULD_ROAM:
3286 // Dont need to do anything
3287 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 struct net_device *dev = pAdapter->dev;
3289 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3290 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303291 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003292 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003293#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003294 if (pHddStaCtx->ft_carrier_on == FALSE)
3295 {
3296#endif
3297 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003298#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 }
3300#endif
3301
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003302#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 //We should clear all sta register with TL, for now, only one.
3304 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
3305 if ( !VOS_IS_STATUS_SUCCESS(status ) )
3306 {
3307 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3308 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
3309 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003310 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003311 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003312#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003313 }
3314 break;
3315 case eCSR_ROAM_LOSTLINK:
3316 case eCSR_ROAM_DISASSOCIATED:
3317 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3319 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05303320 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003321 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3322 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07003323 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3324 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303325 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07003326 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08003327
3328 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
3329 pHddCtx->configuredMcastBcastFilter =
3330 pHddCtx->sus_res_mcastbcast_filter;
3331 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
3332 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303333
Amar Singhald53568e2013-09-26 11:03:45 -07003334 hddLog(VOS_TRACE_LEVEL_INFO,
3335 "offload: disassociation happening, restoring configuredMcastBcastFilter");
3336 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
3337 pHddCtx->configuredMcastBcastFilter);
3338 hddLog(VOS_TRACE_LEVEL_INFO,
3339 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07003340 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3341 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003342#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303343 /* Call to clear any MC Addr List filter applied after
3344 * successful connection.
3345 */
3346 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003347#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 }
3349 break;
3350 case eCSR_ROAM_IBSS_LEAVE:
3351 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3352 "****eCSR_ROAM_IBSS_LEAVE****");
3353 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3354 break;
3355 case eCSR_ROAM_ASSOCIATION_COMPLETION:
3356 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3357 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303358 // To Do - address probable memory leak with WEP encryption upon successful association
3359 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303361 //Clear saved connection information in HDD
3362 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003363 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303364 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003365
3366 break;
3367 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003368 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003369 pRoamInfo, roamId, roamStatus, roamResult );
3370 break;
3371 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07003372 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
3373 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003374 break;
3375
3376 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
3377 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003378 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003379
3380 case eCSR_ROAM_MIC_ERROR_IND:
3381 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3382 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05303383 case eCSR_ROAM_LOST_LINK_PARAMS_IND:
3384 {
3385 /*
3386 * The RSSI will be subtracted from 100 as FW is sending the RSSI by
3387 * adding the 100 value.
3388 */
3389 pAdapter->rssi_on_disconnect = pRoamInfo->u.pLostLinkParams->rssi - 100;
3390 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3391 "%s : Rssi on Disconnect : %d",
3392 __func__, pAdapter->rssi_on_disconnect);
3393 break;
3394 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003395 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003396 {
3397 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
3398
3399 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003400 (TRUE == pHddCtx->hdd_wlan_suspended) &&
3401 (eCSR_ROAM_RESULT_NONE == roamResult))
3402 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003403 /* Send DTIM period to the FW; only if the wlan is already
3404 in suspend. This is the case with roaming (reassoc),
3405 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
3406 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
3407 before the ENTER_BMPS_REQ ensures Listen Interval is
3408 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003409 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003410
3411 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003412 if due to unexpected scenario, if we are in BMPS,
3413 then trigger Exit and Enter BMPS to take DTIM period
3414 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003415 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
3416 {
3417 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
3418
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003419 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3420 iw_full_power_cbfn, pAdapter,
3421 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003422 }
3423 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303424
3425 if ((pHddCtx) &&
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303426 (FULL_POWER == pmcGetPmcState(pHddCtx->hHal)) &&
3427 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
3428 (eCSR_ROAM_RESULT_NONE == roamResult))
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303429 {
3430 hddLog( LOG1, FL("Device in full power."
3431 "Stop and start traffic timer for roaming"));
3432 pmcStopTrafficTimer(pHddCtx->hHal);
3433 if (pmcStartTrafficTimer(pHddCtx->hHal,
3434 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
3435 {
3436 hddLog(LOGP, FL("Cannot start traffic timer"));
3437 }
3438 }
3439
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003440 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303441 if (eCSR_ROAM_RESULT_NONE == roamResult)
3442 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003443 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 break;
3445#ifdef WLAN_FEATURE_VOWIFI_11R
3446 case eCSR_ROAM_FT_RESPONSE:
3447 hdd_SendFTEvent(pAdapter);
3448 break;
3449#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07003450#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003451 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003452 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07003453 {
3454 /* Notify the supplicant of a new candidate */
3455 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
3456 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003457 break;
3458#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003459
Yue Maef608272013-04-08 23:09:17 -07003460#ifdef FEATURE_WLAN_LFR_METRICS
3461 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
3462 /* This event is to notify pre-auth initiation */
3463 if (VOS_STATUS_SUCCESS !=
3464 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
3465 {
3466 halStatus = eHAL_STATUS_FAILURE;
3467 }
3468 break;
3469 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
3470 /* This event will notify pre-auth completion in case of success */
3471 if (VOS_STATUS_SUCCESS !=
3472 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3473 pRoamInfo, 1))
3474 {
3475 halStatus = eHAL_STATUS_FAILURE;
3476 }
3477 break;
3478 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
3479 /* This event will notify pre-auth completion in case of failure. */
3480 if (VOS_STATUS_SUCCESS !=
3481 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3482 pRoamInfo, 0))
3483 {
3484 halStatus = eHAL_STATUS_FAILURE;
3485 }
3486 break;
3487 case eCSR_ROAM_HANDOVER_SUCCESS:
3488 /* This event is to notify handover success.
3489 It will be only invoked on success */
3490 if (VOS_STATUS_SUCCESS !=
3491 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
3492 {
3493 halStatus = eHAL_STATUS_FAILURE;
3494 }
3495 break;
3496#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003497 case eCSR_ROAM_REMAIN_CHAN_READY:
3498 hdd_remainChanReadyHandler( pAdapter );
3499 break;
3500 case eCSR_ROAM_SEND_ACTION_CNF:
3501 hdd_sendActionCnf( pAdapter,
3502 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
3503 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003504#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08003505 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003506 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08003507 roamId, roamStatus, roamResult );
3508 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003509 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
3510 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
3511 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003512#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003513#ifdef WLAN_FEATURE_11W
3514 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
3515 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
3516 pRoamInfo->pbFrames,
3517 pRoamInfo->frameType);
3518 break;
3519#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003520#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003521 case eCSR_ROAM_TSM_IE_IND:
3522 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
3523 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
3524 break;
3525
3526 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
3527 {
3528 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
3529 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
3530 {
3531 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
3532 }
3533 break;
3534 }
3535
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003536 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003537 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003538 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003539 break;
3540 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003541
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003542 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003543 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003544 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003545 break;
3546 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003547#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05303548 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
3549 {
3550 pAdapter->maxRateFlags = roamResult;
3551 break;
3552 }
3553 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07003554 break;
3555 }
3556 return( halStatus );
3557}
Shailender Karmuchia734f332013-04-19 14:02:48 -07003558eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003559{
3560 eCsrAuthType auth_type;
3561 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003562 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003563 {
3564 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003565 } else
3566 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003567 {
3568 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003569 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003570#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003571 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003572 {
3573 // Check for 11r FT Authentication with PSK
3574 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003575 } else
3576 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003577 {
3578 // Check for 11R FT Authentication with 802.1X
3579 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003580 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003581#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003582#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003583 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003584 {
3585 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
3586 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003587#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07003588#ifdef WLAN_FEATURE_11W
3589 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
3590 {
3591 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3592 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303593 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
3594 {
3595 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3596 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003597#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003598 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3600 }
3601 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003602}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003603
Shailender Karmuchia734f332013-04-19 14:02:48 -07003604eCsrAuthType
3605hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003606{
3607 eCsrAuthType auth_type;
3608 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003609 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003610 {
3611 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003612 } else
3613 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 {
3615 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003616 } else
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 , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003619 {
3620 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003621 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003622#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003623 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003624 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3625 }
3626 hddLog(LOG1, FL("auth_type: %d"), auth_type);
3627 return auth_type;
3628}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003629
Shailender Karmuchia734f332013-04-19 14:02:48 -07003630eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003631hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003632{
3633 eCsrEncryptionType cipher_type;
3634 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003635 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003636 {
3637 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003638 }
3639 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003640 {
3641 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003642 }
3643 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003644 {
3645 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003646 }
3647 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003648 {
3649 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003650 }
3651 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
3652 {
3653 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3654 }
3655 else
3656 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003657 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3658 }
3659 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3660 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003661}
Jeff Johnson295189b2012-06-20 16:38:30 -07003662/* To find if the MAC address is NULL */
3663static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3664{
3665 int i;
3666 for (i = 0; i < length; i++)
3667 {
3668 if (0x00 != (macAddr[i]))
3669 {
3670 return FALSE;
3671 }
3672 }
3673 return TRUE;
3674} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003675
Shailender Karmuchia734f332013-04-19 14:02:48 -07003676eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003677hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003678{
3679 eCsrEncryptionType cipher_type;
3680 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003681 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003682 {
3683 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003684 } else
3685 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 {
3687 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003688 } else
3689 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003690 {
3691 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003692 } else
3693 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 {
3695 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003696 } else
3697 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003698 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003699 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3700 } else
3701 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003702 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3703 }
3704 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3705 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003706}
Jeff Johnson295189b2012-06-20 16:38:30 -07003707
Shailender Karmuchia734f332013-04-19 14:02:48 -07003708static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3709 struct ether_addr *pBssid,
3710 eCsrEncryptionType *pEncryptType,
3711 eCsrEncryptionType *mcEncryptType,
3712 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003713#ifdef WLAN_FEATURE_11W
3714 u_int8_t *pMfpRequired,
3715 u_int8_t *pMfpCapable,
3716#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003717 u_int16_t gen_ie_len,
3718 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003719{
3720 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003721 eHalStatus result;
3722 tDot11fIERSN dot11RSNIE;
3723 tDot11fIEWPA dot11WPAIE;
3724 tANI_U32 i;
3725 tANI_U8 *pRsnIe;
3726 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003728 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003729
3730 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3731 flag to 0 */
3732 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3733 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3734
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003736 if ( gen_ie[0] == DOT11F_EID_RSN)
3737 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003738 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003739 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003740 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3741 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303742 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3743 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 return -EINVAL;
3745 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003746 // Skip past the EID byte and length byte
3747 pRsnIe = gen_ie + 2;
3748 RSNIeLen = gen_ie_len - 2;
3749 // Unpack the RSN IE
3750 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3751 pRsnIe,
3752 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003754 // Copy out the encryption and authentication types
3755 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003756 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003757 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003758 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003759 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 but probably I suspect we can do something different*/
3761 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003762 // Just translate the FIRST one
3763 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3764 //dot11RSNIE.pwise_cipher_suite_count
3765 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3766 //dot11RSNIE.gp_cipher_suite_count
3767 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003768#ifdef WLAN_FEATURE_11W
3769 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3770 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3771#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003773 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003774 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003775 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003776 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303777 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003778 break;
3779 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003780 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303782 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003783 break;
3784 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003785 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003786 // For right now, I assume setASSOCIATE() has passed in the bssid.
3787 vos_mem_copy(PMKIDCache[i].BSSID,
3788 pBssid, ETHER_ADDR_LEN);
3789 vos_mem_copy(PMKIDCache[i].PMKID,
3790 dot11RSNIE.pmkid[i],
3791 CSR_RSN_PMKID_SIZE);
3792 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003793
3794 if (updatePMKCache)
3795 {
3796 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003797 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003798 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003799 // Finally set the PMKSA ID Cache in CSR
3800 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3801 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05303802 dot11RSNIE.pmkid_count,
3803 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07003804 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 }
3806 else if (gen_ie[0] == DOT11F_EID_WPA)
3807 {
3808 // Validity checks
3809 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3810 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3811 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303812 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3813 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 return -EINVAL;
3815 }
3816 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003817 pRsnIe = gen_ie + 2 + 4;
3818 RSNIeLen = gen_ie_len - (2 + 4);
3819 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003820 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3821 pRsnIe,
3822 RSNIeLen,
3823 &dot11WPAIE);
3824 // Copy out the encryption and authentication types
3825 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003826 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003828 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003829 //dot11WPAIE.auth_suite_count
3830 // Just translate the FIRST one
3831 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3832 //dot11WPAIE.unicast_cipher_count
3833 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3834 //dot11WPAIE.unicast_cipher_count
3835 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3836 }
3837 else
3838 {
3839 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003840 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 }
3842 return 0;
3843}
3844int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3845{
3846 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3847 v_U32_t status = 0;
3848 eCsrEncryptionType RSNEncryptType;
3849 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003850#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303851 u_int8_t RSNMfpRequired = 0;
3852 u_int8_t RSNMfpCapable = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07003853#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003854 struct ether_addr bSsid; // MAC address of assoc peer
3855 // MAC address of assoc peer
3856 // But, this routine is only called when we are NOT associated.
3857 vos_mem_copy(bSsid.ether_addr_octet,
3858 pWextState->roamProfile.BSSIDs.bssid,
3859 sizeof(bSsid.ether_addr_octet));
3860 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3861 {
3862 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003863 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 else
3865 {
3866 return 0;
3867 }
3868 // The actual processing may eventually be more extensive than this.
3869 // Right now, just consume any PMKIDs that are sent in by the app.
3870 status = hdd_ProcessGENIE(pAdapter,
3871 &bSsid, // MAC address of assoc peer
3872 &RSNEncryptType,
3873 &mcRSNEncryptType,
3874 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003875#ifdef WLAN_FEATURE_11W
3876 &RSNMfpRequired,
3877 &RSNMfpCapable,
3878#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003879 pWextState->WPARSNIE[1]+2,
3880 pWextState->WPARSNIE);
3881 if (status == 0)
3882 {
3883 // Now copy over all the security attributes you have parsed out
3884 pWextState->roamProfile.EncryptionType.numEntries = 1;
3885 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003886
Jeff Johnson295189b2012-06-20 16:38:30 -07003887 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3888 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003889
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003890 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3891 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3892 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3893 {
3894 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3895 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3896 either AES/TKIP based on group cipher configuration
3897 mentioned in the wpa_supplicant.conf.*/
3898
3899 /*Set the unicast cipher same as multicast cipher*/
3900 pWextState->roamProfile.EncryptionType.encryptionType[0]
3901 = mcRSNEncryptType;
3902 }
3903
Chet Lanctot186b5732013-03-18 10:26:30 -07003904#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303905 hddLog( LOG1, FL("RSNMfpRequired = %d, RSNMfpCapable = %d"),
3906 RSNMfpRequired, RSNMfpCapable);
Chet Lanctot186b5732013-03-18 10:26:30 -07003907 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3908 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3909#endif
Abhishek Singh4f6406d2015-10-07 13:43:52 +05303910 hddLog( LOG1,
3911 FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d"),
3912 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 }
3914 return 0;
3915}
3916int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3917{
3918 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3919 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3920 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3921 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003922
Jeff Johnson295189b2012-06-20 16:38:30 -07003923 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003924 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003925
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 switch( pHddStaCtx->conn_info.authType)
3927 {
3928 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003929#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 case eCSR_AUTH_TYPE_CCKM_WPA:
3931 case eCSR_AUTH_TYPE_CCKM_RSN:
3932#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003933 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3934
Jeff Johnson295189b2012-06-20 16:38:30 -07003935 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003936 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003937 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003938
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003939#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003940 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3941 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3942 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003943 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003944 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3945 } else
3946 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003947 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003948 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003949 } else
3950#endif
3951 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3952 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003953 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3954 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003955 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3956 == IW_AUTH_KEY_MGMT_PSK) {
3957 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003958 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003960 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003961 }
3962 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003963#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003964 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3965 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3966 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003967 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003968 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003970 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003971 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003972 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 } else
3974#endif
3975
3976#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003977 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3978 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003980 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003981 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003982 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3984 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003985 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003986 } else
3987#endif
3988
Chet Lanctot186b5732013-03-18 10:26:30 -07003989#ifdef WLAN_FEATURE_11W
3990 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3991 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3992 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303993 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
3994 pRoamProfile->AuthType.authType[0] =
3995 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3996 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003997#endif
3998
Shailender Karmuchia734f332013-04-19 14:02:48 -07003999 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004001 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
4002 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4004 == IW_AUTH_KEY_MGMT_PSK) {
4005 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004006 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004007 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004008 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004009 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004010 break;
4011
Jeff Johnson295189b2012-06-20 16:38:30 -07004012 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004013
4014 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004015 break;
4016 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004017
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004018#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08004019 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004020#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
4022 break;
4023 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004024
Jeff Johnson295189b2012-06-20 16:38:30 -07004025 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004026 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004027
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 EXIT();
4029 return 0;
4030}
4031
4032/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004033
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304034 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07004036 to the CSR roam profile.
4037
Jeff Johnson295189b2012-06-20 16:38:30 -07004038 \param - dev - Pointer to the net device.
4039 - info - Pointer to the iw_request_info.
4040 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004041 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004042 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004043
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 --------------------------------------------------------------------------*/
4045
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304046int __iw_set_essid(struct net_device *dev,
4047 struct iw_request_info *info,
4048 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004049{
4050 v_U32_t status = 0;
4051 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304052 hdd_adapter_t *pAdapter;
4053 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 v_U32_t roamId;
4055 tCsrRoamProfile *pRoamProfile;
4056 eMib_dot11DesiredBssType connectedBssType;
4057 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304058 tHalHandle hHal;
4059 hdd_station_ctx_t *pHddStaCtx;
4060 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004061
Jeff Johnson295189b2012-06-20 16:38:30 -07004062 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304063 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4064 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004065 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304066 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304067 "%s: Adapter is NULL",__func__);
4068 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 }
4070
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304071 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4072 ret = wlan_hdd_validate_context(pHddCtx);
4073 if (0 != ret)
4074 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304075 return ret;
4076 }
4077
4078 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4079 if (NULL == hHal)
4080 {
4081 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4082 "%s: Hal Context is NULL",__func__);
4083 return -EINVAL;
4084 }
4085 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4086 if (NULL == pHddStaCtx)
4087 {
4088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4089 "%s: STA Context is NULL",__func__);
4090 return -EINVAL;
4091 }
4092 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4093 if (NULL == pWextState)
4094 {
4095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4096 "%s: pWextState is NULL",__func__);
4097 return -EINVAL;
4098 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004099 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
4100 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
4101 return -EBUSY;
4102 }
4103 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
4104 return -EINVAL;
4105 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004106 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004107 {
4108 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
4109 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
4110 {
4111 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004112 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07004113 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4114 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
4115
4116 if(VOS_STATUS_SUCCESS == vosStatus)
4117 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
4118 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4119 }
4120 }
4121 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004122 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004123 {
4124 return -EINVAL;
4125 }
4126 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004127 /** when cfg80211 defined, wpa_supplicant wext driver uses
4128 zero-length, null-string ssid for force disconnection.
4129 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 driver MUST return success */
4131 if ( 0 == wrqu->essid.length ) {
4132 return 0;
4133 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004134
4135 status = hdd_wmm_get_uapsd_mask(pAdapter,
4136 &pWextState->roamProfile.uapsd_mask);
4137 if (VOS_STATUS_SUCCESS != status)
4138 {
4139 pWextState->roamProfile.uapsd_mask = 0;
4140 }
4141 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004142
Jeff Johnson295189b2012-06-20 16:38:30 -07004143 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004144
4145 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004146 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
4147 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
4148 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004149
Jeff Johnson295189b2012-06-20 16:38:30 -07004150 //set gen ie
4151 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
4152
4153 //set auth
4154 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
4155 }
4156#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004157 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004158 if (pAdapter->wapi_info.nWapiMode)
4159 {
4160 switch (pAdapter->wapi_info.wapiAuthMode)
4161 {
4162 case WAPI_AUTH_MODE_PSK:
4163 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004164 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004165 pRoamProfile->AuthType.numEntries = 1;
4166 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4167 break;
4168 }
4169 case WAPI_AUTH_MODE_CERT:
4170 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004171 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004172 pRoamProfile->AuthType.numEntries = 1;
4173 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4174 break;
4175 }
4176 } // End of switch
4177 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
4178 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
4179 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004180 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004181 pRoamProfile->EncryptionType.numEntries = 1;
4182 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4183 pRoamProfile->mcEncryptionType.numEntries = 1;
4184 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4185 }
4186 }
4187#endif /* FEATURE_WLAN_WAPI */
4188 /* if previous genIE is not NULL, update AssocIE */
4189 if (0 != pWextState->genIE.length)
4190 {
4191 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
4192 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
4193 pWextState->genIE.length);
4194 pWextState->assocAddIE.length = pWextState->genIE.length;
4195 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
4196 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
4197
4198 /* clear previous genIE after use it */
4199 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
4200 }
4201
4202 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
4203 pWextState->roamProfile.bWPSAssociation = FALSE;
4204
4205 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
4206 pWextState->roamProfile.nAddIEAssocLength))
4207 pWextState->roamProfile.bWPSAssociation = TRUE;
4208
4209
4210 // Disable auto BMPS entry by PMC until DHCP is done
4211 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
4212
Shailender Karmuchia734f332013-04-19 14:02:48 -07004213 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004214 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004215
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004216 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
4217 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004218 hdd_select_cbmode(pAdapter,
4219 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
4220 }
Agarwal Ashish40f9b872015-09-01 16:17:35 +05304221 /*
4222 * Change conn_state to connecting before sme_RoamConnect(),
4223 * because sme_RoamConnect() has a direct path to call
4224 * hdd_smeRoamCallback(), which will change the conn_state
4225 * If direct path, conn_state will be accordingly changed
4226 * to NotConnected or Associated by either
4227 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
4228 * in sme_RoamCallback()
4229 * if sme_RomConnect is to be queued,
4230 * Connecting state will remain until it is completed.
4231 *
4232 * If connection state is not changed,
4233 * connection state will remain in eConnectionState_NotConnected state.
4234 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
4235 * if conn state is eConnectionState_NotConnected.
4236 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
4237 * informed of connect result indication which is an issue.
4238 */
4239 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
4240 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
4241 {
4242 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4243 FL("Set HDD connState to eConnectionState_Connecting"));
4244 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
4245 eConnectionState_Connecting);
4246 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004247 status = sme_RoamConnect( hHal,pAdapter->sessionId,
4248 &(pWextState->roamProfile), &roamId);
Agarwal Ashish40f9b872015-09-01 16:17:35 +05304249
4250 if ((eHAL_STATUS_SUCCESS != status) &&
4251 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
4252 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
4253 {
4254 hddLog(VOS_TRACE_LEVEL_ERROR,
4255 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
4256 pAdapter->sessionId, status);
4257 /* change back to NotAssociated */
4258 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
4259 eConnectionState_NotConnected);
4260 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004261 pRoamProfile->ChannelInfo.ChannelList = NULL;
4262 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004263
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004264 EXIT();
4265 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004266}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004267
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304268int iw_set_essid(struct net_device *dev,
4269 struct iw_request_info *info,
4270 union iwreq_data *wrqu, char *extra)
4271{
4272 int ret;
4273
4274 vos_ssr_protect(__func__);
4275 ret = __iw_set_essid(dev, info, wrqu, extra);
4276 vos_ssr_unprotect(__func__);
4277
4278 return ret;
4279}
4280
Jeff Johnson295189b2012-06-20 16:38:30 -07004281/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004282
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304283 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004285
Jeff Johnson295189b2012-06-20 16:38:30 -07004286 \param - dev - Pointer to the net device.
4287 - info - Pointer to the iw_request_info.
4288 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004289 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004291
Jeff Johnson295189b2012-06-20 16:38:30 -07004292 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304293int __iw_get_essid(struct net_device *dev,
4294 struct iw_request_info *info,
4295 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004296{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304297 hdd_adapter_t *pAdapter;
4298 hdd_context_t *pHddCtx;
4299 hdd_wext_state_t *wextBuf;
4300 hdd_station_ctx_t *pHddStaCtx;
4301 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304302
Jeff Johnson295189b2012-06-20 16:38:30 -07004303 ENTER();
4304
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304305 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4306 if (NULL == pAdapter)
4307 {
4308 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4309 "%s: Adapter is NULL",__func__);
4310 return -EINVAL;
4311 }
4312
4313 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4314 ret = wlan_hdd_validate_context(pHddCtx);
4315 if (0 != ret)
4316 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304317 return ret;
4318 }
4319
4320 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4321 if (NULL == pHddStaCtx)
4322 {
4323 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4324 "%s: STA Context is NULL",__func__);
4325 return -EINVAL;
4326 }
4327
4328 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4329 if (NULL == wextBuf)
4330 {
4331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4332 "%s: wextBuf is NULL",__func__);
4333 return -EINVAL;
4334 }
4335
Jeff Johnson295189b2012-06-20 16:38:30 -07004336 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
4337 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
4338 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
4339 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
4340 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
4341 {
4342 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
4343 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
4344 dwrq->flags = 1;
4345 } else {
4346 memset(extra, 0, dwrq->length);
4347 dwrq->length = 0;
4348 dwrq->flags = 0;
4349 }
4350 EXIT();
4351 return 0;
4352}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304353
4354int iw_get_essid(struct net_device *dev,
4355 struct iw_request_info *info,
4356 struct iw_point *dwrq, char *extra)
4357{
4358 int ret;
4359
4360 vos_ssr_protect(__func__);
4361 ret = __iw_get_essid(dev, info, dwrq, extra);
4362 vos_ssr_unprotect(__func__);
4363
4364 return ret;
4365}
Jeff Johnson295189b2012-06-20 16:38:30 -07004366/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004367
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304368 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004369 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004370
Jeff Johnson295189b2012-06-20 16:38:30 -07004371 \param - dev - Pointer to the net device.
4372 - info - Pointer to the iw_request_info.
4373 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004374 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004375 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004376
Jeff Johnson295189b2012-06-20 16:38:30 -07004377 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304378int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
4379 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004380{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304381 hdd_adapter_t *pAdapter;
4382 hdd_context_t *pHddCtx;
4383 hdd_wext_state_t *pWextState;
4384 hdd_station_ctx_t *pHddStaCtx;
4385 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004386 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07004387 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304388 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004389
Jeff Johnson295189b2012-06-20 16:38:30 -07004390 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004391
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304392 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4393 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004394 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304395 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4396 "%s: Adapter is NULL",__func__);
4397 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004398 }
4399
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304400 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4401 ret = wlan_hdd_validate_context(pHddCtx);
4402 if (0 != ret)
4403 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304404 return ret;
4405 }
4406
4407 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4408 if (NULL == pHddStaCtx)
4409 {
4410 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4411 "%s: STA Context is NULL",__func__);
4412 return -EINVAL;
4413 }
4414
4415 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4416 if (NULL == pWextState)
4417 {
4418 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4419 "%s: pWextState is NULL",__func__);
4420 return -EINVAL;
4421 }
4422
4423 pRoamProfile = &pWextState->roamProfile;
4424
Jeff Johnson295189b2012-06-20 16:38:30 -07004425 switch(wrqu->param.flags & IW_AUTH_INDEX)
4426 {
4427 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004428
Jeff Johnson295189b2012-06-20 16:38:30 -07004429 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004430
Jeff Johnson295189b2012-06-20 16:38:30 -07004431 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004432
Jeff Johnson295189b2012-06-20 16:38:30 -07004433 case IW_AUTH_CIPHER_PAIRWISE:
4434 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004435 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004436 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004437 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4439 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004441 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
4442 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004443 }
4444
Jeff Johnson295189b2012-06-20 16:38:30 -07004445 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004446
4447 if( (IW_AUTH_KEY_MGMT_802_1X
4448 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004449 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
4450 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004451 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07004452 else
4453 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004454 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4455 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004456 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004457
4458 if( ( IW_AUTH_KEY_MGMT_802_1X
4459 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004460 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4461 /*Dynamic WEP key*/
4462 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4463 else
4464 /*Static WEP key*/
4465 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004466
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 }
4468 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004469
Jeff Johnson295189b2012-06-20 16:38:30 -07004470 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004471 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004472 return -EINVAL;
4473 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004474
Jeff Johnson295189b2012-06-20 16:38:30 -07004475 pRoamProfile->EncryptionType.numEntries = 1;
4476 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004477 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004478 break;
4479 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004480 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004481 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
4482 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4483 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004484
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4486 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
4487 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004488
4489 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004490 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
4491 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004492
Jeff Johnson295189b2012-06-20 16:38:30 -07004493 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004494
4495 if( ( IW_AUTH_KEY_MGMT_802_1X
4496 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
4497 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4498
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004500
4501 else
4502 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004503 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004504
4505 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
4506 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004507 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004508 if( ( IW_AUTH_KEY_MGMT_802_1X
4509 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07004510 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4511 {
4512 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4513 }
4514 else
4515 {
4516 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4517 }
4518 }
4519 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004520
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004522 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004523 return -EINVAL;
4524 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004525
Jeff Johnson295189b2012-06-20 16:38:30 -07004526 pRoamProfile->mcEncryptionType.numEntries = 1;
4527 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
4528 }
4529 break;
4530
4531 case IW_AUTH_80211_AUTH_ALG:
4532 {
4533 /*Save the auth algo here and set auth type to SME Roam profile
4534 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004535 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07004536 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004537
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
4539 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
4540
4541 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
4542 /*Not supported*/
4543 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4544 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
4545 }
4546 break;
4547
4548 case IW_AUTH_KEY_MGMT:
4549 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004550#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004551#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
4552 /*Check for CCKM AKM type */
4553 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004554 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
4555 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004556 /* Set the CCKM bit in authKeyMgmt */
4557 /* Right now, this breaks all ref to authKeyMgmt because our
4558 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07004559 */
4560 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
4561 /*Set the key management to 802.1X*/
4562 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004563 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4565 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
4566 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
4567 /*Save the key management*/
4568 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
4569 //pWextState->authKeyMgmt = wrqu->param.value;
4570 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4571 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4572 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
4573 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
4574 /*Save the key management anyway*/
4575 pWextState->authKeyMgmt = wrqu->param.value;
4576 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
4577 /*Save the key management*/
4578 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
4579 //pWextState->authKeyMgmt = wrqu->param.value;
4580 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4581 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4582 }
4583#else
4584 /*Save the key management*/
4585 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004586#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004587 }
4588 break;
4589
4590 case IW_AUTH_TKIP_COUNTERMEASURES:
4591 {
4592 if(wrqu->param.value) {
4593 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4594 "Counter Measure started %d", wrqu->param.value);
4595 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
4596 }
4597 else {
4598 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4599 "Counter Measure stopped=%d", wrqu->param.value);
4600 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
4601 }
4602 }
4603 break;
4604 case IW_AUTH_DROP_UNENCRYPTED:
4605 case IW_AUTH_WPA_ENABLED:
4606 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
4607 case IW_AUTH_ROAMING_CONTROL:
4608 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004609
Jeff Johnson295189b2012-06-20 16:38:30 -07004610 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004611
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004612 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004613 wrqu->param.flags & IW_AUTH_INDEX);
4614 break;
4615 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004616
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 EXIT();
4618 return 0;
4619}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304620
4621int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
4622 union iwreq_data *wrqu, char *extra)
4623{
4624 int ret;
4625
4626 vos_ssr_protect(__func__);
4627 ret = __iw_set_auth(dev, info, wrqu, extra);
4628 vos_ssr_unprotect(__func__);
4629
4630 return ret;
4631}
4632
Jeff Johnson295189b2012-06-20 16:38:30 -07004633/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004634
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304635 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004636 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004637
Jeff Johnson295189b2012-06-20 16:38:30 -07004638 \param - dev - Pointer to the net device.
4639 - info - Pointer to the iw_request_info.
4640 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004641 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004642 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004643
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304645int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4646 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004647{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304648 hdd_adapter_t* pAdapter;
4649 hdd_wext_state_t *pWextState;
4650 tCsrRoamProfile *pRoamProfile;
4651 hdd_context_t *pHddCtx;
4652 int ret = 0;
4653
Jeff Johnson295189b2012-06-20 16:38:30 -07004654 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004655
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304656 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4657 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004658 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304659 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4660 "%s: Adapter is NULL",__func__);
4661 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004662 }
4663
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304664 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4665 ret = wlan_hdd_validate_context(pHddCtx);
4666 if (0 != ret)
4667 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304668 return ret;
4669 }
4670
4671 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4672 if (NULL == pWextState)
4673 {
4674 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4675 "%s: pWextState is NULL",__func__);
4676 return -EINVAL;
4677 }
4678 pRoamProfile = &pWextState->roamProfile;
4679
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 switch(pRoamProfile->negotiatedAuthType)
4681 {
4682 case eCSR_AUTH_TYPE_WPA_NONE:
4683 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4684 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
4685 break;
4686 case eCSR_AUTH_TYPE_WPA:
4687 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4688 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
4689 break;
4690#ifdef WLAN_FEATURE_VOWIFI_11R
4691 case eCSR_AUTH_TYPE_FT_RSN:
4692#endif
4693 case eCSR_AUTH_TYPE_RSN:
4694 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4695 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
4696 break;
4697 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4698 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4699 break;
4700 case eCSR_AUTH_TYPE_SHARED_KEY:
4701 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
4702 break;
4703 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004704 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004705 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4706 break;
4707 case eCSR_AUTH_TYPE_AUTOSWITCH:
4708 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4709 break;
4710 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304711 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004712 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4713 return -EIO;
4714#ifdef WLAN_FEATURE_VOWIFI_11R
4715 case eCSR_AUTH_TYPE_FT_RSN_PSK:
4716#endif
4717 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07004718#ifdef WLAN_FEATURE_11W
4719 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05304720 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07004721#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05304722 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004723 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4724 return -EIO;
4725 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304726 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004727 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4728 return -EIO;
4729 }
4730 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
4731 {
4732 switch(pRoamProfile->negotiatedUCEncryptionType)
4733 {
4734 case eCSR_ENCRYPT_TYPE_NONE:
4735 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4736 break;
4737 case eCSR_ENCRYPT_TYPE_WEP40:
4738 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4739 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4740 break;
4741 case eCSR_ENCRYPT_TYPE_TKIP:
4742 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4743 break;
4744 case eCSR_ENCRYPT_TYPE_WEP104:
4745 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4746 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4747 break;
4748 case eCSR_ENCRYPT_TYPE_AES:
4749 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4750 break;
4751 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304752 hddLog(LOG1, "%s called with unknown auth type %d ",
4753 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004754 return -EIO;
4755 }
4756 }
4757
Shailender Karmuchia734f332013-04-19 14:02:48 -07004758 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07004759 {
4760 switch(pRoamProfile->negotiatedMCEncryptionType)
4761 {
4762 case eCSR_ENCRYPT_TYPE_NONE:
4763 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4764 break;
4765 case eCSR_ENCRYPT_TYPE_WEP40:
4766 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4767 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4768 break;
4769 case eCSR_ENCRYPT_TYPE_TKIP:
4770 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4771 break;
4772 case eCSR_ENCRYPT_TYPE_WEP104:
4773 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4774 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4775 break;
4776 case eCSR_ENCRYPT_TYPE_AES:
4777 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4778 break;
4779 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304780 hddLog(LOG1, "%s called with unknown auth type %d ",
4781 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004782 return -EIO;
4783 }
4784 }
4785
4786 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004787 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004788 EXIT();
4789 return 0;
4790}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304791
4792int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4793 union iwreq_data *wrqu,char *extra)
4794{
4795 int ret;
4796
4797 vos_ssr_protect(__func__);
4798 ret = __iw_get_auth(dev, info, wrqu, extra);
4799 vos_ssr_unprotect(__func__);
4800
4801 return ret;
4802}
4803
Jeff Johnson295189b2012-06-20 16:38:30 -07004804/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004805
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304806 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07004807 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07004808 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004809
Jeff Johnson295189b2012-06-20 16:38:30 -07004810 \param - dev - Pointer to the net device.
4811 - info - Pointer to the iw_request_info.
4812 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004813 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004814 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004815
Jeff Johnson295189b2012-06-20 16:38:30 -07004816 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304817int __iw_set_ap_address(struct net_device *dev,
4818 struct iw_request_info *info,
4819 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004820{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304821 hdd_station_ctx_t *pHddStaCtx;
4822 hdd_adapter_t *pAdapter;
4823 hdd_context_t *pHddCtx;
4824 v_U8_t *pMacAddress = NULL;
4825 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304826
Jeff Johnson295189b2012-06-20 16:38:30 -07004827 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304828
4829 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4830 if (NULL == pAdapter)
4831 {
4832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4833 "%s: Adapter is NULL", __func__);
4834 return -EINVAL;
4835 }
4836 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4837 ret = wlan_hdd_validate_context(pHddCtx);
4838 if (0 != ret)
4839 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304840 return ret;
4841 }
4842 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4843 if (NULL == pHddStaCtx)
4844 {
4845 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4846 "%s: pHddStaCtx is NULL", __func__);
4847 return -EINVAL;
4848 }
4849
Jeff Johnson295189b2012-06-20 16:38:30 -07004850 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08004851 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
4852 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07004853 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07004854
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304855 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004856 return 0;
4857}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304858
4859int iw_set_ap_address(struct net_device *dev,
4860 struct iw_request_info *info,
4861 union iwreq_data *wrqu, char *extra)
4862{
4863 int ret;
4864
4865 vos_ssr_protect(__func__);
4866 ret = __iw_set_ap_address(dev, info, wrqu, extra);
4867 vos_ssr_unprotect(__func__);
4868
4869 return ret;
4870}
4871
Jeff Johnson295189b2012-06-20 16:38:30 -07004872/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004873
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304874 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004875 This function returns the BSSID to the wpa_supplicant
4876 \param - dev - Pointer to the net device.
4877 - info - Pointer to the iw_request_info.
4878 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004879 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004880 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004881
Jeff Johnson295189b2012-06-20 16:38:30 -07004882 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304883int __iw_get_ap_address(struct net_device *dev,
4884 struct iw_request_info *info,
4885 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004886{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304887 hdd_station_ctx_t *pHddStaCtx;
4888 hdd_adapter_t *pAdapter;
4889 hdd_context_t *pHddCtx;
4890 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304891
Jeff Johnson295189b2012-06-20 16:38:30 -07004892 ENTER();
4893
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304894 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4895 if (NULL == pAdapter)
4896 {
4897 hddLog(VOS_TRACE_LEVEL_ERROR,
4898 "%s: Adapter is NULL", __func__);
4899 return -EINVAL;
4900 }
4901 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4902 ret = wlan_hdd_validate_context(pHddCtx);
4903 if (0 != ret)
4904 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304905 return ret;
4906 }
4907 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4908 if (NULL == pHddStaCtx)
4909 {
4910 hddLog(VOS_TRACE_LEVEL_ERROR,
4911 "%s: pHddStaCtx is NULL", __func__);
4912 return -EINVAL;
4913 }
4914
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
4916 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
4917 {
Jeff Johnson4416a782013-03-25 14:17:50 -07004918 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07004919 }
4920 else
4921 {
4922 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4923 }
4924 EXIT();
4925 return 0;
4926}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004927
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304928int iw_get_ap_address(struct net_device *dev,
4929 struct iw_request_info *info,
4930 union iwreq_data *wrqu, char *extra)
4931{
4932 int ret;
4933
4934 vos_ssr_protect(__func__);
4935 ret = __iw_get_ap_address(dev, info, wrqu, extra);
4936 vos_ssr_unprotect(__func__);
4937
4938 return ret;
4939}
4940
Chet Lanctot186b5732013-03-18 10:26:30 -07004941#ifdef WLAN_FEATURE_11W
4942/**---------------------------------------------------------------------------
4943
4944 \brief hdd_indicateUnprotMgmtFrame -
4945 This function forwards the unprotected management frame to the supplicant
4946 \param - pAdapter - Pointer to HDD adapter
4947 - nFrameLength - Length of the unprotected frame being passed
4948 - pbFrames - Pointer to the frame buffer
4949 - frameType - 802.11 frame type
4950 \return - nothing
4951
4952 --------------------------------------------------------------------------*/
4953void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
4954 tANI_U32 nFrameLength,
4955 tANI_U8* pbFrames,
4956 tANI_U8 frameType )
4957{
4958 tANI_U8 type = 0;
4959 tANI_U8 subType = 0;
4960
4961 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
4962 __func__, frameType, nFrameLength);
4963
4964 /* Sanity Checks */
4965 if (NULL == pAdapter)
4966 {
4967 hddLog( LOGE, FL("pAdapter is NULL"));
4968 return;
4969 }
4970
4971 if (NULL == pAdapter->dev)
4972 {
4973 hddLog( LOGE, FL("pAdapter->dev is NULL"));
4974 return;
4975 }
4976
4977 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
4978 {
4979 hddLog( LOGE, FL("pAdapter has invalid magic"));
4980 return;
4981 }
4982
4983 if( !nFrameLength )
4984 {
4985 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
4986 return;
4987 }
4988
4989 if (NULL == pbFrames) {
4990 hddLog( LOGE, FL("pbFrames is NULL"));
4991 return;
4992 }
4993
4994 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4995 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4996
4997 /* Get pAdapter from Destination mac address of the frame */
4998 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
4999 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305000#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5001 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5002#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005003 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305004#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005005 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
5006 }
5007 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
5008 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305009#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5010 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5011#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005012 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305013#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005014 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
5015 }
5016 else
5017 {
5018 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
5019 return;
5020 }
5021}
5022#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005023
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005024#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005025void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
5026 tANI_U8 state,
5027 tANI_U16 measInterval )
5028{
5029 union iwreq_data wrqu;
5030 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005031 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005032
5033 if (NULL == pAdapter)
5034 return;
5035
5036 // create the event
5037 memset(&wrqu, '\0', sizeof(wrqu));
5038 memset(buf, '\0', sizeof(buf));
5039
5040 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
5041 tid, state, measInterval);
5042
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005043 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005044
5045 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005046 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005047 // send the event
5048 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5049}
5050
5051void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
5052{
5053 union iwreq_data wrqu;
5054 char buf[IW_CUSTOM_MAX + 1];
5055 char *pos = buf;
5056 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5057
5058 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5059 return;
5060
5061 // create the event
5062 memset(&wrqu, '\0', sizeof(wrqu));
5063 memset(buf, '\0', sizeof(buf));
5064
5065 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305066 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
5067 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
5068 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
5069 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005070
5071 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
5072 pos += nBytes;
5073 freeBytes -= nBytes;
5074
5075 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
5076 pos += WNI_CFG_BSSID_LEN;
5077 freeBytes -= WNI_CFG_BSSID_LEN;
5078
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005079 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
5080 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005081
5082 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005083 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005084
5085 // send the event
5086 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5087}
5088
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005089void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005090{
5091 union iwreq_data wrqu;
5092 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005093 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005094
5095 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5096 return;
5097
5098 // create the event
5099 memset(&wrqu, '\0', sizeof(wrqu));
5100 memset(buf, '\0', sizeof(buf));
5101
5102 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
5103
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005104 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005105
5106 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005107 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005108
5109 // send the event
5110 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5111}
5112
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005113void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
5114 const tANI_U16 measurementToken,
5115 const tANI_BOOLEAN flag,
5116 const tANI_U8 numBss)
5117{
5118 union iwreq_data wrqu;
5119 char buf[IW_CUSTOM_MAX];
5120 char *pos = buf;
5121 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5122
5123 memset(&wrqu, '\0', sizeof(wrqu));
5124 memset(buf, '\0', sizeof(buf));
5125
5126 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
5127 numBss);
5128
5129 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
5130 flag, numBss);
5131
5132 wrqu.data.pointer = buf;
5133 wrqu.data.length = nBytes;
5134 // send the event
5135 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5136}
5137
5138
5139static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005140 const tCsrRoamInfo *pRoamInfo)
5141{
5142 union iwreq_data wrqu;
5143 char buf[IW_CUSTOM_MAX + 1];
5144 char *pos = buf;
5145 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5146 tANI_U8 i = 0, len = 0;
5147 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
5148 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005149 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
5150 tANI_U8 ieLenByte = 1;
5151 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
5152#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005153
5154 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5155 return;
5156
5157 /* Custom event can pass maximum of 256 bytes of data,
5158 based on the IE len we need to identify how many BSS info can
5159 be filled in to custom event data */
5160 /*
5161 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
5162 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
5163 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
5164 */
5165
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005166 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005167 {
5168 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
5169 /* If the measurement is none and no scan results found,
5170 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005171 hdd_indicateEseBcnReportNoResults(pAdapter,
5172 pRoamInfo->pEseBcnReportRsp->measurementToken,
5173 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005174 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005175 }
5176 else
5177 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005178 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005179 {
5180 memset(&wrqu, '\0', sizeof(wrqu));
5181 memset(buf, '\0', sizeof(buf));
5182 tot_bcn_ieLen = 0;
5183 sendBss = 0;
5184 pos = buf;
5185 freeBytes = IW_CUSTOM_MAX;
5186
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005187 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005188 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005189 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
5190 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005191 {
5192 break;
5193 }
5194 tot_bcn_ieLen += len;
5195 sendBss++;
5196 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
5197 "IeLength(%d) Length of Ie(%d) totLen(%d)",
5198 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005199 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005200 tot_bcn_ieLen);
5201 }
5202
5203 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
5204 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005205 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5206 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005207
5208 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005209 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5210 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005211 pos += nBytes;
5212 freeBytes -= nBytes;
5213
5214 /* Copy total Beacon report data length */
5215 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
5216 pos += sizeof(tot_bcn_ieLen);
5217 freeBytes -= sizeof(tot_bcn_ieLen);
5218
5219 for (i = 0; i < sendBss; i++)
5220 {
5221 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305222 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
5223 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005224 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005225 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
5226 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
5227 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
5228 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
5229 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
5230 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
5231 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
5232 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
5233 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
5234 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
5235 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
5236 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
5237 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
5238 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
5239 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
5240 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005241
5242 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005243 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
5244 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005245 pos += len;
5246 freeBytes -= len;
5247
5248 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005249 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005250 vos_mem_copy(pos, (char*)&len, sizeof(len));
5251 pos += sizeof(len);
5252 freeBytes -= sizeof(len);
5253
5254 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005255 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005256 pos += len;
5257 freeBytes -= len;
5258 }
5259
5260 wrqu.data.pointer = buf;
5261 wrqu.data.length = strlen(buf);
5262
5263 // send the event
5264 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5265 lastSent += sendBss;
5266 }
5267 }
5268}
5269
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005270#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005271