blob: 03ac7cc4b9d4262efc5b8e13defcc2c4f5153c1e [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#ifdef FEATURE_WLAN_TDLS
65#include "wlan_hdd_tdls.h"
66#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070067#include "sme_Api.h"
Sushant Kaushikba6764e2014-06-30 19:52:09 +053068#include "wlan_hdd_hostapd.h"
Mukul Sharma84f27252014-07-14 18:11:42 +053069#include "vos_utils.h"
Siddharth Bhalda0d1622015-04-24 15:47:49 +053070#include <wlan_hdd_wext.h>
Mukul Sharma84f27252014-07-14 18:11:42 +053071
Jeff Johnson295189b2012-06-20 16:38:30 -070072v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
73
Shailender Karmuchia734f332013-04-19 14:02:48 -070074struct ether_addr
Jeff Johnson295189b2012-06-20 16:38:30 -070075{
76 u_char ether_addr_octet[6];
77};
78// These are needed to recognize WPA and RSN suite types
79#define HDD_WPA_OUI_SIZE 4
80v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
81v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
82v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
83v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
84v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
85v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080086#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070087v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080088#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070089#define HDD_RSN_OUI_SIZE 4
90v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
91v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
92v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
93v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
94v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
95v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080096#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070097v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080098#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -070099#ifdef WLAN_FEATURE_11W
100v_U8_t ccpRSNOui07[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x06 }; // RSN-PSK-SHA256
Abhishek Singhae408032014-09-25 17:22:04 +0530101/* RSN-8021X-SHA256 */
102v_U8_t ccpRSNOui08[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 };
Chet Lanctot186b5732013-03-18 10:26:30 -0700103#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700104
Shailender Karmuchia734f332013-04-19 14:02:48 -0700105#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700106// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700107#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
108#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700109#endif
110
111#define BEACON_FRAME_IES_OFFSET 12
112
Chet Lanctot186b5732013-03-18 10:26:30 -0700113#ifdef WLAN_FEATURE_11W
114void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
115 tANI_U32 nFrameLength,
116 tANI_U8* pbFrames,
117 tANI_U8 frameType );
118#endif
119
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800120#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700121static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
122 tANI_U8 state,
123 tANI_U16 measInterval );
124static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800125static void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
126static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700127
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800128#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700129
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530130static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
131 tCsrRoamInfo *pRoamInfo,
132 tANI_U32 roamId,
133 eRoamCmdStatus roamStatus,
134 eCsrRoamResult roamResult );
135
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530136v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
137 eConnectionState connState )
138{
139 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530140 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
141 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700142 pHddStaCtx->conn_info.connState = connState;
143}
144
145// returns FALSE if not connected.
146// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
147// returns the connection state. Can specify NULL if you dont' want to get the actual state.
148
Shailender Karmuchia734f332013-04-19 14:02:48 -0700149static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
150 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700151{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700152 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700153 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700154
Jeff Johnson295189b2012-06-20 16:38:30 -0700155 // get the connection state.
156 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700157 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700158 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700159 eConnectionState_IbssConnected == connState ||
160 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700161 {
162 fConnected = VOS_TRUE;
163 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700164 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700165 {
166 fConnected = VOS_FALSE;
167 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700168
Jeff Johnson295189b2012-06-20 16:38:30 -0700169 if ( pConnState )
170 {
171 *pConnState = connState;
172 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700173
Jeff Johnson295189b2012-06-20 16:38:30 -0700174 return( fConnected );
175}
176
177v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
178{
179 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700180}
Jeff Johnson295189b2012-06-20 16:38:30 -0700181
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530182eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx )
183{
184 v_U8_t staChannel = 0;
185
186 if ( eConnectionState_Associated == pHddStaCtx->conn_info.connState )
187 {
188 staChannel = pHddStaCtx->conn_info.operationChannel;
189 }
190
191 if ( staChannel > 0 && staChannel < 14 )
192 return eCSR_BAND_24;
193 else if (staChannel >= 36 && staChannel <= 165 )
194 return eCSR_BAND_5G;
195 else /* If station is not connected return as eCSR_BAND_ALL */
196 return eCSR_BAND_ALL;
197}
198
199
Jeff Johnson295189b2012-06-20 16:38:30 -0700200//TODO - Not used anyhwere. Can be removed.
201#if 0
202//
203v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
204{
205 v_BOOL_t fConnectedInfra = FALSE;
206 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700207
Jeff Johnson295189b2012-06-20 16:38:30 -0700208 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700209 {
210 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700211 {
212 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700213 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700214 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700215
Jeff Johnson295189b2012-06-20 16:38:30 -0700216 return( fConnectedInfra );
217}
218#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700219
Jeff Johnson295189b2012-06-20 16:38:30 -0700220static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
221{
222 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700223
Jeff Johnson295189b2012-06-20 16:38:30 -0700224 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700225
226 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700227 {
228 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
229 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700230
Jeff Johnson295189b2012-06-20 16:38:30 -0700231 return( fConnected );
232}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700233
Jeff Johnson295189b2012-06-20 16:38:30 -0700234inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
235{
236 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700237
Jeff Johnson295189b2012-06-20 16:38:30 -0700238 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700239
240 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700241 {
242 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
243 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700244
Jeff Johnson295189b2012-06-20 16:38:30 -0700245 return( fConnected );
246}
247
248static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
249{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700250 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700251 {
252 case eCSR_BSS_TYPE_INFRASTRUCTURE:
253 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
254 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700255
Jeff Johnson295189b2012-06-20 16:38:30 -0700256 case eCSR_BSS_TYPE_IBSS:
257 case eCSR_BSS_TYPE_START_IBSS:
258 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
259 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700260
261 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700262 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700263 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700264 default:
265 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700266 break;
267 }
268
Jeff Johnson295189b2012-06-20 16:38:30 -0700269}
270
271void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
272{
273 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
274 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700275
Jeff Johnson295189b2012-06-20 16:38:30 -0700276 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700277
278 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700279 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700280 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700281 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
282 {
283 VOS_ASSERT( pRoamInfo->pBssDesc );
284 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
285
286 // Save the Station ID for this station from the 'Roam Info'.
287 //For IBSS mode, staId is assigned in NEW_PEER_IND
288 //For reassoc, the staID doesn't change and it may be invalid in this structure
289 //so no change here.
290 if( !pRoamInfo->fReassocReq )
291 {
292 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
293 }
294 }
295 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700296 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700298 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700299 else
300 {
301 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
302 // or we can't function.
303 VOS_ASSERT( 0 );
304 }
305
306 // notify WMM
307 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
308
309 if( !pRoamInfo->u.pConnectedProfile )
310 {
311 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
312 }
313 else
314 {
315 // Get Multicast Encryption Type
316 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
317 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
318 // Get Unicast Encrytion Type
319 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
320 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
321
322 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
323
324 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
325
326 // Save the ssid for the connection
327 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530328
329 // Save dot11mode in which STA associated to AP
330 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
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
Arif Hussain77d044f2014-01-03 19:56:04 -0800672 pr_info("wlan: " MAC_ADDRESS_STR " connected to " MAC_ADDRESS_STR "\n",
673 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
Kiet Lam34947452014-01-21 23:23:40 -0800674 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700675 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
676
677 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
678 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
679 * and fFTEnable is TRUE */
680#ifdef WLAN_FEATURE_VOWIFI_11R
681 // Send FT Keys to the supplicant when FT is enabled
682 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700683 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800684#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700685 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
686 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
687#endif
688 )
689 {
690 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
691 }
692#endif
693 }
694 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
695 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530696 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -0700697 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700698 type = WLAN_STA_ASSOC_DONE_IND;
Arif Hussain24bafea2013-11-15 15:10:03 -0800699 pr_info("wlan: new IBSS connection to " MAC_ADDRESS_STR"\n",
700 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700701 }
702 else /* Not Associated */
703 {
704 pr_info("wlan: disconnected\n");
705 type = WLAN_STA_DISASSOC_DONE_IND;
706 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
707 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700708 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700709
710 msg = NULL;
711 /*During the WLAN uninitialization,supplicant is stopped before the
712 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530713 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700714 {
715 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800716#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700718 {
719 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
720 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700721 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
722 }
723#endif
724 }
725 send_btc_nlink_msg(type, 0);
726}
727
728void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
729{
730 // Remove staId, bssId and peerMacAddress
731 pHddStaCtx->conn_info.staId [ 0 ] = 0;
732 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
733 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
734
735 // Clear all security settings
736 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
737 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
738 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
739
740 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700741 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700742
743 // Set not-connected state
744 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -0700745
746 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
747}
Katya Nigam47528772015-02-11 12:24:49 +0530748
749VOS_STATUS hdd_ibss_deinit_tx_rx_sta ( hdd_adapter_t *pAdapter, v_U8_t STAId )
750{
Katya Nigam1fd24402015-02-16 14:52:19 +0530751 v_U8_t ac;
752 /**Track whether OS TX queue has been disabled.*/
753 v_BOOL_t txSuspended[NUM_TX_QUEUES];
754 v_U8_t tlAC;
Katya Nigam47528772015-02-11 12:24:49 +0530755 v_U8_t i;
756 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
757 hdd_ibss_peer_info_t *pPeerInfo;
758
759 if( NULL == pHddStaCtx )
760 {
761 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
762 "%s: HDD station context NULL ",__func__);
763 return VOS_STATUS_E_FAILURE;
764 }
Katya Nigam1fd24402015-02-16 14:52:19 +0530765
Katya Nigam47528772015-02-11 12:24:49 +0530766 pPeerInfo = &pHddStaCtx->ibss_peer_info;
767 if (FALSE == pPeerInfo->ibssStaInfo[STAId].isUsed)
768 {
769 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
770 "%s: Deinit station not inited %d", __func__, STAId );
771 return VOS_STATUS_E_FAILURE;
772 }
773
774 hdd_flush_ibss_tx_queues(pAdapter, STAId);
Katya Nigam1fd24402015-02-16 14:52:19 +0530775
776 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
777 {
778 tlAC = hdd_QdiscAcToTlAC[ac];
779 txSuspended[ac] = pPeerInfo->ibssStaInfo[STAId].txSuspended[tlAC];
780 }
781
Katya Nigam47528772015-02-11 12:24:49 +0530782 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
783
Katya Nigam1fd24402015-02-16 14:52:19 +0530784 /* re-init hdd list, since netdev can still open adapter until
785 * driver gets unloaded
786 */
787 for (i = 0; i < NUM_TX_QUEUES; i ++)
788 {
789 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i],
790 HDD_TX_QUEUE_MAX_LEN);
791 }
792
793 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
794 {
795 if (txSuspended[ac])
796 {
797 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
798 "%s: TX queue re-enabled", __func__);
799 netif_wake_subqueue(pAdapter->dev, ac);
800 }
801 }
Katya Nigam47528772015-02-11 12:24:49 +0530802 return VOS_STATUS_SUCCESS;
803}
804
805static VOS_STATUS hdd_ibss_DeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
806{
807 VOS_STATUS vosStatus;
808
809 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
810 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
811 {
812 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
813 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
814 "Status= %d [0x%08X]",
815 __func__, staId, vosStatus, vosStatus );
816 }
817
818 vosStatus = hdd_ibss_deinit_tx_rx_sta ( pAdapter, staId );
819 if( VOS_STATUS_E_FAILURE == vosStatus )
820 {
821 VOS_TRACE ( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
822 "hdd_ibss_deinit_tx_rx_sta() failed for staID %d. "
823 "Status = %d [0x%08X]",
824 staId, vosStatus, vosStatus );
825 }
826
827 return( vosStatus );
828}
829
830VOS_STATUS hdd_ibss_init_tx_rx_sta( hdd_adapter_t *pAdapter, v_U8_t STAId, v_MACADDR_t *pmacAddrSTA)
831{
832 v_U8_t i = 0;
833 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
834 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
835
836 if (pPeerInfo->ibssStaInfo[STAId].isUsed)
837 {
838 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
839 "%s: Reinit station %d", __func__, STAId );
840 return VOS_STATUS_E_FAILURE;
841 }
842
843 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
844 for (i = 0; i < NUM_TX_QUEUES; i ++)
845 {
846 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i], HDD_TX_QUEUE_MAX_LEN);
847 }
848
849 pPeerInfo->ibssStaInfo[STAId].isUsed = VOS_TRUE;
850 pPeerInfo->ibssStaInfo[STAId].isDeauthInProgress = VOS_FALSE;
851 vos_copy_macaddr( &pPeerInfo->ibssStaInfo[STAId].macAddrSTA, pmacAddrSTA);
852
853 return VOS_STATUS_SUCCESS;
854}
855
856static VOS_STATUS hdd_ibss_RegisterSTA( hdd_adapter_t *pAdapter,
857 tCsrRoamInfo *pRoamInfo,
858 v_U8_t staId,
859 v_MACADDR_t *pPeerMacAddress,
860 tSirBssDescription *pBssDesc )
861{
862 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
863 WLAN_STADescType staDesc = {0};
864 eCsrEncryptionType connectedCipherAlgo;
865 v_BOOL_t fConnected;
866 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
867 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
868 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
869
870 if ( pPeerInfo->ibssStaInfo[staId].isUsed )
871 {
872 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
873 "clean up old entry for STA %d", staId);
874 hdd_ibss_DeregisterSTA( pAdapter, staId );
875 }
876
877 staDesc.ucSTAId = staId;
878 staDesc.wSTAType = WLAN_STA_IBSS;
879
880 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
881 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
882 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
883 // pass when making an Infrastructure connection.
884 vos_mem_copy(staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes));
885 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId, 6 );
886 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
887
888 if (hdd_wmm_is_active(pAdapter))
889 {
890 staDesc.ucQosEnabled = 1;
891 }
892 else
893 {
894 staDesc.ucQosEnabled = 0;
895 }
896 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
897 "HDD SOFTAP register TL QoS_enabled=%d",
898 staDesc.ucQosEnabled );
899
900 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
901 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
902 {
903 staDesc.ucProtectedFrame = 1;
904 }
905 else
906 {
907 staDesc.ucProtectedFrame = 0;
908
909 }
910
911 hdd_ibss_init_tx_rx_sta(pAdapter, staId, &staDesc.vSTAMACAddress);
912
913 // UMA is Not ready yet, Xlation will be done by TL
914 staDesc.ucSwFrameTXXlation = 1;
915 staDesc.ucSwFrameRXXlation = 1;
916 staDesc.ucAddRmvLLC = 1;
917 // Initialize signatures and state
918 staDesc.ucUcastSig = pRoamInfo->ucastSig;
919 staDesc.ucBcastSig = pRoamInfo->bcastSig;
920 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED;
921
922 staDesc.ucIsReplayCheckValid = VOS_FALSE;
923
924 // Register the Station with TL.
925 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
926 hdd_rx_packet_cbk,
927 hdd_tx_complete_cbk,
928 hdd_ibss_tx_fetch_packet_cbk, &staDesc,
929 pBssDesc->rssi );
930 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
931 {
932 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
933 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
934 vosStatus, vosStatus );
935 return vosStatus;
936 }
937
938 //Timer value should be in milliseconds
939 if ( pHddCtx->cfg_ini->dynSplitscan &&
940 ( VOS_TIMER_STATE_RUNNING !=
941 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
942 {
943 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
944 pHddCtx->cfg_ini->trafficMntrTmrForSplitScan);
945 }
946
947 pPeerInfo->ibssStaInfo[staId].ucSTAId = staId;
948 pPeerInfo->ibssStaInfo[staId].isQosEnabled = staDesc.ucQosEnabled;
949
950 vosStatus = WLANTL_ChangeSTAState( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staDesc.ucSTAId,
951 WLANTL_STA_AUTHENTICATED );
952
953 pPeerInfo->ibssStaInfo[staId].tlSTAState = WLANTL_STA_AUTHENTICATED;
954 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
955
956 return( vosStatus );
957}
958
Jeff Johnson295189b2012-06-20 16:38:30 -0700959/* TODO Revist this function. and data path */
960static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
961{
962 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700963
Katya Nigam47528772015-02-11 12:24:49 +0530964 hdd_disconnect_tx_rx(pAdapter);
Ravi Joshif9520d62013-10-18 04:11:46 -0700965
Jeff Johnson295189b2012-06-20 16:38:30 -0700966 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
967 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
968 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530969 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700970 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700971 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700972 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700973 }
974 return( vosStatus );
975}
976
977
978static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
979 tANI_U32 roamId, eRoamCmdStatus roamStatus,
980 eCsrRoamResult roamResult )
981{
982 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700983 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700984 struct net_device *dev = pAdapter->dev;
985 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
986 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700987 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530988 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700989
990 // Sanity check
991 if(dev == NULL)
992 {
Agarwal Ashish971c2882013-10-30 20:11:12 +0530993 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700994 "%s: net_dev is released return", __func__);
995 return eHAL_STATUS_FAILURE;
996 }
997
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530999 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 netif_tx_disable(dev);
1001 netif_carrier_off(dev);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +05301002 //TxTimeoutCount need to reset in case of disconnect handler
1003 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001004
Jeff Johnsone7245742012-09-05 17:12:55 -07001005 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301006 /* HDD has initiated disconnect, do not send disconnect indication
1007 * to kernel as it will be handled by __cfg80211_disconnect.
1008 */
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301009 /* If only STA mode is on */
1010 if((pHddCtx->concurrency_mode <= 1) &&
1011 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
1012 {
1013 pHddCtx->isAmpAllowed = VOS_TRUE;
1014 }
1015
Agarwal Ashish47d18112014-08-04 19:55:07 +05301016 /* Need to apply spin lock before decreasing active sessions
1017 * as there can be chance for double decrement if context switch
1018 * Calls wlan_hdd_disconnect.
1019 */
1020
1021 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301022 if ( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState )
1023 {
1024 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1025 FL(" HDD has initiated a disconnect, no need to send"
1026 " disconnect indication to kernel"));
1027 sendDisconInd = FALSE;
1028 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301029 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301031 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +05301032 FL(" Set HDD connState to eConnectionState_Disconnecting from %d "),
1033 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301034 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
1035 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001036 }
Agarwal Ashish47d18112014-08-04 19:55:07 +05301037 spin_unlock_bh(&pAdapter->lock_for_active_session);
1038
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -07001040
1041 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07001042
1043 // indicate 'disconnect' status to wpa_supplicant...
1044 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001045 /* indicate disconnected event to nl80211 */
1046 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
1047 {
1048 /*During the WLAN uninitialization,supplicant is stopped before the
1049 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301050 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001051 {
Sushant Kaushik0b343422015-05-25 17:15:55 +05301052 if (sendDisconInd)
1053 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1054 "%s: sent disconnected event to nl80211",
1055 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001056#ifdef WLAN_FEATURE_P2P_DEBUG
1057 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1058 {
1059 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
1060 {
1061 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
1062 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
1063 "and moved to disconnected state");
1064 }
1065 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
1066 {
1067 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
1068 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
1069 "and moved to inactive state");
1070 }
1071 }
1072#endif
Sushant Kaushikbad61892015-07-10 16:43:28 +05301073 if ((roamStatus == eCSR_ROAM_LOSTLINK) &&
1074 !pRoamInfo->reasonCode)
1075 wlan_hdd_get_frame_logs(pAdapter,
1076 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301077 /*Only send indication to kernel if not initiated by kernel*/
1078 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301080 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
1081 if ( eCSR_ROAM_LOSTLINK == roamStatus )
1082 {
1083 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
1084 }
1085 else
1086 {
1087 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
1088 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001089 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301090 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
Masti, Narayanraddi70e5b472015-08-04 12:54:16 +05301091 (TRUE == sme_IsFeatureSupportedByFW(TDLS)) &&
1092 (eTDLS_SUPPORT_ENABLED == pHddCtx->tdls_mode_last ||
1093 eTDLS_SUPPORT_EXPLICIT_TRIGGER_ONLY ==
1094 pHddCtx->tdls_mode_last)) {
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301095 if (pAdapter->device_mode != WLAN_HDD_INFRA_STATION)
1096 /* Enable TDLS support Once P2P session ends since
1097 * upond detection of concurrency TDLS would be disabled
1098 */
Masti, Narayanraddi70e5b472015-08-04 12:54:16 +05301099 wlan_hdd_tdls_set_mode(pHddCtx, pHddCtx->tdls_mode_last,
1100 FALSE);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301101 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001102 //If the Device Mode is Station
1103 // and the P2P Client is Connected
1104 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001105
1106 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001107 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07001108 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -07001109 {
1110 //Enable BMPS only of other Session is P2P Client
1111 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001112 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001113
1114 if (NULL != pVosContext)
1115 {
1116 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1117
1118 if(NULL != pHddCtx)
1119 {
1120 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301121 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1122 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301124 if (pHddCtx->hdd_wlan_suspended)
1125 {
1126 hdd_set_pwrparams(pHddCtx);
1127 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301129 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001130 }
1131 }
1132 }
1133 }
1134 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001135
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +05301136 hdd_wmm_adapter_clear(pAdapter);
Mukul Sharmac159c432014-01-15 15:42:46 +05301137#if defined(WLAN_FEATURE_VOWIFI_11R)
1138 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
1139#endif
Katya Nigam63ce1772014-09-26 15:53:49 +05301140
1141 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
1142 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301143 v_U8_t i;
1144
Katya Nigam63ce1772014-09-26 15:53:49 +05301145 sta_id = IBSS_BROADCAST_STAID;
Katya Nigam47528772015-02-11 12:24:49 +05301146 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Katya Nigam63ce1772014-09-26 15:53:49 +05301147 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1148 {
1149 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301150 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1151 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +05301152 sta_id, status, status );
1153
1154 status = eHAL_STATUS_FAILURE;
1155 }
Katya Nigam63ce1772014-09-26 15:53:49 +05301156 pHddCtx->sta_to_adapter[sta_id] = NULL;
1157
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301158 /*Clear all the peer sta register with TL.*/
1159 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
1160 {
1161 if (0 != pHddStaCtx->conn_info.staId[i])
1162 {
1163 sta_id = pHddStaCtx->conn_info.staId[i];
1164
1165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1166 FL("Deregister StaID %d"),sta_id);
Katya Nigam47528772015-02-11 12:24:49 +05301167 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301168 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1169 {
1170 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1171 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1172 "Status= %d [0x%x]"),
1173 sta_id, status, status );
1174 status = eHAL_STATUS_FAILURE;
1175 }
1176
Nirav Shah7e3c8132015-06-22 23:51:42 +05301177 vstatus = hdd_sta_id_hash_remove_entry(pAdapter,
1178 sta_id, &pHddStaCtx->conn_info.peerMacAddress[i]);
1179 if (vstatus != VOS_STATUS_SUCCESS) {
1180 hddLog(VOS_TRACE_LEVEL_ERROR,
1181 FL("Not able to remove staid hash %d"),
1182 sta_id);
1183 status = eHAL_STATUS_FAILURE;
1184 } else {
1185 hddLog(VOS_TRACE_LEVEL_INFO,
1186 FL("ibss station removed sta_id %d mac:"
1187 MAC_ADDRESS_STR), sta_id,
1188 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[i].bytes));
1189 }
1190
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301191 /*set the staid and peer mac as 0, all other reset are
1192 * done in hdd_connRemoveConnectInfo.
1193 */
1194 pHddStaCtx->conn_info.staId[i]= 0;
1195 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
1196
1197 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1198 pHddCtx->sta_to_adapter[sta_id] = NULL;
1199 }
1200 }
1201
Katya Nigam63ce1772014-09-26 15:53:49 +05301202 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301203 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001204 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301205 sta_id = pHddStaCtx->conn_info.staId[0];
1206
1207 //We should clear all sta register with TL, for now, only one.
1208 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
1209 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1210 {
1211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1212 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1213 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -07001214 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001215
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301216 status = eHAL_STATUS_FAILURE;
1217 }
1218
1219 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 }
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301221
1222#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1223 if (VOS_STATUS_SUCCESS !=
1224 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1225 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE_AC))
1226 {
1227 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1228 "WLANTL_ClearInterfaceStats Failed", __func__);
1229 }
1230 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1231 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1232 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1233 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1234#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1235
Jeff Johnson295189b2012-06-20 16:38:30 -07001236 // Clear saved connection information in HDD
1237 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhf4669da2014-05-26 15:07:49 +05301238 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1239 "%s: Set HDD connState to eConnectionState_NotConnected",
1240 __func__);
1241 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301242#ifdef WLAN_FEATURE_GTK_OFFLOAD
1243 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1244 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1245 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301246 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1247 sizeof (tSirGtkOffloadParams));
1248 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301249 }
1250#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001251
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001252#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001253 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1254 {
1255 wlan_hdd_tdls_disconnection_callback(pAdapter);
1256 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001257#endif
1258
Jeff Johnson295189b2012-06-20 16:38:30 -07001259 //Unblock anyone waiting for disconnect to complete
1260 complete(&pAdapter->disconnect_comp_var);
1261 return( status );
1262}
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301263
1264static void hdd_postTLPacketPendingInd(hdd_adapter_t *pAdapter,
1265 v_U8_t staId)
1266{
1267 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1268 v_SINT_t i;
1269 v_SIZE_t size;
1270 VOS_STATUS status;
1271 v_BOOL_t granted = VOS_FALSE;
1272
1273 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1274 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ||
1275 (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE))
1276 {
1277 //Indicate to TL that there is pending data if a queue is non empty
1278 for (i = WLANTL_AC_HIGH_PRIO; i>=0; --i)
1279 {
1280 size = 0;
1281 hdd_list_size(&pAdapter->wmm_tx_queue[i], &size);
1282 if (size > 0)
1283 {
1284 if (i != WLANTL_AC_HIGH_PRIO)
1285 {
1286 if (VOS_FALSE ==
1287 pAdapter->hddWmmStatus.wmmAcStatus[i].wmmAcAccessAllowed)
1288 {
1289 hdd_wmm_acquire_access(pAdapter,
1290 (WLANTL_ACEnumType)i, &granted);
1291 pAdapter->psbChanged |= (1 << i);
1292 }
1293 else
1294 granted = VOS_TRUE;
1295 }
1296
1297 if (granted || (i == WLANTL_AC_HIGH_PRIO))
1298 {
1299 status = WLANTL_STAPktPending(pHddCtx->pvosContext,
1300 staId, (WLANTL_ACEnumType)i);
1301 if (!VOS_IS_STATUS_SUCCESS(status))
1302 {
1303 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1304 "%s: Failure in indicating pkt to TL for QID=%d",
1305 __func__, i);
1306 }
1307 }
1308 }
1309 }
1310 }
1311}
1312
Jeff Johnson295189b2012-06-20 16:38:30 -07001313static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
1314 tCsrRoamInfo *pRoamInfo,
1315 v_U8_t staId,
1316 v_MACADDR_t *pPeerMacAddress,
1317 tSirBssDescription *pBssDesc )
1318{
1319 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1320 WLAN_STADescType staDesc = {0};
1321 eCsrEncryptionType connectedCipherAlgo;
1322 v_BOOL_t fConnected;
1323 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1324 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001325 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001326
1327 if ( NULL == pBssDesc)
1328 {
1329 return VOS_STATUS_E_FAILURE;
1330 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 // Get the Station ID from the one saved during the assocation.
1332 staDesc.ucSTAId = staId;
1333
Katya Nigam47528772015-02-11 12:24:49 +05301334 staDesc.wSTAType = WLAN_STA_INFRA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001335
Katya Nigam47528772015-02-11 12:24:49 +05301336 // grab the bssid from the connection info in the adapter structure and hand that
1337 // over to TL when registering.
1338 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,
1339 sizeof(pHddStaCtx->conn_info.bssId) );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001340
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1342
1343 // set the QoS field appropriately
1344 if (hdd_wmm_is_active(pAdapter))
1345 {
1346 staDesc.ucQosEnabled = 1;
1347 }
1348 else
1349 {
1350 staDesc.ucQosEnabled = 0;
1351 }
1352
1353 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1354 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1355 {
1356 staDesc.ucProtectedFrame = 1;
1357 }
1358 else
1359 {
1360 staDesc.ucProtectedFrame = 0;
1361
1362 }
1363
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001364#ifdef FEATURE_WLAN_ESE
1365 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
1366#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001367
1368#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1369 /* check whether replay check is valid for the station or not */
1370 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
1371 {
1372 /* Encryption mode is either TKIP or AES
1373 and replay check is valid for only these
1374 two encryption modes */
1375 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1376 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1377 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1378 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001379
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 else
1381 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001382 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001383 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001384 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001385 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1386 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1387 }
1388#endif
1389
1390#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001391 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001392 if (pAdapter->wapi_info.fIsWapiSta)
1393 {
1394 staDesc.ucIsWapiSta = 1;
1395 }
1396 else
1397 {
1398 staDesc.ucIsWapiSta = 0;
1399 }
1400#endif /* FEATURE_WLAN_WAPI */
1401
1402 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1403 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1404
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 // UMA is Not ready yet, Xlation will be done by TL
1406 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001407 staDesc.ucSwFrameRXXlation = 1;
1408 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001409 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001410 staDesc.ucQosEnabled );
1411 // Initialize signatures and state
1412 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1413 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1414 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1415 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001416 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001417 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 -07001418 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1419 hdd_rx_packet_cbk,
1420 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001421 hdd_tx_fetch_packet_cbk, &staDesc,
1422 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001423
Jeff Johnson295189b2012-06-20 16:38:30 -07001424 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1425 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001426 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001427 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001428 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001429 return vosStatus;
1430 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001431
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001432 if ( cfg_param->dynSplitscan &&
1433 ( VOS_TIMER_STATE_RUNNING !=
1434 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1435 {
1436 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1437 cfg_param->trafficMntrTmrForSplitScan);
1438 }
1439
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301440 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1441 // then go to 'authenticated'. For all other authentication types
1442 // (those that donot require upper layer authentication) we can put
1443 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001444 if (staDesc.wSTAType != WLAN_STA_IBSS)
1445 VOS_ASSERT( fConnected );
1446
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301447 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001448 {
1449 // Connections that do not need Upper layer auth, transition TL directly
1450 // to 'Authenticated' state.
1451 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1452 WLANTL_STA_AUTHENTICATED );
1453
1454 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301455
1456 hdd_postTLPacketPendingInd(pAdapter, staDesc.ucSTAId);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001457 }
1458 else
1459 {
1460 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301461 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1462 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001463 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301464 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001465 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1466 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001467 return( vosStatus );
1468}
1469
Jeff Johnson295189b2012-06-20 16:38:30 -07001470static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1471 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1472{
1473 unsigned int len = 0;
1474 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001475 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001476 tANI_U32 rspRsnLength = 0;
1477 struct ieee80211_channel *chan;
1478
Agarwal Ashish51325b52014-06-16 16:50:49 +05301479 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001480 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001481 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001482 }
1483
Agarwal Ashish51325b52014-06-16 16:50:49 +05301484 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001485 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1486 goto done;
1487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001488
Agarwal Ashish51325b52014-06-16 16:50:49 +05301489 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001490 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1491 goto done;
1492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001493
1494 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1495 pCsrRoamInfo->nAssocReqLength);
1496 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001497 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001498
1499 //pFTAssocRsp needs to point to the IEs
1500 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001501 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001502 (unsigned int)pFTAssocRsp[0],
1503 (unsigned int)pFTAssocRsp[1]);
1504
1505 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001506 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001507 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001508 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001509 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001510
1511 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1512 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1513 reqRsnIe, reqRsnLength,
1514 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001515
1516done:
1517 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001518}
Jeff Johnson295189b2012-06-20 16:38:30 -07001519
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301520void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1521{
1522 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1523 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1524 tCsrRoamInfo roamInfo;
1525 roamInfo.fAuthRequired = FALSE;
1526 vos_mem_copy(roamInfo.bssid,
1527 pHddStaCtx->roam_info.bssid,
1528 WNI_CFG_BSSID_LEN);
1529 vos_mem_copy(roamInfo.peerMac,
1530 pHddStaCtx->roam_info.peerMac,
1531 WNI_CFG_BSSID_LEN);
1532
1533 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1534 &roamInfo,
1535 pHddStaCtx->roam_info.roamId,
1536 pHddStaCtx->roam_info.roamStatus,
1537 eCSR_ROAM_RESULT_AUTHENTICATED);
1538 if (halStatus != eHAL_STATUS_SUCCESS)
1539 {
1540 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1541 }
1542 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1543}
1544
Shailender Karmuchia734f332013-04-19 14:02:48 -07001545static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1546 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 eCsrRoamResult roamResult )
1548{
1549 struct net_device *dev = pAdapter->dev;
1550 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1551 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301552 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05301553 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001554 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1555 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001556#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 int ft_carrier_on = FALSE;
1558#endif
1559 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301560 v_BOOL_t hddDisconInProgress = FALSE;
1561
1562 /* HDD has initiated disconnect, do not send connect result indication
1563 * to kernel as it will be handled by __cfg80211_disconnect.
1564 */
1565 if(( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) &&
1566 (( eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
1567 ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)) )
1568 {
1569 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1570 FL(" Disconnect from HDD in progress "));
1571 hddDisconInProgress = TRUE;
1572 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001573
Jeff Johnson295189b2012-06-20 16:38:30 -07001574 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1575 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301576 if ( !hddDisconInProgress )
1577 {
1578 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05301579 "%s: Set HDD connState to eConnectionState_Associated",
1580 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301581 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1582 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001583
c_hpothu44ff4e02014-05-08 00:13:57 +05301584 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001585 // Save the connection info from CSR...
1586 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1587#ifdef FEATURE_WLAN_WAPI
1588 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1589 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1590 {
1591 pAdapter->wapi_info.fIsWapiSta = 1;
1592 }
1593 else
1594 {
1595 pAdapter->wapi_info.fIsWapiSta = 0;
1596 }
1597#endif /* FEATURE_WLAN_WAPI */
1598
1599 // indicate 'connect' status to userspace
1600 hdd_SendAssociationEvent(dev,pRoamInfo);
1601
1602
Shailender Karmuchia734f332013-04-19 14:02:48 -07001603 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001604 INIT_COMPLETION(pAdapter->linkup_event_var);
1605
1606 /*
1607 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1608 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 -07001609 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001610 know that the device is getting activated properly.
1611 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001612#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05301613 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 {
1615#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001616 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 pAdapter->isLinkUpSvcNeeded = TRUE;
1618
Shailender Karmuchia734f332013-04-19 14:02:48 -07001619 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 pAdapter->isLinkUpSvcNeeded = TRUE;
1621
1622 // Switch on the Carrier to activate the device
1623 netif_carrier_on(dev);
1624
1625 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1626 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1627 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001628 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001629 {
1630 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1631 }
1632
1633 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1634 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001635#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001636 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001637 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001638 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001639 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001640 }
1641#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05301642 /* Check for STAID */
1643 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
1644 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1645 else
1646 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001647
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001648#ifdef FEATURE_WLAN_TDLS
1649 wlan_hdd_tdls_connection_callback(pAdapter);
1650#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001651 //For reassoc, the station is already registered, all we need is to change the state
1652 //of the STA in TL.
1653 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05301654 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07001655 if( !pRoamInfo->fReassocReq )
1656 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001657 struct cfg80211_bss *bss;
1658#ifdef WLAN_FEATURE_VOWIFI_11R
1659 u8 *pFTAssocRsp = NULL;
1660 unsigned int assocRsplen = 0;
1661 u8 *pFTAssocReq = NULL;
1662 unsigned int assocReqlen = 0;
1663 struct ieee80211_channel *chan;
1664#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001665 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001667
1668 /* add bss_id to cfg80211 data base */
1669 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1670 if (NULL == bss)
1671 {
1672 pr_err("wlan: Not able to create BSS entry\n");
Katya Nigam346d4e92014-09-02 16:16:12 +05301673 netif_carrier_off(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 return eHAL_STATUS_FAILURE;
1675 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001676#ifdef WLAN_FEATURE_VOWIFI_11R
1677 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001678 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001679 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001680
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001681 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001682 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001683 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001684 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001685 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001686 // pFTAssocRsp needs to point to the IEs
1687 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1688 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1689 (unsigned int)pFTAssocRsp[0],
1690 (unsigned int)pFTAssocRsp[1]);
1691 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001692 }
1693 else
1694 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001695 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1696 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001697 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001698
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001699 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001700 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001701 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001702 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001703 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001704 if(!ft_carrier_on)
1705 {
1706 // pFTAssocReq needs to point to the IEs
1707 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1708 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1709 (unsigned int)pFTAssocReq[0],
1710 (unsigned int)pFTAssocReq[1]);
1711 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1712 }
1713 else
1714 {
1715 /* This should contain only the FTIEs */
1716 assocReqlen = pRoamInfo->nAssocReqLength;
1717 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001718 }
1719 else
1720 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001721 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1722 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001723 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001724
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001725 if(ft_carrier_on)
1726 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301727 if ( !hddDisconInProgress )
1728 {
1729 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001730 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301731 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001732 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301733 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001734 assocRsplen);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301735 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1736 {
1737 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1738 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301739 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001740 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1741 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301742 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301743 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1744 {
1745 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1746 pRoamInfo->fAuthRequired = FALSE;
1747
1748 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1749 pRoamInfo->bssid,
1750 HDD_MAC_ADDR_LEN);
1751 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1752 pRoamInfo->peerMac,
1753 HDD_MAC_ADDR_LEN);
1754 pHddStaCtx->roam_info.roamId = roamId;
1755 pHddStaCtx->roam_info.roamStatus = roamStatus;
1756 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1757 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001758 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301759 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001760 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001761 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001762 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001763 cfg80211_connect_result(dev, pRoamInfo->bssid,
1764 pFTAssocReq, assocReqlen,
1765 pFTAssocRsp, assocRsplen,
1766 WLAN_STATUS_SUCCESS,
1767 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001768 }
1769 }
1770 else
1771#endif
1772 {
1773 /* wpa supplicant expecting WPA/RSN IE in connect result */
1774 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1775 pAdapter->sessionId,
1776 &reqRsnLength,
1777 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001778
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001779 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1780 pAdapter->sessionId,
1781 &rspRsnLength,
1782 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301783 if ( !hddDisconInProgress )
1784 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001785#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301786 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05301787 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301788 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301789 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1790 {
1791 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1792 }
Mukul Sharma84f27252014-07-14 18:11:42 +05301793 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301794 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001795#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001796
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301797 {
1798 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301799 "%s: sending connect indication to nl80211:"
1800 " for bssid " MAC_ADDRESS_STR
1801 " reason:%d and Status:%d\n",
1802 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1803 roamResult, roamStatus);
1804
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301805 /* inform connect result to nl80211 */
1806 cfg80211_connect_result(dev, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001807 reqRsnIe, reqRsnLength,
1808 rspRsnIe, rspRsnLength,
1809 WLAN_STATUS_SUCCESS,
1810 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301811 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001812 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001813 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301814 if ( !hddDisconInProgress )
1815 {
1816 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07001817#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301818 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07001819#endif
1820 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301821 // Register the Station with TL after associated...
1822 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001823 pRoamInfo,
1824 pHddStaCtx->conn_info.staId[ 0 ],
1825 NULL,
1826 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301827 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001828 }
1829 else
1830 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001831 /* wpa supplicant expecting WPA/RSN IE in connect result */
1832 /* in case of reassociation also need to indicate it to supplicant */
1833 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1834 pAdapter->sessionId,
1835 &reqRsnLength,
1836 reqRsnIe);
1837
1838 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001839 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301840 if( pRoamInfo->fAuthRequired )
1841 {
1842 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1843 pHddStaCtx->conn_info.staId[ 0 ],
1844 WLANTL_STA_CONNECTED );
1845 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1846 }
1847 else
1848 {
1849 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1850 "%s: staId: %d Changing TL state to AUTHENTICATED",
1851 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1852 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1853 pHddStaCtx->conn_info.staId[ 0 ],
1854 WLANTL_STA_AUTHENTICATED );
1855 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301856 hdd_postTLPacketPendingInd(pAdapter,
1857 pHddStaCtx->conn_info.staId[0]);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301858 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001859 }
1860
1861 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1862 {
1863 // perform any WMM-related association processing
1864 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1865 }
1866 else
1867 {
1868 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001869 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001870 vosStatus, vosStatus );
1871 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001872#ifdef WLAN_FEATURE_11W
1873 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1874 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1875#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301876
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05301878 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301879 {
1880 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05301881 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301882 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301883 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1884 {
1885 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
1886 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001887 }
1888 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001889 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1891
1892 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001893 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001894 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1895 " reason:%d and Status:%d\n",
1896 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1897 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001898 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001899 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1900 " reason:%d and Status:%d\n",
1901 MAC_ADDR_ARRAY(pWextState->req_bssId),
1902 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001903
Abhishek Singh611295e2015-07-09 11:11:54 +05301904 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)
1905 wlan_hdd_get_frame_logs(pAdapter,
Siddharth Bhalda0d1622015-04-24 15:47:49 +05301906 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
1907
Abhishek Singhf4669da2014-05-26 15:07:49 +05301908 /* Set connection state to eConnectionState_NotConnected only when CSR
1909 * has completed operation - with a ASSOCIATION_FAILURE status
1910 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301911 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05301912 {
1913 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1914 "%s: Set HDD connState to eConnectionState_NotConnected",
1915 __func__);
1916 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1917 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05301918 if((pHddCtx->concurrency_mode <= 1) &&
1919 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 {
1921 pHddCtx->isAmpAllowed = VOS_TRUE;
1922 }
1923
1924 //If the Device Mode is Station
1925 // and the P2P Client is Connected
1926 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001927
1928 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001929 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001930 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1931 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05301932 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07001933 {
1934 //Enable BMPS only of other Session is P2P Client
1935 hdd_context_t *pHddCtx = NULL;
1936 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1937
1938 if (NULL != pVosContext)
1939 {
1940 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1941
1942 if(NULL != pHddCtx)
1943 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301944 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301945 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1946 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301947 {
1948 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001949 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301950 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001951 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301952 hdd_enable_bmps_imps(pHddCtx);
1953 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001954 }
1955 }
1956 }
1957
James Zmudafbf5ffc2013-03-25 12:45:35 -07001958 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001959 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301960 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07001961 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301962 if (pRoamInfo)
1963 hddLog(VOS_TRACE_LEVEL_ERROR,
1964 "%s: send connect failure to nl80211:"
1965 " for bssid " MAC_ADDRESS_STR
1966 " reason:%d and Status:%d\n" ,
1967 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1968 roamResult, roamStatus);
1969 else
1970 hddLog(VOS_TRACE_LEVEL_ERROR,
1971 "%s: connect failed:"
1972 " for bssid " MAC_ADDRESS_STR
1973 " reason:%d and Status:%d\n" ,
1974 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
1975 roamResult, roamStatus);
1976
c_hpothudaa90e22014-06-24 17:23:43 +05301977 /*Clear the roam profile*/
1978 hdd_clearRoamProfileIe( pAdapter );
1979
James Zmudafbf5ffc2013-03-25 12:45:35 -07001980 /* inform association failure event to nl80211 */
1981 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1982 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001983 if (pRoamInfo)
1984 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1985 NULL, 0, NULL, 0,
1986 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1987 GFP_KERNEL );
1988 else
1989 cfg80211_connect_result ( dev, pWextState->req_bssId,
1990 NULL, 0, NULL, 0,
1991 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1992 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001993 }
1994 else
1995 {
Sushant Kaushik21f28232014-12-18 11:42:46 +05301996 if (pRoamInfo){
1997 eCsrAuthType authType =
1998 pWextState->roamProfile.AuthType.authType[0];
1999 v_BOOL_t isWep = (authType == eCSR_AUTH_TYPE_OPEN_SYSTEM) ||
2000 (authType == eCSR_AUTH_TYPE_SHARED_KEY);
2001
2002 /* In case of OPEN-WEP or SHARED-WEP authentication,
2003 * send exact protocol reason code. This enables user
2004 * applications to reconnect the station with correct
2005 * configuration.
2006 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002007 cfg80211_connect_result ( dev, pRoamInfo->bssid,
2008 NULL, 0, NULL, 0,
Sushant Kaushik21f28232014-12-18 11:42:46 +05302009 isWep ? pRoamInfo->reasonCode :
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002010 WLAN_STATUS_UNSPECIFIED_FAILURE,
2011 GFP_KERNEL );
Sushant Kaushik21f28232014-12-18 11:42:46 +05302012 } else
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002013 cfg80211_connect_result ( dev, pWextState->req_bssId,
2014 NULL, 0, NULL, 0,
2015 WLAN_STATUS_UNSPECIFIED_FAILURE,
2016 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07002017 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002018 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002019
Kumar Anand82c009f2014-05-29 00:29:42 -07002020 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07002021
c_hpothu24f40982014-04-18 18:00:36 +05302022 if (pRoamInfo)
2023 {
2024 WLANTL_AssocFailed(pRoamInfo->staId);
2025 }
Mihir Sheteb7337272014-04-11 15:53:08 +05302026
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302027 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 netif_tx_disable(dev);
2029 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002030
Jeff Johnson295189b2012-06-20 16:38:30 -07002031 }
2032
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302033 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302034 {
2035 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
2036 if (pHostapdAdapter != NULL)
2037 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302038 /* Restart SAP if its operating channel is different
2039 * from AP channel.
2040 */
2041 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
2042 (int)pRoamInfo->pBssDesc->channelId)
2043 {
2044 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
2045 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
2046 (int)pRoamInfo->pBssDesc->channelId);
Deepthi Gowric9c777d2014-12-10 16:17:11 +05302047 hdd_hostapd_stop(pHostapdAdapter->dev);
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302048 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302049 }
2050 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002051 return eHAL_STATUS_SUCCESS;
2052}
2053
2054/**============================================================================
2055 *
Jeff Johnson81c17882013-05-03 09:53:35 -07002056 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07002057 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07002058
Jeff Johnson295189b2012-06-20 16:38:30 -07002059 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07002060static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
2061 tCsrRoamInfo *pRoamInfo,
2062 tANI_U32 roamId,
2063 eRoamCmdStatus roamStatus,
2064 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07002065{
Katya Nigam47528772015-02-11 12:24:49 +05302066 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2067 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2068 struct cfg80211_bss *bss;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302069 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Katya Nigam47528772015-02-11 12:24:49 +05302070
Jeff Johnson81c17882013-05-03 09:53:35 -07002071 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
2072 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
2073
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 switch( roamResult )
2075 {
2076 // both IBSS Started and IBSS Join should come in here.
2077 case eCSR_ROAM_RESULT_IBSS_STARTED:
2078 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002079 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07002080 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002081 if (NULL == pRoamInfo)
2082 {
2083 VOS_ASSERT(0);
2084 return;
2085 }
2086
2087 /* When IBSS Started comes from CSR, we need to move
2088 * connection state to IBSS Disconnected (meaning no peers
2089 * are in the IBSS).
2090 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05302091 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2092 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
2093 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07002094 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2095 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302096 /*notify wmm */
2097 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002098 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002099
Jeff Johnson81c17882013-05-03 09:53:35 -07002100 if (pRoamInfo->pBssDesc)
2101 {
Anand N Sunkadfec40682015-07-29 09:51:17 +05302102#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2103 struct ieee80211_channel *chan;
2104 int chan_no;
2105 unsigned int freq;
2106#endif
Katya Nigam47528772015-02-11 12:24:49 +05302107 hdd_ibss_RegisterSTA (pAdapter, pRoamInfo,
2108 IBSS_BROADCAST_STAID,
2109 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson81c17882013-05-03 09:53:35 -07002110
2111 /* we created the IBSS, notify supplicant */
2112 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
2113 MAC_ADDRESS_STR,
2114 __func__, pAdapter->dev->name,
2115 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2116
2117 /* we must first give cfg80211 the BSS information */
2118 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2119 if (NULL == bss)
2120 {
2121 hddLog(VOS_TRACE_LEVEL_ERROR,
2122 "%s: %s: unable to create IBSS entry",
2123 __func__, pAdapter->dev->name);
2124 return;
2125 }
Anand N Sunkadfec40682015-07-29 09:51:17 +05302126#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2127 chan_no = pRoamInfo->pBssDesc->channelId;
Jeff Johnson81c17882013-05-03 09:53:35 -07002128
Anand N Sunkadfec40682015-07-29 09:51:17 +05302129 if (chan_no <= 14)
2130 freq = ieee80211_channel_to_frequency(chan_no,
2131 IEEE80211_BAND_2GHZ);
2132 else
2133 freq = ieee80211_channel_to_frequency(chan_no,
2134 IEEE80211_BAND_5GHZ);
2135
2136 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
2137
2138 if (chan)
2139 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
2140 chan, GFP_KERNEL);
2141 else
2142 hddLog(LOGE, FL("%s: chanId: %d, can't find channel"),
2143 pAdapter->dev->name,
2144 (int)pRoamInfo->pBssDesc->channelId);
2145#else
Jeff Johnson81c17882013-05-03 09:53:35 -07002146 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302147#endif
Yue Maf49ba872013-08-19 12:04:25 -07002148 cfg80211_put_bss(
2149#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2150 pHddCtx->wiphy,
2151#endif
2152 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07002153 }
Katya Nigam47528772015-02-11 12:24:49 +05302154 else
2155 {
2156 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2157 "%s: NULL Bss Desc",__func__);
2158 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05302159
2160 /* Set Broadcast key again in case IBSS_COALESCED as DEL BSS,
2161 * in IBSS_COALESCED will remove the BC key.
2162 */
2163 if ((eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) &&
2164 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY
2165 == pHddStaCtx->ibss_enc_key.encType
2166 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY
2167 == pHddStaCtx->ibss_enc_key.encType
2168 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2169 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType ))
2170 {
2171 u8 grpmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2172 VOS_STATUS vosStatus;
2173
2174 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2175
2176 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2177 grpmacaddr, WNI_CFG_BSSID_LEN);
2178 hddLog(VOS_TRACE_LEVEL_INFO,
2179 FL(" SET GTK in case of COALESCED"));
2180 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2181 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2182 if ( VOS_STATUS_SUCCESS != vosStatus )
2183 {
2184 hddLog(VOS_TRACE_LEVEL_ERROR,
2185 FL("sme_RoamSetKey failed, returned %d"),vosStatus);
2186 }
2187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002188 break;
2189 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002190
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
2192 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002193 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
2194 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07002195 break;
2196 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002197
Jeff Johnson295189b2012-06-20 16:38:30 -07002198 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07002199 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
2200 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002202 }
2203
Jeff Johnson81c17882013-05-03 09:53:35 -07002204 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002205}
2206
2207/**============================================================================
2208 *
2209 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
2210 This information is passed to iwconfig later. The peer that joined
2211 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002212 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002213 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002214
Jeff Johnson295189b2012-06-20 16:38:30 -07002215 ===========================================================================*/
Nirav Shah7e3c8132015-06-22 23:51:42 +05302216static int roamSaveIbssStation(hdd_adapter_t *pAdapter, v_U8_t staId, v_MACADDR_t *peerMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07002217{
2218 int fSuccess = FALSE;
2219 int idx = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302220 VOS_STATUS status;
2221 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002222
Jeff Johnson295189b2012-06-20 16:38:30 -07002223 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2224 {
2225 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
2226 {
2227 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002228
Jeff Johnson295189b2012-06-20 16:38:30 -07002229 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002230
Jeff Johnson295189b2012-06-20 16:38:30 -07002231 fSuccess = TRUE;
2232 break;
2233 }
2234 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002235
Nirav Shah7e3c8132015-06-22 23:51:42 +05302236 status = hdd_sta_id_hash_add_entry(pAdapter, staId, peerMacAddress);
2237 if (status != VOS_STATUS_SUCCESS) {
2238 hddLog(VOS_TRACE_LEVEL_ERROR,
2239 FL("Not able to add staid hash %d"), staId);
2240 return FALSE;
2241 }
2242
2243 hddLog(VOS_TRACE_LEVEL_INFO,
2244 FL("New station added sta_id %d mac:"
2245 MAC_ADDRESS_STR), staId,
2246 MAC_ADDR_ARRAY(peerMacAddress->bytes));
2247
Shailender Karmuchia734f332013-04-19 14:02:48 -07002248 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07002249}
2250/**============================================================================
2251 *
2252 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002253 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002254 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002255
Jeff Johnson295189b2012-06-20 16:38:30 -07002256 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07002257static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07002258{
2259 int fSuccess = FALSE;
2260 int idx = 0;
2261 v_U8_t valid_idx = 0;
2262 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07002263 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002264 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Nirav Shah7e3c8132015-06-22 23:51:42 +05302265 VOS_STATUS status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002266
Jeff Johnson295189b2012-06-20 16:38:30 -07002267 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2268 {
2269 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
2270 {
2271 pHddStaCtx->conn_info.staId[ idx ] = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302272 status = hdd_sta_id_hash_remove_entry(pAdapter,
2273 staId, &pHddStaCtx->conn_info.peerMacAddress[idx]);
2274 if (status != VOS_STATUS_SUCCESS) {
2275 hddLog(VOS_TRACE_LEVEL_ERROR,
2276 FL("Not able to remove staid hash %d"), staId );
2277 fSuccess = FALSE;
2278 } else {
2279 hddLog(VOS_TRACE_LEVEL_INFO,
2280 FL("station removed sta_id %d mac:"
2281 MAC_ADDRESS_STR), staId,
2282 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[idx].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07002283
Nirav Shah7e3c8132015-06-22 23:51:42 +05302284 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002285
Nirav Shah7e3c8132015-06-22 23:51:42 +05302286 fSuccess = TRUE;
2287 // Note the deleted Index, if its 0 we need special handling
2288 del_idx = idx;
2289 empty_slots++;
2290 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002291 }
2292 else
2293 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002294 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002295 {
2296 valid_idx = idx;
2297 }
Ravi Joshi8a934352013-09-25 16:46:58 -07002298 else
2299 {
2300 // Found an empty slot
2301 empty_slots++;
2302 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 }
2304 }
2305
Ravi Joshi8a934352013-09-25 16:46:58 -07002306 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
2307 {
2308 // Last peer departed, set the IBSS state appropriately
2309 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002310 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07002311 "Last IBSS Peer Departed!!!" );
2312 }
2313
Jeff Johnson295189b2012-06-20 16:38:30 -07002314 // Find next active staId, to have a valid sta trigger for TL.
2315 if (fSuccess == TRUE)
2316 {
2317 if (del_idx == 0)
2318 {
2319 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
2320 {
2321 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
2322 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
2323 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
2324
2325 pHddStaCtx->conn_info.staId[valid_idx] = 0;
2326 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
2327 }
2328 }
2329 }
2330 return( fSuccess );
2331}
2332
2333/**============================================================================
2334 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002335 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07002336 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002337
Jeff Johnson295189b2012-06-20 16:38:30 -07002338 ===========================================================================*/
2339static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
2340{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002341 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05302342 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2343 "%s: IBSS Connect Indication from SME!!! "
2344 "Set HDD connState to eConnectionState_IbssConnected",
2345 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002346 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
2347 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
2348
2349 // Save the connection info from CSR...
2350 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
2351
2352 // Send the bssid address to the wext.
2353 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002354 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002355 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2356 if (NULL == bss)
2357 {
2358 hddLog(VOS_TRACE_LEVEL_ERROR,
2359 "%s: %s: unable to create IBSS entry",
2360 __func__, pAdapter->dev->name);
2361 return eHAL_STATUS_FAILURE;
2362 }
Yue Maf49ba872013-08-19 12:04:25 -07002363 cfg80211_put_bss(
2364#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2365 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
2366#endif
2367 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07002368
2369 return( eHAL_STATUS_SUCCESS );
2370}
2371/**============================================================================
2372 *
Mukul Sharmad2589a52014-04-23 21:06:25 +05302373 @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
2374 suspend related data which was cleared during roaming in FWR.
2375
2376 ===========================================================================*/
2377static void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
2378{
2379 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
2380 hdd_adapter_t *pAdapter;
2381 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
2382 ENTER();
2383
2384 spin_lock(&pHddCtx->filter_lock);
2385 if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
2386 {
2387 pHddCtx->sus_res_mcastbcast_filter =
2388 pHddCtx->configuredMcastBcastFilter;
2389 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
2390 hddLog(VOS_TRACE_LEVEL_INFO, FL("offload: callback to associated"));
2391 hddLog(VOS_TRACE_LEVEL_INFO,
2392 FL("saving configuredMcastBcastFilter = %d"),
2393 pHddCtx->configuredMcastBcastFilter);
2394 hddLog(VOS_TRACE_LEVEL_INFO,
2395 FL("offload: calling hdd_conf_mcastbcast_filter"));
2396 }
2397 spin_unlock(&pHddCtx->filter_lock);
2398
2399 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
2400 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
2401 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
2402
2403 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
2404 //No need to configure GTK Offload from here because it might possible
2405 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
2406 //be handled as part of cfg80211_set_rekey_data processing.
2407 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
2408 {
2409 pAdapter = pAdapterNode->pAdapter;
2410 if( pAdapter &&
2411 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
2412 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
2413 {
2414 if (pHddCtx->cfg_ini->fhostArpOffload)
2415 {
2416 //Configure ARPOFFLOAD
2417 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
2418 if (!VOS_IS_STATUS_SUCCESS(vstatus))
2419 {
2420 hddLog(VOS_TRACE_LEVEL_ERROR,
2421 FL("Failed to disable ARPOffload Feature %d"), vstatus);
2422 }
2423 }
2424#ifdef WLAN_NS_OFFLOAD
2425 //Configure NSOFFLOAD
2426 if (pHddCtx->cfg_ini->fhostNSOffload)
2427 {
2428 hdd_conf_ns_offload(pAdapter, TRUE);
2429 }
2430#endif
Mukul Sharma25e70c32014-05-22 12:50:24 +05302431#ifdef WLAN_FEATURE_PACKET_FILTERING
2432 /* During suspend, configure MC Addr list filter to the firmware
2433 * function takes care of checking necessary conditions before
2434 * configuring.
2435 */
2436 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
2437#endif
Mukul Sharmad2589a52014-04-23 21:06:25 +05302438 }
2439 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2440 pAdapterNode = pNext;
2441 }
2442 EXIT();
2443}
2444
2445/**============================================================================
2446 *
Jeff Johnson295189b2012-06-20 16:38:30 -07002447 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002448
Jeff Johnson295189b2012-06-20 16:38:30 -07002449 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002450static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2451 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 eCsrRoamResult roamResult )
2453{
2454 eCsrEncryptionType connectedCipherAlgo;
2455 v_BOOL_t fConnected = FALSE;
2456 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2457 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Bhargav Shaha805ef22015-07-29 17:31:38 +05302458 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002459 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302460 WLANTL_STAStateType prevTLState = WLANTL_STA_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07002461 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07002462
2463 if (NULL == pRoamInfo)
2464 {
2465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
2466 return eHAL_STATUS_FAILURE;
2467 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002468 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002469 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07002470 // not require upper layer authentication) we can put TL directly into 'authenticated'
2471 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002472 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2473 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
2474 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002475
Jeff Johnson295189b2012-06-20 16:38:30 -07002476 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2477 if( fConnected )
2478 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002479 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
2480 {
2481 v_U8_t staId;
2482
2483 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2484
2485 if ( 0 == memcmp( pRoamInfo->peerMac,
2486 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
2487 {
2488 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2489 IBSS_BROADCAST_STAID);
Abhishek Singhb25e8442015-06-23 14:28:05 +05302490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2491 "WLAN TL STA GTK Installed for STAID=%d", IBSS_BROADCAST_STAID);
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002492 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2493 }
2494 else
2495 {
2496 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
2497 (v_MACADDR_t*)pRoamInfo->peerMac,
2498 &staId);
2499 if ( VOS_STATUS_SUCCESS == vosStatus )
2500 {
2501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2502 "WLAN TL STA Ptk Installed for STAID=%d", staId);
2503 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2504 staId);
2505 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2506 }
2507 }
2508 }
2509 else
2510 {
Bhargav Shaha805ef22015-07-29 17:31:38 +05302511 WLANTL_GetSTAState(pHddCtx->pvosContext,
2512 pHddStaCtx->conn_info.staId[0],
2513 &prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302514 // TODO: Considering getting a state machine in HDD later.
2515 // This routine is invoked twice. 1)set PTK 2)set GTK.
2516 // The folloing if statement will be TRUE when setting GTK.
2517 // At this time we don't handle the state in detail.
2518 // Related CR: 174048 - TL not in authenticated state
2519 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
2520 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
2521 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302522
2523 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
2524 "for StaId=%d. Changing TL state to AUTHENTICATED from"
2525 " state:%d", pHddStaCtx->conn_info.staId[0], prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302526
2527 // Connections that do not need Upper layer authentication,
2528 // transition TL to 'Authenticated' state after the keys are set.
2529 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2530 pHddStaCtx->conn_info.staId[ 0 ],
2531 WLANTL_STA_AUTHENTICATED );
2532
2533 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302534
2535 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2536 hdd_postTLPacketPendingInd(pAdapter,
2537 pHddStaCtx->conn_info.staId[0]);
Mukul Sharmad2589a52014-04-23 21:06:25 +05302538 //Need to call offload because when roaming happen at that time fwr
2539 //clean offload info as part of the DelBss
2540 // No need to configure offload if host was not suspended
2541 spin_lock(&pHddCtx->filter_lock);
2542 if(pHddCtx->hdd_wlan_suspended)
2543 {
2544 spin_unlock(&pHddCtx->filter_lock);
2545 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
2546 }
2547 else
2548 {
2549 spin_unlock(&pHddCtx->filter_lock);
2550 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302551 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2552 {
2553 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
2554 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302555 }
2556 else
2557 {
2558 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2559 pHddStaCtx->conn_info.staId[ 0 ]);
Bhargav Shaha805ef22015-07-29 17:31:38 +05302560
2561 /* In case of OSEN move TL to 'Authenticated' after PTK is set */
2562 if (pWextState->roamProfile.bOSENAssociation == VOS_TRUE)
2563 {
2564 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "PTK set"
2565 " for StaId=%d. Due to OSEN, Changing TL state to"
2566 "AUTHENTICATED from state:%d",
2567 pHddStaCtx->conn_info.staId[0], prevTLState);
2568
2569 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2570 pHddStaCtx->conn_info.staId[ 0 ],
2571 WLANTL_STA_AUTHENTICATED );
2572
2573 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
2574
2575 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2576 hdd_postTLPacketPendingInd(pAdapter,
2577 pHddStaCtx->conn_info.staId[0]);
2578 }
2579
2580
2581
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302582 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2583 {
2584 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
2585 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302586 }
2587
2588 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302591 else
2592 {
2593 // possible disassoc after issuing set key and waiting set key complete
2594 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2595 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002596
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 EXIT();
2598 return( eHAL_STATUS_SUCCESS );
2599}
2600/**============================================================================
2601 *
2602 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2603 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002604static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002605 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002606{
Jeff Johnson295189b2012-06-20 16:38:30 -07002607 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2608
2609 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2610 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2611 {
2612 struct iw_michaelmicfailure msg;
2613 union iwreq_data wreq;
2614 memset(&msg, '\0', sizeof(msg));
2615 msg.src_addr.sa_family = ARPHRD_ETHER;
2616 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002617 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2618 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002619
Jeff Johnson295189b2012-06-20 16:38:30 -07002620 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2621 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002622 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 msg.flags = IW_MICFAILURE_PAIRWISE;
2624 memset(&wreq, 0, sizeof(wreq));
2625 wreq.data.length = sizeof(msg);
2626 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002627 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002628 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002629 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2630 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2631 NL80211_KEYTYPE_GROUP :
2632 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002633 pRoamInfo->u.pMICFailureInfo->keyId,
2634 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002635 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002636
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002638
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 return( eHAL_STATUS_SUCCESS );
2640}
2641
2642/**============================================================================
2643 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002644 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002646
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002648static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2649 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002650 eCsrRoamResult roamResult )
2651{
2652 VOS_STATUS vosStatus;
2653
2654 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2655 switch( roamResult )
2656 {
2657 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2658 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002659 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002660 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002661
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002662 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002663 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2664 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2665 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002666 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002667
Nirav Shah7e3c8132015-06-22 23:51:42 +05302668 if ( !roamSaveIbssStation( pAdapter, pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002669 {
2670 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2671 "New IBSS peer but we already have the max we can handle. Can't register this one" );
2672 break;
2673 }
2674
2675 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2676
Shailender Karmuchia734f332013-04-19 14:02:48 -07002677 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2678 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2679 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2680
2681 // Register the Station with TL for the new peer.
Katya Nigam47528772015-02-11 12:24:49 +05302682 vosStatus = hdd_ibss_RegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 pRoamInfo,
2684 pRoamInfo->staId,
2685 (v_MACADDR_t *)pRoamInfo->peerMac,
2686 pRoamInfo->pBssDesc );
2687 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2688 {
2689 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002690 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002691 vosStatus, vosStatus );
2692 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002693 pHddStaCtx->ibss_sta_generation++;
2694 memset(&staInfo, 0, sizeof(staInfo));
2695 staInfo.filled = 0;
2696 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2697
2698 cfg80211_new_sta(pAdapter->dev,
2699 (const u8 *)pRoamInfo->peerMac,
2700 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002701
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002702 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2703 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2704 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2705 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2706 {
2707 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302708
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002709 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2710 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2711
2712 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002713 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002714 pHddStaCtx->ibss_enc_key.encType);
2715
2716 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2717 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2718
2719 if ( VOS_STATUS_SUCCESS != vosStatus )
2720 {
2721 hddLog(VOS_TRACE_LEVEL_ERROR,
2722 "%s: sme_RoamSetKey failed, returned %d",
2723 __func__, vosStatus);
2724 return VOS_STATUS_E_FAILURE;
2725 }
2726 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 netif_carrier_on(pAdapter->dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302728 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002729 netif_tx_start_all_queues(pAdapter->dev);
2730 break;
2731 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002732
Jeff Johnson295189b2012-06-20 16:38:30 -07002733 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2734 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002735
Jeff Johnson295189b2012-06-20 16:38:30 -07002736 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002737
Jeff Johnson295189b2012-06-20 16:38:30 -07002738 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002739 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2741 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002742 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002743
Ravi Joshicc57ed42013-10-12 16:31:25 -07002744 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002745 {
2746 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2747 "IBSS peer departed by cannot find peer in our registration table with TL" );
2748 }
2749
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002750 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002751 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2752 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2753 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2754 pRoamInfo->staId );
2755
Katya Nigam47528772015-02-11 12:24:49 +05302756 hdd_ibss_DeregisterSTA( pAdapter, pRoamInfo->staId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002757
2758 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002759 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002760
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002761 cfg80211_del_sta(pAdapter->dev,
2762 (const u8 *)&pRoamInfo->peerMac,
2763 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002764 break;
2765 }
2766 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2767 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002768 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2769 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 // Stop only when we are inactive
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302771 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002772 netif_tx_disable(pAdapter->dev);
2773 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05302774 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2775 "%s: Set HDD connState to eConnectionState_NotConnected",
2776 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002777 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002778
Jeff Johnson295189b2012-06-20 16:38:30 -07002779 // Send the bssid address to the wext.
2780 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2781 // clean up data path
2782 hdd_disconnect_tx_rx(pAdapter);
2783 break;
2784 }
2785 default:
2786 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002787
Jeff Johnson295189b2012-06-20 16:38:30 -07002788 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002789
Jeff Johnson295189b2012-06-20 16:38:30 -07002790 return( eHAL_STATUS_SUCCESS );
2791}
2792
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002793#ifdef FEATURE_WLAN_TDLS
2794/**============================================================================
2795 *
2796 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2797 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2798 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002799
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002800 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002801VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
2802 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002803{
2804 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002805 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002806 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2807 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002808 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2809 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002810 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2811 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002812
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002813 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2814 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002815 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002816 "%s not connected. ignored", __func__);
2817 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002818 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002819
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002820 /*
2821 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2822 * be peer MAC, here we are wokrking on direct Link
2823 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002824 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002825
2826 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002827
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002828 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002829 sizeof(tSirMacAddr) );
2830
2831 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2832 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2833
2834 /* set the QoS field appropriately ..*/
2835 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2836 : (staDesc.ucQosEnabled = 0) ;
2837
2838 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002839 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002840
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002841 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002842
2843 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002844 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002845
Shailender Karmuchia734f332013-04-19 14:02:48 -07002846 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002847 * UMA is ready we inform TL to do frame translation.
2848 */
2849 staDesc.ucSwFrameTXXlation = 1;
2850 staDesc.ucSwFrameRXXlation = 1;
2851 staDesc.ucAddRmvLLC = 1;
2852
2853 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002854 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002855
2856 /* tdls Direct Link do not need bcastSig */
2857 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002858
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002859#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2860 if(staDesc.ucProtectedFrame)
2861 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2862 else
2863 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2864#endif
2865
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302866 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002867
Shailender Karmuchia734f332013-04-19 14:02:48 -07002868 /* Register the Station with TL... */
2869 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2870 hdd_rx_packet_cbk,
2871 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002872 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002873
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002874 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2875 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002876 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002877 "%s: WLANTL_RegisterSTAClient() failed to register. "
2878 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002879 return vosStatus;
2880 }
2881
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002882 if ( cfg_param->dynSplitscan &&
2883 ( VOS_TIMER_STATE_RUNNING !=
2884 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2885 {
2886 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2887 cfg_param->trafficMntrTmrForSplitScan);
2888 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002889 return( vosStatus );
2890}
2891
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05302892VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002893{
2894 VOS_STATUS vosStatus;
2895 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2896 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2897 {
2898 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2899 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002900 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002901 __func__, staId, vosStatus, vosStatus );
2902 }
2903 return( vosStatus );
2904}
2905
2906
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002907/*
2908 * HDD interface between SME and TL to ensure TDLS client registration with
2909 * TL in case of new TDLS client is added and deregistration at the time
2910 * TDLS client is deleted.
2911 */
2912
Shailender Karmuchia734f332013-04-19 14:02:48 -07002913eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2914 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002915 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002916 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002917 eCsrRoamResult roamResult)
2918{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002919 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002920 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002921 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002922
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302923 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002924 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2925 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2926 "ADD_TDLS_PEER" :
2927 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2928 "DEL_TDLS_PEER" :
2929 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2930 "DEL_TDLS_PEER_IND" :
2931 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2932 "DEL_ALL_TDLS_PEER_IND" :
2933 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2934 "UPDATE_TDLS_PEER" :
2935 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2936 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2937 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002938 switch( roamResult )
2939 {
2940 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2941 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002942 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2943 {
2944 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002945 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002946 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002947 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002948 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002949
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002950 /* check if there is available index for this new TDLS STA */
2951 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2952 {
2953 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2954 {
2955 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2956 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2957
2958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002959 ("TDLS: STA IDX at %d is %d "
2960 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002961 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002962 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002963
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002964 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002965 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2966 status = eHAL_STATUS_SUCCESS ;
2967 break ;
2968 }
2969 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002970 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002971 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002972 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002973 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2974 "wlan_hdd_tdls_set_sta_id() failed");
2975 return VOS_FALSE;
2976 }
2977
2978 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302979 /* store the ucast signature , if required for further reference. */
2980
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002981 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302982 /* start TDLS client registration with TL */
2983 status = hdd_roamRegisterTDLSSTA( pAdapter,
2984 pRoamInfo->peerMac,
2985 pRoamInfo->staId,
2986 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05302987 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002988 }
2989 else
2990 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002991 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002992 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002993 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002994 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002995 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002996 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002997 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002998 break ;
2999 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003000 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3001 {
3002 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3003 {
3004 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3005 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
3006 }
3007 /* store the ucast signature which will be used later when
3008 * registering to TL
3009 */
3010 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3011 complete(&pAdapter->tdls_add_station_comp);
3012 break;
3013 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303014 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3015 {
3016 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3017 {
3018 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3019 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
3020 }
3021 complete(&pAdapter->tdls_link_establish_req_comp);
3022 break;
3023 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003024 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003025 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003026 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003027 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003028 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003029 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3030 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003031 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003032 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003033 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
3034
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303035 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303036 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003037 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303038 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3039 " Current status for peer" MAC_ADDRESS_STR "is %d",
3040 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303041 if (TDLS_IS_CONNECTED(curr_peer) ||
3042 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303043 {
3044 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
3045 }
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303046 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003047 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003048 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003049
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003050 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3051 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
3052 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003053 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003054 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003055 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003056 break ;
3057 }
3058 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003059 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003060 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003061 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003062 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3063 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003064 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003065 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3066 "%s: Sending teardown to supplicant with reason code %u",
3067 __func__, pRoamInfo->reasonCode);
3068
3069#ifdef CONFIG_TDLS_IMPLICIT
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303070 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003071 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003072#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003073 status = eHAL_STATUS_SUCCESS ;
3074 break ;
3075 }
3076 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3077 {
3078 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003079 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003080 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003081 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3082 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003083 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003084 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003085 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003086 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003087 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003088 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
3089 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3090 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003091
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003092 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003093 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003094 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3095 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003096
3097 status = eHAL_STATUS_SUCCESS ;
3098 }
3099 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303100 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003101 break ;
3102 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003103 default:
3104 {
3105 break ;
3106 }
3107 }
3108
3109 return status ;
3110}
3111#endif
3112
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003113static void iw_full_power_cbfn (void *pContext, eHalStatus status)
3114{
3115 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3116 hdd_context_t *pHddCtx = NULL;
3117 int ret;
3118
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303119 ENTER();
3120
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003121 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3122 {
3123 hddLog(VOS_TRACE_LEVEL_ERROR,
3124 "%s: Bad param, pAdapter [%p]",
3125 __func__, pAdapter);
3126 return;
3127 }
3128
3129 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3130 ret = wlan_hdd_validate_context(pHddCtx);
3131 if (0 != ret)
3132 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003133 return;
3134 }
3135
3136 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3137 {
3138 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
3139 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303140
3141 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003142}
3143
Shailender Karmuchia734f332013-04-19 14:02:48 -07003144eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
3146{
3147 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
3148 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303149 hdd_wext_state_t *pWextState = NULL;
3150 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003151 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07003152 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003153
3154 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003155 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003156 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003157
3158 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303159 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003160 {
3161 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303162 "invalid adapter or adapter has invalid magic");
3163 return eHAL_STATUS_FAILURE;
3164 }
3165
3166 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3167 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3168
3169 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3170 {
3171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3172 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003173 return eHAL_STATUS_FAILURE;
3174 }
3175
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05303176
3177 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
3178 pAdapter->sessionId, roamStatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003179 switch( roamStatus )
3180 {
3181 case eCSR_ROAM_SESSION_OPENED:
3182 if(pAdapter != NULL)
3183 {
3184 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
3185 complete(&pAdapter->session_open_comp_var);
3186 }
3187 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003188
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003189#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
3190 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07003192 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 * interface down */
3194 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303195 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
3196 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05303197 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003198 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3199 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
3200 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3202 }
3203 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05303204 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 break;
3206
3207 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003208 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07003209 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07003210 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 // eCSR_ROAM_SHOULD_ROAM will be received.
3212 // Where in we will not mark the link down
3213 // Also we want to stop tx at this point when we will be
3214 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003215 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 {
3217 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303218 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303220 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3221 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3222 {
3223 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
3224 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003225 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303226 * Deregister this STA with TL, but do not flush the packets
3227 * for this STA from wmm_tx_queue. Since there is no valid STA
3228 * for these packets they will not be transmitted. Eventually
3229 * after the reassociation is successful, these packets will be
3230 * transmitted after registering STA with TL again. This ensures
3231 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003232 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303233 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
3234 pHddStaCtx->conn_info.staId[0]);
3235 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003236 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303237 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3238 FL("WLANTL_ClearSTAClient failed for staID %d."
3239 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
3240 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003241 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003242 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003243 }
3244 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003245 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003246 break;
3247#endif
3248
3249 case eCSR_ROAM_SHOULD_ROAM:
3250 // Dont need to do anything
3251 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 struct net_device *dev = pAdapter->dev;
3253 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3254 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303255 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003257#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 if (pHddStaCtx->ft_carrier_on == FALSE)
3259 {
3260#endif
3261 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003262#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003263 }
3264#endif
3265
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003266#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07003267 //We should clear all sta register with TL, for now, only one.
3268 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
3269 if ( !VOS_IS_STATUS_SUCCESS(status ) )
3270 {
3271 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3272 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
3273 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003274 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003275 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003276#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 }
3278 break;
3279 case eCSR_ROAM_LOSTLINK:
3280 case eCSR_ROAM_DISASSOCIATED:
3281 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3283 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05303284 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003285 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3286 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07003287 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3288 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303289 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07003290 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08003291
3292 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
3293 pHddCtx->configuredMcastBcastFilter =
3294 pHddCtx->sus_res_mcastbcast_filter;
3295 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
3296 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303297
Amar Singhald53568e2013-09-26 11:03:45 -07003298 hddLog(VOS_TRACE_LEVEL_INFO,
3299 "offload: disassociation happening, restoring configuredMcastBcastFilter");
3300 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
3301 pHddCtx->configuredMcastBcastFilter);
3302 hddLog(VOS_TRACE_LEVEL_INFO,
3303 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3305 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003306#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303307 /* Call to clear any MC Addr List filter applied after
3308 * successful connection.
3309 */
3310 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003311#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003312 }
3313 break;
3314 case eCSR_ROAM_IBSS_LEAVE:
3315 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3316 "****eCSR_ROAM_IBSS_LEAVE****");
3317 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3318 break;
3319 case eCSR_ROAM_ASSOCIATION_COMPLETION:
3320 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3321 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303322 // To Do - address probable memory leak with WEP encryption upon successful association
3323 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303325 //Clear saved connection information in HDD
3326 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003327 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303328 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003329
3330 break;
3331 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003332 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003333 pRoamInfo, roamId, roamStatus, roamResult );
3334 break;
3335 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07003336 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
3337 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003338 break;
3339
3340 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
3341 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003342 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003343
3344 case eCSR_ROAM_MIC_ERROR_IND:
3345 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3346 break;
3347
3348 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003349 {
3350 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
3351
3352 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003353 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
3354 (TRUE == pHddCtx->hdd_wlan_suspended) &&
3355 (eCSR_ROAM_RESULT_NONE == roamResult))
3356 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003357 /* Send DTIM period to the FW; only if the wlan is already
3358 in suspend. This is the case with roaming (reassoc),
3359 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
3360 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
3361 before the ENTER_BMPS_REQ ensures Listen Interval is
3362 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003363 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003364
3365 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003366 if due to unexpected scenario, if we are in BMPS,
3367 then trigger Exit and Enter BMPS to take DTIM period
3368 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003369 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
3370 {
3371 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
3372
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003373 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3374 iw_full_power_cbfn, pAdapter,
3375 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003376 }
3377 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303378
3379 if ((pHddCtx) &&
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303380 (FULL_POWER == pmcGetPmcState(pHddCtx->hHal)) &&
3381 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
3382 (eCSR_ROAM_RESULT_NONE == roamResult))
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303383 {
3384 hddLog( LOG1, FL("Device in full power."
3385 "Stop and start traffic timer for roaming"));
3386 pmcStopTrafficTimer(pHddCtx->hHal);
3387 if (pmcStartTrafficTimer(pHddCtx->hHal,
3388 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
3389 {
3390 hddLog(LOGP, FL("Cannot start traffic timer"));
3391 }
3392 }
3393
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003394 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05303395 if (eCSR_ROAM_RESULT_NONE == roamResult)
3396 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003397 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003398 break;
3399#ifdef WLAN_FEATURE_VOWIFI_11R
3400 case eCSR_ROAM_FT_RESPONSE:
3401 hdd_SendFTEvent(pAdapter);
3402 break;
3403#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07003404#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003405 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003406 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07003407 {
3408 /* Notify the supplicant of a new candidate */
3409 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
3410 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003411 break;
3412#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003413
Yue Maef608272013-04-08 23:09:17 -07003414#ifdef FEATURE_WLAN_LFR_METRICS
3415 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
3416 /* This event is to notify pre-auth initiation */
3417 if (VOS_STATUS_SUCCESS !=
3418 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
3419 {
3420 halStatus = eHAL_STATUS_FAILURE;
3421 }
3422 break;
3423 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
3424 /* This event will notify pre-auth completion in case of success */
3425 if (VOS_STATUS_SUCCESS !=
3426 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3427 pRoamInfo, 1))
3428 {
3429 halStatus = eHAL_STATUS_FAILURE;
3430 }
3431 break;
3432 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
3433 /* This event will notify pre-auth completion in case of failure. */
3434 if (VOS_STATUS_SUCCESS !=
3435 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3436 pRoamInfo, 0))
3437 {
3438 halStatus = eHAL_STATUS_FAILURE;
3439 }
3440 break;
3441 case eCSR_ROAM_HANDOVER_SUCCESS:
3442 /* This event is to notify handover success.
3443 It will be only invoked on success */
3444 if (VOS_STATUS_SUCCESS !=
3445 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
3446 {
3447 halStatus = eHAL_STATUS_FAILURE;
3448 }
3449 break;
3450#endif
3451
Jeff Johnson295189b2012-06-20 16:38:30 -07003452 case eCSR_ROAM_INDICATE_MGMT_FRAME:
3453 hdd_indicateMgmtFrame( pAdapter,
3454 pRoamInfo->nFrameLength,
3455 pRoamInfo->pbFrames,
3456 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05303457 pRoamInfo->rxChan,
3458 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07003459 break;
3460 case eCSR_ROAM_REMAIN_CHAN_READY:
3461 hdd_remainChanReadyHandler( pAdapter );
3462 break;
3463 case eCSR_ROAM_SEND_ACTION_CNF:
3464 hdd_sendActionCnf( pAdapter,
3465 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
3466 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003467#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08003468 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003469 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08003470 roamId, roamStatus, roamResult );
3471 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003472 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
3473 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
3474 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003475#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003476#ifdef WLAN_FEATURE_11W
3477 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
3478 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
3479 pRoamInfo->pbFrames,
3480 pRoamInfo->frameType);
3481 break;
3482#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003483#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003484 case eCSR_ROAM_TSM_IE_IND:
3485 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
3486 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
3487 break;
3488
3489 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
3490 {
3491 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
3492 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
3493 {
3494 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
3495 }
3496 break;
3497 }
3498
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003499 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003500 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003501 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003502 break;
3503 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003504
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003505 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003506 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003507 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003508 break;
3509 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003510#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05303511 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
3512 {
3513 pAdapter->maxRateFlags = roamResult;
3514 break;
3515 }
3516 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07003517 break;
3518 }
3519 return( halStatus );
3520}
Shailender Karmuchia734f332013-04-19 14:02:48 -07003521eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003522{
3523 eCsrAuthType auth_type;
3524 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003525 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003526 {
3527 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003528 } else
3529 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 {
3531 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003532 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003533#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003534 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003535 {
3536 // Check for 11r FT Authentication with PSK
3537 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003538 } else
3539 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003540 {
3541 // Check for 11R FT Authentication with 802.1X
3542 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003543 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003544#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003545#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003546 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003547 {
3548 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
3549 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003550#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07003551#ifdef WLAN_FEATURE_11W
3552 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
3553 {
3554 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3555 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303556 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
3557 {
3558 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3559 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003560#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003561 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3563 }
3564 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003565}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003566
Shailender Karmuchia734f332013-04-19 14:02:48 -07003567eCsrAuthType
3568hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003569{
3570 eCsrAuthType auth_type;
3571 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003572 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 {
3574 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003575 } else
3576 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003577 {
3578 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003579 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003580#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003581 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003582 {
3583 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003584 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003585#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003586 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3588 }
3589 hddLog(LOG1, FL("auth_type: %d"), auth_type);
3590 return auth_type;
3591}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003592
Shailender Karmuchia734f332013-04-19 14:02:48 -07003593eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003594hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003595{
3596 eCsrEncryptionType cipher_type;
3597 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003598 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 {
3600 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003601 }
3602 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003603 {
3604 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003605 }
3606 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003607 {
3608 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003609 }
3610 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003611 {
3612 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003613 }
3614 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
3615 {
3616 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3617 }
3618 else
3619 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003620 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3621 }
3622 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3623 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003624}
Jeff Johnson295189b2012-06-20 16:38:30 -07003625/* To find if the MAC address is NULL */
3626static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3627{
3628 int i;
3629 for (i = 0; i < length; i++)
3630 {
3631 if (0x00 != (macAddr[i]))
3632 {
3633 return FALSE;
3634 }
3635 }
3636 return TRUE;
3637} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003638
Shailender Karmuchia734f332013-04-19 14:02:48 -07003639eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003640hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003641{
3642 eCsrEncryptionType cipher_type;
3643 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003644 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 {
3646 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003647 } else
3648 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 {
3650 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003651 } else
3652 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003653 {
3654 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003655 } else
3656 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003657 {
3658 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003659 } else
3660 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003661 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003662 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3663 } else
3664 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003665 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3666 }
3667 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3668 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003669}
Jeff Johnson295189b2012-06-20 16:38:30 -07003670
Shailender Karmuchia734f332013-04-19 14:02:48 -07003671static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3672 struct ether_addr *pBssid,
3673 eCsrEncryptionType *pEncryptType,
3674 eCsrEncryptionType *mcEncryptType,
3675 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003676#ifdef WLAN_FEATURE_11W
3677 u_int8_t *pMfpRequired,
3678 u_int8_t *pMfpCapable,
3679#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003680 u_int16_t gen_ie_len,
3681 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003682{
3683 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003684 eHalStatus result;
3685 tDot11fIERSN dot11RSNIE;
3686 tDot11fIEWPA dot11WPAIE;
3687 tANI_U32 i;
3688 tANI_U8 *pRsnIe;
3689 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003690 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003691 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003692
3693 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3694 flag to 0 */
3695 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3696 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3697
Jeff Johnson295189b2012-06-20 16:38:30 -07003698 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003699 if ( gen_ie[0] == DOT11F_EID_RSN)
3700 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003702 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3704 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303705 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3706 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 return -EINVAL;
3708 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003709 // Skip past the EID byte and length byte
3710 pRsnIe = gen_ie + 2;
3711 RSNIeLen = gen_ie_len - 2;
3712 // Unpack the RSN IE
3713 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3714 pRsnIe,
3715 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003716 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003717 // Copy out the encryption and authentication types
3718 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003719 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003720 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003721 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003722 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003723 but probably I suspect we can do something different*/
3724 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003725 // Just translate the FIRST one
3726 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3727 //dot11RSNIE.pwise_cipher_suite_count
3728 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3729 //dot11RSNIE.gp_cipher_suite_count
3730 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003731#ifdef WLAN_FEATURE_11W
3732 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3733 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3734#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003736 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003737 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003738 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003739 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303740 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 break;
3742 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003743 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303745 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003746 break;
3747 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003748 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 // For right now, I assume setASSOCIATE() has passed in the bssid.
3750 vos_mem_copy(PMKIDCache[i].BSSID,
3751 pBssid, ETHER_ADDR_LEN);
3752 vos_mem_copy(PMKIDCache[i].PMKID,
3753 dot11RSNIE.pmkid[i],
3754 CSR_RSN_PMKID_SIZE);
3755 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003756
3757 if (updatePMKCache)
3758 {
3759 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003760 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003761 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003762 // Finally set the PMKSA ID Cache in CSR
3763 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3764 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05303765 dot11RSNIE.pmkid_count,
3766 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07003767 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003768 }
3769 else if (gen_ie[0] == DOT11F_EID_WPA)
3770 {
3771 // Validity checks
3772 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3773 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3774 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303775 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3776 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003777 return -EINVAL;
3778 }
3779 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003780 pRsnIe = gen_ie + 2 + 4;
3781 RSNIeLen = gen_ie_len - (2 + 4);
3782 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003783 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3784 pRsnIe,
3785 RSNIeLen,
3786 &dot11WPAIE);
3787 // Copy out the encryption and authentication types
3788 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003789 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003791 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003792 //dot11WPAIE.auth_suite_count
3793 // Just translate the FIRST one
3794 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3795 //dot11WPAIE.unicast_cipher_count
3796 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3797 //dot11WPAIE.unicast_cipher_count
3798 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3799 }
3800 else
3801 {
3802 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003803 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003804 }
3805 return 0;
3806}
3807int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3808{
3809 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3810 v_U32_t status = 0;
3811 eCsrEncryptionType RSNEncryptType;
3812 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003813#ifdef WLAN_FEATURE_11W
3814 u_int8_t RSNMfpRequired;
3815 u_int8_t RSNMfpCapable;
3816#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003817 struct ether_addr bSsid; // MAC address of assoc peer
3818 // MAC address of assoc peer
3819 // But, this routine is only called when we are NOT associated.
3820 vos_mem_copy(bSsid.ether_addr_octet,
3821 pWextState->roamProfile.BSSIDs.bssid,
3822 sizeof(bSsid.ether_addr_octet));
3823 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3824 {
3825 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003826 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 else
3828 {
3829 return 0;
3830 }
3831 // The actual processing may eventually be more extensive than this.
3832 // Right now, just consume any PMKIDs that are sent in by the app.
3833 status = hdd_ProcessGENIE(pAdapter,
3834 &bSsid, // MAC address of assoc peer
3835 &RSNEncryptType,
3836 &mcRSNEncryptType,
3837 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003838#ifdef WLAN_FEATURE_11W
3839 &RSNMfpRequired,
3840 &RSNMfpCapable,
3841#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003842 pWextState->WPARSNIE[1]+2,
3843 pWextState->WPARSNIE);
3844 if (status == 0)
3845 {
3846 // Now copy over all the security attributes you have parsed out
3847 pWextState->roamProfile.EncryptionType.numEntries = 1;
3848 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003849
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3851 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003852
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003853 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3854 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3855 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3856 {
3857 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3858 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3859 either AES/TKIP based on group cipher configuration
3860 mentioned in the wpa_supplicant.conf.*/
3861
3862 /*Set the unicast cipher same as multicast cipher*/
3863 pWextState->roamProfile.EncryptionType.encryptionType[0]
3864 = mcRSNEncryptType;
3865 }
3866
Chet Lanctot186b5732013-03-18 10:26:30 -07003867#ifdef WLAN_FEATURE_11W
3868 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3869 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3870#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003871 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003872 }
3873 return 0;
3874}
3875int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3876{
3877 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3878 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3879 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3880 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003881
Jeff Johnson295189b2012-06-20 16:38:30 -07003882 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003883 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003884
Jeff Johnson295189b2012-06-20 16:38:30 -07003885 switch( pHddStaCtx->conn_info.authType)
3886 {
3887 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003888#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003889 case eCSR_AUTH_TYPE_CCKM_WPA:
3890 case eCSR_AUTH_TYPE_CCKM_RSN:
3891#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003892 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3893
Jeff Johnson295189b2012-06-20 16:38:30 -07003894 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003895 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003897
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003898#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003899 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3900 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3901 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003902 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003903 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3904 } else
3905 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003906 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003907 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003908 } else
3909#endif
3910 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3911 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003912 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3913 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3915 == IW_AUTH_KEY_MGMT_PSK) {
3916 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003917 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003918 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003919 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003920 }
3921 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003922#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003923 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3924 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3925 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003926 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003927 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003928 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003929 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003930 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003931 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003932 } else
3933#endif
3934
3935#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003936 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3937 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003938 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003939 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003940 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003941 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003942 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3943 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003944 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003945 } else
3946#endif
3947
Chet Lanctot186b5732013-03-18 10:26:30 -07003948#ifdef WLAN_FEATURE_11W
3949 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3950 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3951 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303952 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
3953 pRoamProfile->AuthType.authType[0] =
3954 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3955 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003956#endif
3957
Shailender Karmuchia734f332013-04-19 14:02:48 -07003958 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003960 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3961 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003962 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3963 == IW_AUTH_KEY_MGMT_PSK) {
3964 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003965 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003966 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003967 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003968 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003969 break;
3970
Jeff Johnson295189b2012-06-20 16:38:30 -07003971 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003972
3973 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 break;
3975 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003976
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003977#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08003978 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003979#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003980 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3981 break;
3982 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003983
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003985 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003986
Jeff Johnson295189b2012-06-20 16:38:30 -07003987 EXIT();
3988 return 0;
3989}
3990
3991/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003992
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303993 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003994 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07003995 to the CSR roam profile.
3996
Jeff Johnson295189b2012-06-20 16:38:30 -07003997 \param - dev - Pointer to the net device.
3998 - info - Pointer to the iw_request_info.
3999 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004000 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004001 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004002
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 --------------------------------------------------------------------------*/
4004
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304005int __iw_set_essid(struct net_device *dev,
4006 struct iw_request_info *info,
4007 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004008{
4009 v_U32_t status = 0;
4010 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304011 hdd_adapter_t *pAdapter;
4012 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 v_U32_t roamId;
4014 tCsrRoamProfile *pRoamProfile;
4015 eMib_dot11DesiredBssType connectedBssType;
4016 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304017 tHalHandle hHal;
4018 hdd_station_ctx_t *pHddStaCtx;
4019 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004020
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304022 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4023 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304025 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304026 "%s: Adapter is NULL",__func__);
4027 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004028 }
4029
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304030 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4031 ret = wlan_hdd_validate_context(pHddCtx);
4032 if (0 != ret)
4033 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304034 return ret;
4035 }
4036
4037 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4038 if (NULL == hHal)
4039 {
4040 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4041 "%s: Hal Context is NULL",__func__);
4042 return -EINVAL;
4043 }
4044 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4045 if (NULL == pHddStaCtx)
4046 {
4047 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4048 "%s: STA Context is NULL",__func__);
4049 return -EINVAL;
4050 }
4051 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4052 if (NULL == pWextState)
4053 {
4054 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4055 "%s: pWextState is NULL",__func__);
4056 return -EINVAL;
4057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004058 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
4059 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
4060 return -EBUSY;
4061 }
4062 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
4063 return -EINVAL;
4064 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004065 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004066 {
4067 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
4068 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
4069 {
4070 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004071 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4073 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
4074
4075 if(VOS_STATUS_SUCCESS == vosStatus)
4076 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
4077 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4078 }
4079 }
4080 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004081 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 {
4083 return -EINVAL;
4084 }
4085 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004086 /** when cfg80211 defined, wpa_supplicant wext driver uses
4087 zero-length, null-string ssid for force disconnection.
4088 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07004089 driver MUST return success */
4090 if ( 0 == wrqu->essid.length ) {
4091 return 0;
4092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004093
4094 status = hdd_wmm_get_uapsd_mask(pAdapter,
4095 &pWextState->roamProfile.uapsd_mask);
4096 if (VOS_STATUS_SUCCESS != status)
4097 {
4098 pWextState->roamProfile.uapsd_mask = 0;
4099 }
4100 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004101
Jeff Johnson295189b2012-06-20 16:38:30 -07004102 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004103
4104 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004105 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
4106 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
4107 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004108
Jeff Johnson295189b2012-06-20 16:38:30 -07004109 //set gen ie
4110 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
4111
4112 //set auth
4113 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
4114 }
4115#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004116 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004117 if (pAdapter->wapi_info.nWapiMode)
4118 {
4119 switch (pAdapter->wapi_info.wapiAuthMode)
4120 {
4121 case WAPI_AUTH_MODE_PSK:
4122 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004123 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004124 pRoamProfile->AuthType.numEntries = 1;
4125 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4126 break;
4127 }
4128 case WAPI_AUTH_MODE_CERT:
4129 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004130 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 pRoamProfile->AuthType.numEntries = 1;
4132 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4133 break;
4134 }
4135 } // End of switch
4136 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
4137 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
4138 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004139 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004140 pRoamProfile->EncryptionType.numEntries = 1;
4141 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4142 pRoamProfile->mcEncryptionType.numEntries = 1;
4143 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4144 }
4145 }
4146#endif /* FEATURE_WLAN_WAPI */
4147 /* if previous genIE is not NULL, update AssocIE */
4148 if (0 != pWextState->genIE.length)
4149 {
4150 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
4151 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
4152 pWextState->genIE.length);
4153 pWextState->assocAddIE.length = pWextState->genIE.length;
4154 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
4155 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
4156
4157 /* clear previous genIE after use it */
4158 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
4159 }
4160
4161 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
4162 pWextState->roamProfile.bWPSAssociation = FALSE;
4163
4164 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
4165 pWextState->roamProfile.nAddIEAssocLength))
4166 pWextState->roamProfile.bWPSAssociation = TRUE;
4167
4168
4169 // Disable auto BMPS entry by PMC until DHCP is done
4170 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
4171
Shailender Karmuchia734f332013-04-19 14:02:48 -07004172 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004173 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004174
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004175 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
4176 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004177 hdd_select_cbmode(pAdapter,
4178 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
4179 }
4180 status = sme_RoamConnect( hHal,pAdapter->sessionId,
4181 &(pWextState->roamProfile), &roamId);
4182 pRoamProfile->ChannelInfo.ChannelList = NULL;
4183 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004184
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004185 EXIT();
4186 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004187}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004188
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304189int iw_set_essid(struct net_device *dev,
4190 struct iw_request_info *info,
4191 union iwreq_data *wrqu, char *extra)
4192{
4193 int ret;
4194
4195 vos_ssr_protect(__func__);
4196 ret = __iw_set_essid(dev, info, wrqu, extra);
4197 vos_ssr_unprotect(__func__);
4198
4199 return ret;
4200}
4201
Jeff Johnson295189b2012-06-20 16:38:30 -07004202/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004203
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304204 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004205 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004206
Jeff Johnson295189b2012-06-20 16:38:30 -07004207 \param - dev - Pointer to the net device.
4208 - info - Pointer to the iw_request_info.
4209 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004210 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004211 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004212
Jeff Johnson295189b2012-06-20 16:38:30 -07004213 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304214int __iw_get_essid(struct net_device *dev,
4215 struct iw_request_info *info,
4216 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004217{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304218 hdd_adapter_t *pAdapter;
4219 hdd_context_t *pHddCtx;
4220 hdd_wext_state_t *wextBuf;
4221 hdd_station_ctx_t *pHddStaCtx;
4222 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304223
Jeff Johnson295189b2012-06-20 16:38:30 -07004224 ENTER();
4225
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304226 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4227 if (NULL == pAdapter)
4228 {
4229 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4230 "%s: Adapter is NULL",__func__);
4231 return -EINVAL;
4232 }
4233
4234 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4235 ret = wlan_hdd_validate_context(pHddCtx);
4236 if (0 != ret)
4237 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304238 return ret;
4239 }
4240
4241 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4242 if (NULL == pHddStaCtx)
4243 {
4244 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4245 "%s: STA Context is NULL",__func__);
4246 return -EINVAL;
4247 }
4248
4249 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4250 if (NULL == wextBuf)
4251 {
4252 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4253 "%s: wextBuf is NULL",__func__);
4254 return -EINVAL;
4255 }
4256
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
4258 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
4259 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
4260 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
4261 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
4262 {
4263 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
4264 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
4265 dwrq->flags = 1;
4266 } else {
4267 memset(extra, 0, dwrq->length);
4268 dwrq->length = 0;
4269 dwrq->flags = 0;
4270 }
4271 EXIT();
4272 return 0;
4273}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304274
4275int iw_get_essid(struct net_device *dev,
4276 struct iw_request_info *info,
4277 struct iw_point *dwrq, char *extra)
4278{
4279 int ret;
4280
4281 vos_ssr_protect(__func__);
4282 ret = __iw_get_essid(dev, info, dwrq, extra);
4283 vos_ssr_unprotect(__func__);
4284
4285 return ret;
4286}
Jeff Johnson295189b2012-06-20 16:38:30 -07004287/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004288
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304289 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004290 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004291
Jeff Johnson295189b2012-06-20 16:38:30 -07004292 \param - dev - Pointer to the net device.
4293 - info - Pointer to the iw_request_info.
4294 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004295 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004297
Jeff Johnson295189b2012-06-20 16:38:30 -07004298 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304299int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
4300 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004301{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304302 hdd_adapter_t *pAdapter;
4303 hdd_context_t *pHddCtx;
4304 hdd_wext_state_t *pWextState;
4305 hdd_station_ctx_t *pHddStaCtx;
4306 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004307 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304309 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004310
Jeff Johnson295189b2012-06-20 16:38:30 -07004311 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004312
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304313 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4314 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004315 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304316 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4317 "%s: Adapter is NULL",__func__);
4318 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004319 }
4320
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304321 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4322 ret = wlan_hdd_validate_context(pHddCtx);
4323 if (0 != ret)
4324 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304325 return ret;
4326 }
4327
4328 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4329 if (NULL == pHddStaCtx)
4330 {
4331 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4332 "%s: STA Context is NULL",__func__);
4333 return -EINVAL;
4334 }
4335
4336 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4337 if (NULL == pWextState)
4338 {
4339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4340 "%s: pWextState is NULL",__func__);
4341 return -EINVAL;
4342 }
4343
4344 pRoamProfile = &pWextState->roamProfile;
4345
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 switch(wrqu->param.flags & IW_AUTH_INDEX)
4347 {
4348 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004349
Jeff Johnson295189b2012-06-20 16:38:30 -07004350 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004351
Jeff Johnson295189b2012-06-20 16:38:30 -07004352 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004353
Jeff Johnson295189b2012-06-20 16:38:30 -07004354 case IW_AUTH_CIPHER_PAIRWISE:
4355 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004356 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004357 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004358 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004359 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4360 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004361 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004362 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
4363 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004364 }
4365
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004367
4368 if( (IW_AUTH_KEY_MGMT_802_1X
4369 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
4371 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004372 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07004373 else
4374 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004375 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4376 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004377 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004378
4379 if( ( IW_AUTH_KEY_MGMT_802_1X
4380 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004381 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4382 /*Dynamic WEP key*/
4383 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4384 else
4385 /*Static WEP key*/
4386 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004387
Jeff Johnson295189b2012-06-20 16:38:30 -07004388 }
4389 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004390
Jeff Johnson295189b2012-06-20 16:38:30 -07004391 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004392 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004393 return -EINVAL;
4394 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004395
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 pRoamProfile->EncryptionType.numEntries = 1;
4397 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004398 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 break;
4400 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004401 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004402 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
4403 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4404 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004405
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4407 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
4408 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004409
4410 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
4412 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004413
Jeff Johnson295189b2012-06-20 16:38:30 -07004414 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004415
4416 if( ( IW_AUTH_KEY_MGMT_802_1X
4417 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
4418 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4419
Jeff Johnson295189b2012-06-20 16:38:30 -07004420 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004421
4422 else
4423 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004424 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004425
4426 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
4427 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004428 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004429 if( ( IW_AUTH_KEY_MGMT_802_1X
4430 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07004431 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4432 {
4433 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4434 }
4435 else
4436 {
4437 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4438 }
4439 }
4440 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004441
Jeff Johnson295189b2012-06-20 16:38:30 -07004442 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004443 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004444 return -EINVAL;
4445 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004446
Jeff Johnson295189b2012-06-20 16:38:30 -07004447 pRoamProfile->mcEncryptionType.numEntries = 1;
4448 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
4449 }
4450 break;
4451
4452 case IW_AUTH_80211_AUTH_ALG:
4453 {
4454 /*Save the auth algo here and set auth type to SME Roam profile
4455 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004456 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07004457 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004458
Jeff Johnson295189b2012-06-20 16:38:30 -07004459 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
4460 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
4461
4462 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
4463 /*Not supported*/
4464 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4465 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
4466 }
4467 break;
4468
4469 case IW_AUTH_KEY_MGMT:
4470 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004471#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004472#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
4473 /*Check for CCKM AKM type */
4474 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004475 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
4476 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004477 /* Set the CCKM bit in authKeyMgmt */
4478 /* Right now, this breaks all ref to authKeyMgmt because our
4479 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 */
4481 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
4482 /*Set the key management to 802.1X*/
4483 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004484 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004485 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4486 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
4487 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
4488 /*Save the key management*/
4489 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
4490 //pWextState->authKeyMgmt = wrqu->param.value;
4491 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4492 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4493 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
4494 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
4495 /*Save the key management anyway*/
4496 pWextState->authKeyMgmt = wrqu->param.value;
4497 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
4498 /*Save the key management*/
4499 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
4500 //pWextState->authKeyMgmt = wrqu->param.value;
4501 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4502 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4503 }
4504#else
4505 /*Save the key management*/
4506 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004507#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004508 }
4509 break;
4510
4511 case IW_AUTH_TKIP_COUNTERMEASURES:
4512 {
4513 if(wrqu->param.value) {
4514 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4515 "Counter Measure started %d", wrqu->param.value);
4516 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
4517 }
4518 else {
4519 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4520 "Counter Measure stopped=%d", wrqu->param.value);
4521 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
4522 }
4523 }
4524 break;
4525 case IW_AUTH_DROP_UNENCRYPTED:
4526 case IW_AUTH_WPA_ENABLED:
4527 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
4528 case IW_AUTH_ROAMING_CONTROL:
4529 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004530
Jeff Johnson295189b2012-06-20 16:38:30 -07004531 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004532
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004533 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004534 wrqu->param.flags & IW_AUTH_INDEX);
4535 break;
4536 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004537
Jeff Johnson295189b2012-06-20 16:38:30 -07004538 EXIT();
4539 return 0;
4540}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304541
4542int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
4543 union iwreq_data *wrqu, char *extra)
4544{
4545 int ret;
4546
4547 vos_ssr_protect(__func__);
4548 ret = __iw_set_auth(dev, info, wrqu, extra);
4549 vos_ssr_unprotect(__func__);
4550
4551 return ret;
4552}
4553
Jeff Johnson295189b2012-06-20 16:38:30 -07004554/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004555
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304556 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004557 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004558
Jeff Johnson295189b2012-06-20 16:38:30 -07004559 \param - dev - Pointer to the net device.
4560 - info - Pointer to the iw_request_info.
4561 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004562 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004563 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004564
Jeff Johnson295189b2012-06-20 16:38:30 -07004565 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304566int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4567 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004568{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304569 hdd_adapter_t* pAdapter;
4570 hdd_wext_state_t *pWextState;
4571 tCsrRoamProfile *pRoamProfile;
4572 hdd_context_t *pHddCtx;
4573 int ret = 0;
4574
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004576
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304577 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4578 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004579 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304580 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4581 "%s: Adapter is NULL",__func__);
4582 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004583 }
4584
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304585 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4586 ret = wlan_hdd_validate_context(pHddCtx);
4587 if (0 != ret)
4588 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304589 return ret;
4590 }
4591
4592 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4593 if (NULL == pWextState)
4594 {
4595 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4596 "%s: pWextState is NULL",__func__);
4597 return -EINVAL;
4598 }
4599 pRoamProfile = &pWextState->roamProfile;
4600
Jeff Johnson295189b2012-06-20 16:38:30 -07004601 switch(pRoamProfile->negotiatedAuthType)
4602 {
4603 case eCSR_AUTH_TYPE_WPA_NONE:
4604 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4605 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
4606 break;
4607 case eCSR_AUTH_TYPE_WPA:
4608 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4609 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
4610 break;
4611#ifdef WLAN_FEATURE_VOWIFI_11R
4612 case eCSR_AUTH_TYPE_FT_RSN:
4613#endif
4614 case eCSR_AUTH_TYPE_RSN:
4615 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4616 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
4617 break;
4618 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4619 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4620 break;
4621 case eCSR_AUTH_TYPE_SHARED_KEY:
4622 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
4623 break;
4624 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004625 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004626 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4627 break;
4628 case eCSR_AUTH_TYPE_AUTOSWITCH:
4629 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4630 break;
4631 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304632 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004633 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4634 return -EIO;
4635#ifdef WLAN_FEATURE_VOWIFI_11R
4636 case eCSR_AUTH_TYPE_FT_RSN_PSK:
4637#endif
4638 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07004639#ifdef WLAN_FEATURE_11W
4640 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05304641 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07004642#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05304643 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4645 return -EIO;
4646 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304647 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004648 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4649 return -EIO;
4650 }
4651 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
4652 {
4653 switch(pRoamProfile->negotiatedUCEncryptionType)
4654 {
4655 case eCSR_ENCRYPT_TYPE_NONE:
4656 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4657 break;
4658 case eCSR_ENCRYPT_TYPE_WEP40:
4659 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4660 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4661 break;
4662 case eCSR_ENCRYPT_TYPE_TKIP:
4663 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4664 break;
4665 case eCSR_ENCRYPT_TYPE_WEP104:
4666 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4667 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4668 break;
4669 case eCSR_ENCRYPT_TYPE_AES:
4670 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4671 break;
4672 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304673 hddLog(LOG1, "%s called with unknown auth type %d ",
4674 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004675 return -EIO;
4676 }
4677 }
4678
Shailender Karmuchia734f332013-04-19 14:02:48 -07004679 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07004680 {
4681 switch(pRoamProfile->negotiatedMCEncryptionType)
4682 {
4683 case eCSR_ENCRYPT_TYPE_NONE:
4684 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4685 break;
4686 case eCSR_ENCRYPT_TYPE_WEP40:
4687 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4688 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4689 break;
4690 case eCSR_ENCRYPT_TYPE_TKIP:
4691 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4692 break;
4693 case eCSR_ENCRYPT_TYPE_WEP104:
4694 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4695 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4696 break;
4697 case eCSR_ENCRYPT_TYPE_AES:
4698 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4699 break;
4700 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304701 hddLog(LOG1, "%s called with unknown auth type %d ",
4702 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004703 return -EIO;
4704 }
4705 }
4706
4707 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004708 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004709 EXIT();
4710 return 0;
4711}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304712
4713int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4714 union iwreq_data *wrqu,char *extra)
4715{
4716 int ret;
4717
4718 vos_ssr_protect(__func__);
4719 ret = __iw_get_auth(dev, info, wrqu, extra);
4720 vos_ssr_unprotect(__func__);
4721
4722 return ret;
4723}
4724
Jeff Johnson295189b2012-06-20 16:38:30 -07004725/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004726
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304727 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07004728 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07004729 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004730
Jeff Johnson295189b2012-06-20 16:38:30 -07004731 \param - dev - Pointer to the net device.
4732 - info - Pointer to the iw_request_info.
4733 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004734 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004735 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004736
Jeff Johnson295189b2012-06-20 16:38:30 -07004737 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304738int __iw_set_ap_address(struct net_device *dev,
4739 struct iw_request_info *info,
4740 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004741{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304742 hdd_station_ctx_t *pHddStaCtx;
4743 hdd_adapter_t *pAdapter;
4744 hdd_context_t *pHddCtx;
4745 v_U8_t *pMacAddress = NULL;
4746 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304747
Jeff Johnson295189b2012-06-20 16:38:30 -07004748 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304749
4750 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4751 if (NULL == pAdapter)
4752 {
4753 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4754 "%s: Adapter is NULL", __func__);
4755 return -EINVAL;
4756 }
4757 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4758 ret = wlan_hdd_validate_context(pHddCtx);
4759 if (0 != ret)
4760 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304761 return ret;
4762 }
4763 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4764 if (NULL == pHddStaCtx)
4765 {
4766 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4767 "%s: pHddStaCtx is NULL", __func__);
4768 return -EINVAL;
4769 }
4770
Jeff Johnson295189b2012-06-20 16:38:30 -07004771 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08004772 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
4773 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07004774 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07004775
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304776 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004777 return 0;
4778}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304779
4780int iw_set_ap_address(struct net_device *dev,
4781 struct iw_request_info *info,
4782 union iwreq_data *wrqu, char *extra)
4783{
4784 int ret;
4785
4786 vos_ssr_protect(__func__);
4787 ret = __iw_set_ap_address(dev, info, wrqu, extra);
4788 vos_ssr_unprotect(__func__);
4789
4790 return ret;
4791}
4792
Jeff Johnson295189b2012-06-20 16:38:30 -07004793/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004794
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304795 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004796 This function returns the BSSID to the wpa_supplicant
4797 \param - dev - Pointer to the net device.
4798 - info - Pointer to the iw_request_info.
4799 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004800 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004801 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004802
Jeff Johnson295189b2012-06-20 16:38:30 -07004803 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304804int __iw_get_ap_address(struct net_device *dev,
4805 struct iw_request_info *info,
4806 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004807{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304808 hdd_station_ctx_t *pHddStaCtx;
4809 hdd_adapter_t *pAdapter;
4810 hdd_context_t *pHddCtx;
4811 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304812
Jeff Johnson295189b2012-06-20 16:38:30 -07004813 ENTER();
4814
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304815 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4816 if (NULL == pAdapter)
4817 {
4818 hddLog(VOS_TRACE_LEVEL_ERROR,
4819 "%s: Adapter is NULL", __func__);
4820 return -EINVAL;
4821 }
4822 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4823 ret = wlan_hdd_validate_context(pHddCtx);
4824 if (0 != ret)
4825 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304826 return ret;
4827 }
4828 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4829 if (NULL == pHddStaCtx)
4830 {
4831 hddLog(VOS_TRACE_LEVEL_ERROR,
4832 "%s: pHddStaCtx is NULL", __func__);
4833 return -EINVAL;
4834 }
4835
Jeff Johnson295189b2012-06-20 16:38:30 -07004836 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
4837 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
4838 {
Jeff Johnson4416a782013-03-25 14:17:50 -07004839 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07004840 }
4841 else
4842 {
4843 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4844 }
4845 EXIT();
4846 return 0;
4847}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004848
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304849int iw_get_ap_address(struct net_device *dev,
4850 struct iw_request_info *info,
4851 union iwreq_data *wrqu, char *extra)
4852{
4853 int ret;
4854
4855 vos_ssr_protect(__func__);
4856 ret = __iw_get_ap_address(dev, info, wrqu, extra);
4857 vos_ssr_unprotect(__func__);
4858
4859 return ret;
4860}
4861
Chet Lanctot186b5732013-03-18 10:26:30 -07004862#ifdef WLAN_FEATURE_11W
4863/**---------------------------------------------------------------------------
4864
4865 \brief hdd_indicateUnprotMgmtFrame -
4866 This function forwards the unprotected management frame to the supplicant
4867 \param - pAdapter - Pointer to HDD adapter
4868 - nFrameLength - Length of the unprotected frame being passed
4869 - pbFrames - Pointer to the frame buffer
4870 - frameType - 802.11 frame type
4871 \return - nothing
4872
4873 --------------------------------------------------------------------------*/
4874void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
4875 tANI_U32 nFrameLength,
4876 tANI_U8* pbFrames,
4877 tANI_U8 frameType )
4878{
4879 tANI_U8 type = 0;
4880 tANI_U8 subType = 0;
4881
4882 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
4883 __func__, frameType, nFrameLength);
4884
4885 /* Sanity Checks */
4886 if (NULL == pAdapter)
4887 {
4888 hddLog( LOGE, FL("pAdapter is NULL"));
4889 return;
4890 }
4891
4892 if (NULL == pAdapter->dev)
4893 {
4894 hddLog( LOGE, FL("pAdapter->dev is NULL"));
4895 return;
4896 }
4897
4898 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
4899 {
4900 hddLog( LOGE, FL("pAdapter has invalid magic"));
4901 return;
4902 }
4903
4904 if( !nFrameLength )
4905 {
4906 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
4907 return;
4908 }
4909
4910 if (NULL == pbFrames) {
4911 hddLog( LOGE, FL("pbFrames is NULL"));
4912 return;
4913 }
4914
4915 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4916 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4917
4918 /* Get pAdapter from Destination mac address of the frame */
4919 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
4920 {
4921 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
4922 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4923 }
4924 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
4925 {
4926 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
4927 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4928 }
4929 else
4930 {
4931 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
4932 return;
4933 }
4934}
4935#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004936
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004937#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004938void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
4939 tANI_U8 state,
4940 tANI_U16 measInterval )
4941{
4942 union iwreq_data wrqu;
4943 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004944 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004945
4946 if (NULL == pAdapter)
4947 return;
4948
4949 // create the event
4950 memset(&wrqu, '\0', sizeof(wrqu));
4951 memset(buf, '\0', sizeof(buf));
4952
4953 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
4954 tid, state, measInterval);
4955
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004956 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004957
4958 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004959 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004960 // send the event
4961 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4962}
4963
4964void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4965{
4966 union iwreq_data wrqu;
4967 char buf[IW_CUSTOM_MAX + 1];
4968 char *pos = buf;
4969 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4970
4971 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4972 return;
4973
4974 // create the event
4975 memset(&wrqu, '\0', sizeof(wrqu));
4976 memset(buf, '\0', sizeof(buf));
4977
4978 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304979 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
4980 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
4981 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
4982 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004983
4984 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4985 pos += nBytes;
4986 freeBytes -= nBytes;
4987
4988 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
4989 pos += WNI_CFG_BSSID_LEN;
4990 freeBytes -= WNI_CFG_BSSID_LEN;
4991
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004992 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4993 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004994
4995 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004996 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004997
4998 // send the event
4999 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5000}
5001
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005002void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005003{
5004 union iwreq_data wrqu;
5005 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005006 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005007
5008 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5009 return;
5010
5011 // create the event
5012 memset(&wrqu, '\0', sizeof(wrqu));
5013 memset(buf, '\0', sizeof(buf));
5014
5015 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
5016
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005017 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005018
5019 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005020 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005021
5022 // send the event
5023 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5024}
5025
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005026void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
5027 const tANI_U16 measurementToken,
5028 const tANI_BOOLEAN flag,
5029 const tANI_U8 numBss)
5030{
5031 union iwreq_data wrqu;
5032 char buf[IW_CUSTOM_MAX];
5033 char *pos = buf;
5034 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5035
5036 memset(&wrqu, '\0', sizeof(wrqu));
5037 memset(buf, '\0', sizeof(buf));
5038
5039 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
5040 numBss);
5041
5042 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
5043 flag, numBss);
5044
5045 wrqu.data.pointer = buf;
5046 wrqu.data.length = nBytes;
5047 // send the event
5048 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5049}
5050
5051
5052static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005053 const tCsrRoamInfo *pRoamInfo)
5054{
5055 union iwreq_data wrqu;
5056 char buf[IW_CUSTOM_MAX + 1];
5057 char *pos = buf;
5058 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5059 tANI_U8 i = 0, len = 0;
5060 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
5061 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005062 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
5063 tANI_U8 ieLenByte = 1;
5064 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
5065#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005066
5067 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5068 return;
5069
5070 /* Custom event can pass maximum of 256 bytes of data,
5071 based on the IE len we need to identify how many BSS info can
5072 be filled in to custom event data */
5073 /*
5074 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
5075 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
5076 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
5077 */
5078
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005079 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005080 {
5081 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
5082 /* If the measurement is none and no scan results found,
5083 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005084 hdd_indicateEseBcnReportNoResults(pAdapter,
5085 pRoamInfo->pEseBcnReportRsp->measurementToken,
5086 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005087 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005088 }
5089 else
5090 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005091 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005092 {
5093 memset(&wrqu, '\0', sizeof(wrqu));
5094 memset(buf, '\0', sizeof(buf));
5095 tot_bcn_ieLen = 0;
5096 sendBss = 0;
5097 pos = buf;
5098 freeBytes = IW_CUSTOM_MAX;
5099
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005100 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005101 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005102 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
5103 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005104 {
5105 break;
5106 }
5107 tot_bcn_ieLen += len;
5108 sendBss++;
5109 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
5110 "IeLength(%d) Length of Ie(%d) totLen(%d)",
5111 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005112 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005113 tot_bcn_ieLen);
5114 }
5115
5116 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
5117 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005118 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5119 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005120
5121 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005122 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5123 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005124 pos += nBytes;
5125 freeBytes -= nBytes;
5126
5127 /* Copy total Beacon report data length */
5128 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
5129 pos += sizeof(tot_bcn_ieLen);
5130 freeBytes -= sizeof(tot_bcn_ieLen);
5131
5132 for (i = 0; i < sendBss; i++)
5133 {
5134 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305135 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
5136 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005137 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005138 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
5139 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
5140 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
5141 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
5142 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
5143 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
5144 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
5145 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
5146 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
5147 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
5148 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
5149 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
5150 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
5151 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
5152 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
5153 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005154
5155 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005156 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
5157 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005158 pos += len;
5159 freeBytes -= len;
5160
5161 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005162 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005163 vos_mem_copy(pos, (char*)&len, sizeof(len));
5164 pos += sizeof(len);
5165 freeBytes -= sizeof(len);
5166
5167 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005168 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005169 pos += len;
5170 freeBytes -= len;
5171 }
5172
5173 wrqu.data.pointer = buf;
5174 wrqu.data.length = strlen(buf);
5175
5176 // send the event
5177 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5178 lastSent += sendBss;
5179 }
5180 }
5181}
5182
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005183#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005184