blob: 2ef6059bd32bcdde6f7fd606faedd2df8a6f6133 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kiet Lam842dad02014-02-18 18:44:02 -08002 * Copyright (c) 2012-2014 The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
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"
Jeff Johnson295189b2012-06-20 16:38:30 -070056#include <linux/ieee80211.h>
57#include <linux/wireless.h>
58#include <net/cfg80211.h>
59#include "wlan_hdd_cfg80211.h"
60#include "csrInsideApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070061#include "wlan_hdd_p2p.h"
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053062#include <vos_sched.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080063#ifdef FEATURE_WLAN_TDLS
64#include "wlan_hdd_tdls.h"
65#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070066#include "sme_Api.h"
Sushant Kaushikba6764e2014-06-30 19:52:09 +053067#include "wlan_hdd_hostapd.h"
Mukul Sharma84f27252014-07-14 18:11:42 +053068#ifdef DEBUG_ROAM_DELAY
69#include "vos_utils.h"
70#endif
71
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__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700509 return;
510 }
511
512 wrqu.data.length = str_len + auth_resp_len;
513 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
514
515 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700516#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700517}
518
519#endif /* WLAN_FEATURE_VOWIFI_11R */
520
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800521#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700522
523/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800524 * Send the ESE required "new AP Channel info" to the supplicant.
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 * (This keeps the supplicant "up to date" on the current channel.)
526 *
527 * The current (new AP) channel information is passed in.
528 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700529static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700530 tCsrRoamInfo *pCsrRoamInfo)
531{
532 union iwreq_data wrqu;
533 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700534
Shailender Karmuchia734f332013-04-19 14:02:48 -0700535
536 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 {
538 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800539 "%s: pCsrRoamInfo->pBssDesc=%p",
Jeff Johnson295189b2012-06-20 16:38:30 -0700540 __func__, descriptor);
541 return;
542 }
543
544 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -0800545 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700546 memset(&wrqu, '\0', sizeof(wrqu));
547 wrqu.freq.m = descriptor->channelId;
548 wrqu.freq.e = 0;
549 wrqu.freq.i = 0;
550 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
551}
552
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800553#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700554
555void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
556{
557 union iwreq_data wrqu;
558 u8 *pBeaconIes;
559 u8 currentLen = 0;
560 char *buff;
561 int totalIeLen = 0, currentOffset = 0, strLen;
562
563 memset(&wrqu, '\0', sizeof(wrqu));
564
565 if (0 == pCsrRoamInfo->nBeaconLength)
566 {
567 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
568 return;
569 }
570 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700571 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700572 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700573 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700574 return;
575 }
576
577 // pBeaconIes needs to point to the IEs
578 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
579 (unsigned int)pBeaconIes[0],
580 (unsigned int)pBeaconIes[1]);
581 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700582
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 // We need to send the IEs to the supplicant.
584 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700585 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700586 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700587 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700588 return;
589 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700590 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700591
592 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
593 currentLen = strLen + 1;
594
595 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
596 do
597 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700598 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -0700599 * max size and send it to supplicant. Changes are done in supplicant to handle this */
600 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
601 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
602 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
603 currentOffset += currentLen;
604 totalIeLen -= currentLen;
605 wrqu.data.length = strLen + 1 + currentLen;
606 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700607 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -0700608 else
609 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
610
611 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
612 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
613 } while (totalIeLen > 0);
614
615 kfree(buff);
616}
617
618static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
619{
620 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
621 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
622 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
623 union iwreq_data wrqu;
624 int we_event;
625 char *msg;
626 int type = -1;
627
Shailender Karmuchia734f332013-04-19 14:02:48 -0700628#if defined (WLAN_FEATURE_VOWIFI_11R)
629 // Added to find the auth type on the fly at run time
630 // rather than with cfg to see if FT is enabled
631 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
633#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700634
Jeff Johnson295189b2012-06-20 16:38:30 -0700635 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -0700636 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700637 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700638
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
640 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530641 /* In case of roaming ; We are not doing disconnect.
642 * If disconnect is not being done for roam; We will not
643 * decrease count for Active sessions. We should not increase active
644 * active session in case of roaming.
645 */
Padma, Santhosh Kumar87ba40f2014-11-26 19:40:15 +0530646 if((pHddStaCtx->ft_carrier_on == FALSE) && !pCsrRoamInfo->fReassocReq)
Agarwal Ashish51325b52014-06-16 16:50:49 +0530647 {
648 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
649 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700650 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
651 type = WLAN_STA_ASSOC_DONE_IND;
652
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700653#ifdef WLAN_FEATURE_P2P_DEBUG
654 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
655 {
656 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
657 {
658 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
659 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
660 "Connecting state to Connected State for 8-way "
661 "Handshake");
662 }
663 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
664 {
665 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
666 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
667 "Connecting state to P2P Client Connection Completed");
668 }
669 }
670#endif
Arif Hussain77d044f2014-01-03 19:56:04 -0800671 pr_info("wlan: " MAC_ADDRESS_STR " connected to " MAC_ADDRESS_STR "\n",
672 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
Kiet Lam34947452014-01-21 23:23:40 -0800673 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700674 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
675
676 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
677 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
678 * and fFTEnable is TRUE */
679#ifdef WLAN_FEATURE_VOWIFI_11R
680 // Send FT Keys to the supplicant when FT is enabled
681 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700682 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800683#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700684 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
685 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
686#endif
687 )
688 {
689 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
690 }
691#endif
692 }
693 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
694 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530695 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -0700696 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 type = WLAN_STA_ASSOC_DONE_IND;
Arif Hussain24bafea2013-11-15 15:10:03 -0800698 pr_info("wlan: new IBSS connection to " MAC_ADDRESS_STR"\n",
699 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700700 }
701 else /* Not Associated */
702 {
703 pr_info("wlan: disconnected\n");
704 type = WLAN_STA_DISASSOC_DONE_IND;
705 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
706 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700707 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700708
709 msg = NULL;
710 /*During the WLAN uninitialization,supplicant is stopped before the
711 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530712 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 {
714 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800715#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700716 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700717 {
718 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
719 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700720 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
721 }
722#endif
723 }
724 send_btc_nlink_msg(type, 0);
725}
726
727void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
728{
729 // Remove staId, bssId and peerMacAddress
730 pHddStaCtx->conn_info.staId [ 0 ] = 0;
731 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
732 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
733
734 // Clear all security settings
735 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
736 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
737 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
738
739 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700740 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700741
742 // Set not-connected state
743 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -0700744
745 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
746}
747/* TODO Revist this function. and data path */
748static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
749{
750 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700751 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
752
753 if (WLAN_HDD_IBSS != pAdapter->device_mode)
754 {
755 hdd_disconnect_tx_rx(pAdapter);
756 }
757 else
758 {
759 // Need to cleanup all queues only if the last peer leaves
760 if (eConnectionState_IbssDisconnected == pHddStaCtx->conn_info.connState)
761 {
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530762 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Ravi Joshif9520d62013-10-18 04:11:46 -0700763 netif_tx_disable(pAdapter->dev);
764 netif_carrier_off(pAdapter->dev);
765 hdd_disconnect_tx_rx(pAdapter);
766 }
767 else
768 {
769 // There is atleast one more peer, do not cleanup all queues
770 hdd_flush_ibss_tx_queues(pAdapter, staId);
771 }
772 }
773
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
775 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
776 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530777 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700778 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700779 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700780 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700781 }
782 return( vosStatus );
783}
784
785
786static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
787 tANI_U32 roamId, eRoamCmdStatus roamStatus,
788 eCsrRoamResult roamResult )
789{
790 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700791 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700792 struct net_device *dev = pAdapter->dev;
793 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
794 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700795 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530796 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700797
798 // Sanity check
799 if(dev == NULL)
800 {
Agarwal Ashish971c2882013-10-30 20:11:12 +0530801 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700802 "%s: net_dev is released return", __func__);
803 return eHAL_STATUS_FAILURE;
804 }
805
Jeff Johnson295189b2012-06-20 16:38:30 -0700806 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530807 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700808 netif_tx_disable(dev);
809 netif_carrier_off(dev);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +0530810 //TxTimeoutCount need to reset in case of disconnect handler
811 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700812
Jeff Johnsone7245742012-09-05 17:12:55 -0700813 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530814 /* HDD has initiated disconnect, do not send disconnect indication
815 * to kernel as it will be handled by __cfg80211_disconnect.
816 */
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530817 /* If only STA mode is on */
818 if((pHddCtx->concurrency_mode <= 1) &&
819 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
820 {
821 pHddCtx->isAmpAllowed = VOS_TRUE;
822 }
823
Agarwal Ashish47d18112014-08-04 19:55:07 +0530824 /* Need to apply spin lock before decreasing active sessions
825 * as there can be chance for double decrement if context switch
826 * Calls wlan_hdd_disconnect.
827 */
828
829 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530830 if ( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState )
831 {
832 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
833 FL(" HDD has initiated a disconnect, no need to send"
834 " disconnect indication to kernel"));
835 sendDisconInd = FALSE;
836 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530837 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700838 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530839 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +0530840 FL(" Set HDD connState to eConnectionState_Disconnecting from %d "),
841 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530842 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
843 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700844 }
Agarwal Ashish47d18112014-08-04 19:55:07 +0530845 spin_unlock_bh(&pAdapter->lock_for_active_session);
846
Jeff Johnson295189b2012-06-20 16:38:30 -0700847 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -0700848
849 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -0700850
851 // indicate 'disconnect' status to wpa_supplicant...
852 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700853 /* indicate disconnected event to nl80211 */
854 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
855 {
856 /*During the WLAN uninitialization,supplicant is stopped before the
857 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530858 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700860 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
861 "%s: sent disconnected event to nl80211",
Jeff Johnson295189b2012-06-20 16:38:30 -0700862 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700863#ifdef WLAN_FEATURE_P2P_DEBUG
864 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
865 {
866 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
867 {
868 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
869 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
870 "and moved to disconnected state");
871 }
872 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
873 {
874 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
875 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
876 "and moved to inactive state");
877 }
878 }
879#endif
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530880 /*Only send indication to kernel if not initiated by kernel*/
881 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -0700882 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530883 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
884 if ( eCSR_ROAM_LOSTLINK == roamStatus )
885 {
886 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
887 }
888 else
889 {
890 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
891 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700892 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 //If the Device Mode is Station
894 // and the P2P Client is Connected
895 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -0700896
897 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -0700898 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -0700899 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -0700900 {
901 //Enable BMPS only of other Session is P2P Client
902 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700903 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -0700904
905 if (NULL != pVosContext)
906 {
907 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
908
909 if(NULL != pHddCtx)
910 {
911 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +0530912 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
913 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530915 if (pHddCtx->hdd_wlan_suspended)
916 {
917 hdd_set_pwrparams(pHddCtx);
918 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700919 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530920 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 }
922 }
923 }
924 }
925 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700926
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +0530927 hdd_wmm_adapter_clear(pAdapter);
Mukul Sharmac159c432014-01-15 15:42:46 +0530928#if defined(WLAN_FEATURE_VOWIFI_11R)
929 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
930#endif
Katya Nigam63ce1772014-09-26 15:53:49 +0530931
932 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
933 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530934 v_U8_t i;
935
Katya Nigam63ce1772014-09-26 15:53:49 +0530936 sta_id = IBSS_BROADCAST_STAID;
937 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
938 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
939 {
940 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530941 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
942 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +0530943 sta_id, status, status );
944
945 status = eHAL_STATUS_FAILURE;
946 }
Katya Nigam63ce1772014-09-26 15:53:49 +0530947 pHddCtx->sta_to_adapter[sta_id] = NULL;
948
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530949 /*Clear all the peer sta register with TL.*/
950 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
951 {
952 if (0 != pHddStaCtx->conn_info.staId[i])
953 {
954 sta_id = pHddStaCtx->conn_info.staId[i];
955
956 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
957 FL("Deregister StaID %d"),sta_id);
958 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
959 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
960 {
961 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
962 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
963 "Status= %d [0x%x]"),
964 sta_id, status, status );
965 status = eHAL_STATUS_FAILURE;
966 }
967
968 /*set the staid and peer mac as 0, all other reset are
969 * done in hdd_connRemoveConnectInfo.
970 */
971 pHddStaCtx->conn_info.staId[i]= 0;
972 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
973
974 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
975 pHddCtx->sta_to_adapter[sta_id] = NULL;
976 }
977 }
978
Katya Nigam63ce1772014-09-26 15:53:49 +0530979 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530980 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700981 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530982 sta_id = pHddStaCtx->conn_info.staId[0];
983
984 //We should clear all sta register with TL, for now, only one.
985 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
986 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
987 {
988 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
989 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
990 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -0700991 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700992
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530993 status = eHAL_STATUS_FAILURE;
994 }
995
996 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700997 }
Srinivas Dasarideb7ae92014-12-19 15:26:40 +0530998
999#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1000 if (VOS_STATUS_SUCCESS !=
1001 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1002 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE_AC))
1003 {
1004 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1005 "WLANTL_ClearInterfaceStats Failed", __func__);
1006 }
1007 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1008 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1009 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1010 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1011#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1012
Jeff Johnson295189b2012-06-20 16:38:30 -07001013 // Clear saved connection information in HDD
1014 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhf4669da2014-05-26 15:07:49 +05301015 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1016 "%s: Set HDD connState to eConnectionState_NotConnected",
1017 __func__);
1018 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301019#ifdef WLAN_FEATURE_GTK_OFFLOAD
1020 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1021 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1022 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301023 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1024 sizeof (tSirGtkOffloadParams));
1025 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301026 }
1027#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001028
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001029#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001030 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1031 {
1032 wlan_hdd_tdls_disconnection_callback(pAdapter);
1033 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001034#endif
1035
Jeff Johnson295189b2012-06-20 16:38:30 -07001036 //Unblock anyone waiting for disconnect to complete
1037 complete(&pAdapter->disconnect_comp_var);
1038 return( status );
1039}
1040static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
1041 tCsrRoamInfo *pRoamInfo,
1042 v_U8_t staId,
1043 v_MACADDR_t *pPeerMacAddress,
1044 tSirBssDescription *pBssDesc )
1045{
1046 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1047 WLAN_STADescType staDesc = {0};
1048 eCsrEncryptionType connectedCipherAlgo;
1049 v_BOOL_t fConnected;
1050 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1051 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001052 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001053
1054 if ( NULL == pBssDesc)
1055 {
1056 return VOS_STATUS_E_FAILURE;
1057 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 // Get the Station ID from the one saved during the assocation.
1059 staDesc.ucSTAId = staId;
1060
1061 if ( pHddStaCtx->conn_info.connDot11DesiredBssType == eMib_dot11DesiredBssType_infrastructure)
Jeff Johnson295189b2012-06-20 16:38:30 -07001062 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001063 staDesc.wSTAType = WLAN_STA_INFRA;
1064
1065 // grab the bssid from the connection info in the adapter structure and hand that
1066 // over to TL when registering.
1067 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) );
1068 }
1069 else
1070 {
1071 // for an IBSS 'connect', setup the Station Descriptor for TL.
Jeff Johnson295189b2012-06-20 16:38:30 -07001072 staDesc.wSTAType = WLAN_STA_IBSS;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001073
Jeff Johnson295189b2012-06-20 16:38:30 -07001074 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
1075 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
1076 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
1077 // pass when making an Infrastructure connection.
1078 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) );
1079 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
1080 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001081
Jeff Johnson295189b2012-06-20 16:38:30 -07001082 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1083
1084 // set the QoS field appropriately
1085 if (hdd_wmm_is_active(pAdapter))
1086 {
1087 staDesc.ucQosEnabled = 1;
1088 }
1089 else
1090 {
1091 staDesc.ucQosEnabled = 0;
1092 }
1093
1094 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1095 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1096 {
1097 staDesc.ucProtectedFrame = 1;
1098 }
1099 else
1100 {
1101 staDesc.ucProtectedFrame = 0;
1102
1103 }
1104
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001105#ifdef FEATURE_WLAN_ESE
1106 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
1107#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001108
1109#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1110 /* check whether replay check is valid for the station or not */
1111 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
1112 {
1113 /* Encryption mode is either TKIP or AES
1114 and replay check is valid for only these
1115 two encryption modes */
1116 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1117 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1118 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1119 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001120
Jeff Johnson295189b2012-06-20 16:38:30 -07001121 else
1122 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001123 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001124 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001125 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001126 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1127 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1128 }
1129#endif
1130
1131#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001132 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 if (pAdapter->wapi_info.fIsWapiSta)
1134 {
1135 staDesc.ucIsWapiSta = 1;
1136 }
1137 else
1138 {
1139 staDesc.ucIsWapiSta = 0;
1140 }
1141#endif /* FEATURE_WLAN_WAPI */
1142
1143 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1144 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1145
Jeff Johnson295189b2012-06-20 16:38:30 -07001146 // UMA is Not ready yet, Xlation will be done by TL
1147 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 staDesc.ucSwFrameRXXlation = 1;
1149 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001150 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001151 staDesc.ucQosEnabled );
1152 // Initialize signatures and state
1153 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1154 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1155 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1156 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001157 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001158 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 -07001159 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1160 hdd_rx_packet_cbk,
1161 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001162 hdd_tx_fetch_packet_cbk, &staDesc,
1163 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001164
Jeff Johnson295189b2012-06-20 16:38:30 -07001165 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1166 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001167 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001168 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001169 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001170 return vosStatus;
1171 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001172
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001173 if ( cfg_param->dynSplitscan &&
1174 ( VOS_TIMER_STATE_RUNNING !=
1175 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1176 {
1177 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1178 cfg_param->trafficMntrTmrForSplitScan);
1179 }
1180
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301181 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1182 // then go to 'authenticated'. For all other authentication types
1183 // (those that donot require upper layer authentication) we can put
1184 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001185 if (staDesc.wSTAType != WLAN_STA_IBSS)
1186 VOS_ASSERT( fConnected );
1187
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301188 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001189 {
1190 // Connections that do not need Upper layer auth, transition TL directly
1191 // to 'Authenticated' state.
1192 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1193 WLANTL_STA_AUTHENTICATED );
1194
1195 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1196 }
1197 else
1198 {
1199 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301200 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1201 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001202 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301203 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001204 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1205 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001206 return( vosStatus );
1207}
1208
Jeff Johnson295189b2012-06-20 16:38:30 -07001209static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1210 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1211{
1212 unsigned int len = 0;
1213 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001214 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001215 tANI_U32 rspRsnLength = 0;
1216 struct ieee80211_channel *chan;
1217
Agarwal Ashish51325b52014-06-16 16:50:49 +05301218 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001219 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001220 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001221 }
1222
Agarwal Ashish51325b52014-06-16 16:50:49 +05301223 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001224 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1225 goto done;
1226 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001227
Agarwal Ashish51325b52014-06-16 16:50:49 +05301228 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001229 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1230 goto done;
1231 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001232
1233 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1234 pCsrRoamInfo->nAssocReqLength);
1235 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001236 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001237
1238 //pFTAssocRsp needs to point to the IEs
1239 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001240 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001241 (unsigned int)pFTAssocRsp[0],
1242 (unsigned int)pFTAssocRsp[1]);
1243
1244 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001245 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001246 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001247 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001248 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001249
1250 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1251 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1252 reqRsnIe, reqRsnLength,
1253 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001254
1255done:
1256 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001257}
Jeff Johnson295189b2012-06-20 16:38:30 -07001258
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301259void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1260{
1261 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1262 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1263 tCsrRoamInfo roamInfo;
1264 roamInfo.fAuthRequired = FALSE;
1265 vos_mem_copy(roamInfo.bssid,
1266 pHddStaCtx->roam_info.bssid,
1267 WNI_CFG_BSSID_LEN);
1268 vos_mem_copy(roamInfo.peerMac,
1269 pHddStaCtx->roam_info.peerMac,
1270 WNI_CFG_BSSID_LEN);
1271
1272 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1273 &roamInfo,
1274 pHddStaCtx->roam_info.roamId,
1275 pHddStaCtx->roam_info.roamStatus,
1276 eCSR_ROAM_RESULT_AUTHENTICATED);
1277 if (halStatus != eHAL_STATUS_SUCCESS)
1278 {
1279 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1280 }
1281 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1282}
1283
Shailender Karmuchia734f332013-04-19 14:02:48 -07001284static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1285 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001286 eCsrRoamResult roamResult )
1287{
1288 struct net_device *dev = pAdapter->dev;
1289 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1290 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301291 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05301292 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001293 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1294 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001295#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001296 int ft_carrier_on = FALSE;
1297#endif
1298 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301299 v_BOOL_t hddDisconInProgress = FALSE;
1300
1301 /* HDD has initiated disconnect, do not send connect result indication
1302 * to kernel as it will be handled by __cfg80211_disconnect.
1303 */
1304 if(( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) &&
1305 (( eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
1306 ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)) )
1307 {
1308 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1309 FL(" Disconnect from HDD in progress "));
1310 hddDisconInProgress = TRUE;
1311 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001312
Jeff Johnson295189b2012-06-20 16:38:30 -07001313 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1314 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301315 if ( !hddDisconInProgress )
1316 {
1317 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05301318 "%s: Set HDD connState to eConnectionState_Associated",
1319 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301320 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1321 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001322
c_hpothu44ff4e02014-05-08 00:13:57 +05301323 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001324 // Save the connection info from CSR...
1325 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1326#ifdef FEATURE_WLAN_WAPI
1327 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1328 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1329 {
1330 pAdapter->wapi_info.fIsWapiSta = 1;
1331 }
1332 else
1333 {
1334 pAdapter->wapi_info.fIsWapiSta = 0;
1335 }
1336#endif /* FEATURE_WLAN_WAPI */
1337
1338 // indicate 'connect' status to userspace
1339 hdd_SendAssociationEvent(dev,pRoamInfo);
1340
1341
Shailender Karmuchia734f332013-04-19 14:02:48 -07001342 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001343 INIT_COMPLETION(pAdapter->linkup_event_var);
1344
1345 /*
1346 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1347 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 -07001348 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001349 know that the device is getting activated properly.
1350 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001351#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05301352 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07001353 {
1354#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001355 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001356 pAdapter->isLinkUpSvcNeeded = TRUE;
1357
Shailender Karmuchia734f332013-04-19 14:02:48 -07001358 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 pAdapter->isLinkUpSvcNeeded = TRUE;
1360
1361 // Switch on the Carrier to activate the device
1362 netif_carrier_on(dev);
1363
1364 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1365 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1366 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001367 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001368 {
1369 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1370 }
1371
1372 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1373 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001374#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001376 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001377 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001379 }
1380#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05301381 /* Check for STAID */
1382 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
1383 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1384 else
1385 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001386
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001387#ifdef FEATURE_WLAN_TDLS
1388 wlan_hdd_tdls_connection_callback(pAdapter);
1389#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001390 //For reassoc, the station is already registered, all we need is to change the state
1391 //of the STA in TL.
1392 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05301393 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07001394 if( !pRoamInfo->fReassocReq )
1395 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001396 struct cfg80211_bss *bss;
1397#ifdef WLAN_FEATURE_VOWIFI_11R
1398 u8 *pFTAssocRsp = NULL;
1399 unsigned int assocRsplen = 0;
1400 u8 *pFTAssocReq = NULL;
1401 unsigned int assocReqlen = 0;
1402 struct ieee80211_channel *chan;
1403#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001404 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001406
1407 /* add bss_id to cfg80211 data base */
1408 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1409 if (NULL == bss)
1410 {
1411 pr_err("wlan: Not able to create BSS entry\n");
Katya Nigam346d4e92014-09-02 16:16:12 +05301412 netif_carrier_off(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001413 return eHAL_STATUS_FAILURE;
1414 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001415#ifdef WLAN_FEATURE_VOWIFI_11R
1416 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001417 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001418 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001419
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001420 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001421 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001422 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001423 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001424 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001425 // pFTAssocRsp needs to point to the IEs
1426 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1427 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1428 (unsigned int)pFTAssocRsp[0],
1429 (unsigned int)pFTAssocRsp[1]);
1430 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001431 }
1432 else
1433 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001434 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1435 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001436 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001437
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001438 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001439 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001440 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001441 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001442 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001443 if(!ft_carrier_on)
1444 {
1445 // pFTAssocReq needs to point to the IEs
1446 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1447 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1448 (unsigned int)pFTAssocReq[0],
1449 (unsigned int)pFTAssocReq[1]);
1450 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1451 }
1452 else
1453 {
1454 /* This should contain only the FTIEs */
1455 assocReqlen = pRoamInfo->nAssocReqLength;
1456 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001457 }
1458 else
1459 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001460 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1461 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001462 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001463
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001464 if(ft_carrier_on)
1465 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301466 if ( !hddDisconInProgress )
1467 {
1468 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001469 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301470 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001471 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301472 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001473 assocRsplen);
Girish Gowlidf0ed732014-08-11 12:39:39 +05301474#ifdef DEBUG_ROAM_DELAY
1475 //HACK we are using the buff len as Auth Type
1476 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1477#endif
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301478 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001479 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1480 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301481 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301482 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1483 {
1484 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1485 pRoamInfo->fAuthRequired = FALSE;
1486
1487 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1488 pRoamInfo->bssid,
1489 HDD_MAC_ADDR_LEN);
1490 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1491 pRoamInfo->peerMac,
1492 HDD_MAC_ADDR_LEN);
1493 pHddStaCtx->roam_info.roamId = roamId;
1494 pHddStaCtx->roam_info.roamStatus = roamStatus;
1495 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1496 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001497 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301498 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001499 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001500 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001501 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001502 cfg80211_connect_result(dev, pRoamInfo->bssid,
1503 pFTAssocReq, assocReqlen,
1504 pFTAssocRsp, assocRsplen,
1505 WLAN_STATUS_SUCCESS,
1506 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001507 }
1508 }
1509 else
1510#endif
1511 {
1512 /* wpa supplicant expecting WPA/RSN IE in connect result */
1513 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1514 pAdapter->sessionId,
1515 &reqRsnLength,
1516 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001517
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001518 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1519 pAdapter->sessionId,
1520 &rspRsnLength,
1521 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301522 if ( !hddDisconInProgress )
1523 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001524#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301525 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05301526 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301527 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Mukul Sharma84f27252014-07-14 18:11:42 +05301528#ifdef DEBUG_ROAM_DELAY
1529 //HACK we are using the buff len as Auth Type
1530 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1531#endif
1532 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301533 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001534#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001535
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301536 {
1537 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301538 "%s: sending connect indication to nl80211:"
1539 " for bssid " MAC_ADDRESS_STR
1540 " reason:%d and Status:%d\n",
1541 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1542 roamResult, roamStatus);
1543
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301544 /* inform connect result to nl80211 */
1545 cfg80211_connect_result(dev, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001546 reqRsnIe, reqRsnLength,
1547 rspRsnIe, rspRsnLength,
1548 WLAN_STATUS_SUCCESS,
1549 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301550 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001551 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001552 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301553 if ( !hddDisconInProgress )
1554 {
1555 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07001556#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301557 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07001558#endif
1559 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301560 // Register the Station with TL after associated...
1561 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001562 pRoamInfo,
1563 pHddStaCtx->conn_info.staId[ 0 ],
1564 NULL,
1565 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301566 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001567 }
1568 else
1569 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001570 /* wpa supplicant expecting WPA/RSN IE in connect result */
1571 /* in case of reassociation also need to indicate it to supplicant */
1572 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1573 pAdapter->sessionId,
1574 &reqRsnLength,
1575 reqRsnIe);
1576
1577 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301579 if( pRoamInfo->fAuthRequired )
1580 {
1581 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1582 pHddStaCtx->conn_info.staId[ 0 ],
1583 WLANTL_STA_CONNECTED );
1584 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1585 }
1586 else
1587 {
1588 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1589 "%s: staId: %d Changing TL state to AUTHENTICATED",
1590 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1591 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1592 pHddStaCtx->conn_info.staId[ 0 ],
1593 WLANTL_STA_AUTHENTICATED );
1594 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1595 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 }
1597
1598 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1599 {
1600 // perform any WMM-related association processing
1601 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1602 }
1603 else
1604 {
1605 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001606 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001607 vosStatus, vosStatus );
1608 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001609#ifdef WLAN_FEATURE_11W
1610 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1611 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1612#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301613
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05301615 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301616 {
1617 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05301618 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301619 }
Mukul Sharma84f27252014-07-14 18:11:42 +05301620#ifdef DEBUG_ROAM_DELAY
1621 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
1622#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001623 }
1624 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001625 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001626 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1627
1628 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001629 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001630 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1631 " reason:%d and Status:%d\n",
1632 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1633 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001634 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001635 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1636 " reason:%d and Status:%d\n",
1637 MAC_ADDR_ARRAY(pWextState->req_bssId),
1638 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001639
Abhishek Singhf4669da2014-05-26 15:07:49 +05301640 /* Set connection state to eConnectionState_NotConnected only when CSR
1641 * has completed operation - with a ASSOCIATION_FAILURE status
1642 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301643 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05301644 {
1645 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1646 "%s: Set HDD connState to eConnectionState_NotConnected",
1647 __func__);
1648 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1649 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05301650 if((pHddCtx->concurrency_mode <= 1) &&
1651 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07001652 {
1653 pHddCtx->isAmpAllowed = VOS_TRUE;
1654 }
1655
1656 //If the Device Mode is Station
1657 // and the P2P Client is Connected
1658 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001659
1660 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001661 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001662 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1663 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05301664 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07001665 {
1666 //Enable BMPS only of other Session is P2P Client
1667 hdd_context_t *pHddCtx = NULL;
1668 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1669
1670 if (NULL != pVosContext)
1671 {
1672 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1673
1674 if(NULL != pHddCtx)
1675 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301676 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301677 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1678 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301679 {
1680 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001681 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301682 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001683 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301684 hdd_enable_bmps_imps(pHddCtx);
1685 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001686 }
1687 }
1688 }
1689
James Zmudafbf5ffc2013-03-25 12:45:35 -07001690 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001691 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301692 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07001693 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301694 if (pRoamInfo)
1695 hddLog(VOS_TRACE_LEVEL_ERROR,
1696 "%s: send connect failure to nl80211:"
1697 " for bssid " MAC_ADDRESS_STR
1698 " reason:%d and Status:%d\n" ,
1699 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1700 roamResult, roamStatus);
1701 else
1702 hddLog(VOS_TRACE_LEVEL_ERROR,
1703 "%s: connect failed:"
1704 " for bssid " MAC_ADDRESS_STR
1705 " reason:%d and Status:%d\n" ,
1706 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
1707 roamResult, roamStatus);
1708
c_hpothudaa90e22014-06-24 17:23:43 +05301709 /*Clear the roam profile*/
1710 hdd_clearRoamProfileIe( pAdapter );
1711
James Zmudafbf5ffc2013-03-25 12:45:35 -07001712 /* inform association failure event to nl80211 */
1713 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1714 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001715 if (pRoamInfo)
1716 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1717 NULL, 0, NULL, 0,
1718 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1719 GFP_KERNEL );
1720 else
1721 cfg80211_connect_result ( dev, pWextState->req_bssId,
1722 NULL, 0, NULL, 0,
1723 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1724 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001725 }
1726 else
1727 {
Sushant Kaushik21f28232014-12-18 11:42:46 +05301728 if (pRoamInfo){
1729 eCsrAuthType authType =
1730 pWextState->roamProfile.AuthType.authType[0];
1731 v_BOOL_t isWep = (authType == eCSR_AUTH_TYPE_OPEN_SYSTEM) ||
1732 (authType == eCSR_AUTH_TYPE_SHARED_KEY);
1733
1734 /* In case of OPEN-WEP or SHARED-WEP authentication,
1735 * send exact protocol reason code. This enables user
1736 * applications to reconnect the station with correct
1737 * configuration.
1738 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001739 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1740 NULL, 0, NULL, 0,
Sushant Kaushik21f28232014-12-18 11:42:46 +05301741 isWep ? pRoamInfo->reasonCode :
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001742 WLAN_STATUS_UNSPECIFIED_FAILURE,
1743 GFP_KERNEL );
Sushant Kaushik21f28232014-12-18 11:42:46 +05301744 } else
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001745 cfg80211_connect_result ( dev, pWextState->req_bssId,
1746 NULL, 0, NULL, 0,
1747 WLAN_STATUS_UNSPECIFIED_FAILURE,
1748 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001749 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001751
Kumar Anand82c009f2014-05-29 00:29:42 -07001752 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001753
c_hpothu24f40982014-04-18 18:00:36 +05301754 if (pRoamInfo)
1755 {
1756 WLANTL_AssocFailed(pRoamInfo->staId);
1757 }
Mihir Sheteb7337272014-04-11 15:53:08 +05301758
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301759 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 netif_tx_disable(dev);
1761 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001762
Jeff Johnson295189b2012-06-20 16:38:30 -07001763 }
1764
Sushant Kaushikbf584e92014-08-06 17:59:20 +05301765 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301766 {
1767 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
1768 if (pHostapdAdapter != NULL)
1769 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05301770 /* Restart SAP if its operating channel is different
1771 * from AP channel.
1772 */
1773 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
1774 (int)pRoamInfo->pBssDesc->channelId)
1775 {
1776 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
1777 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
1778 (int)pRoamInfo->pBssDesc->channelId);
Deepthi Gowric9c777d2014-12-10 16:17:11 +05301779 hdd_hostapd_stop(pHostapdAdapter->dev);
Sushant Kaushikbf584e92014-08-06 17:59:20 +05301780 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301781 }
1782 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001783 return eHAL_STATUS_SUCCESS;
1784}
1785
1786/**============================================================================
1787 *
Jeff Johnson81c17882013-05-03 09:53:35 -07001788 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07001789 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07001790
Jeff Johnson295189b2012-06-20 16:38:30 -07001791 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07001792static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
1793 tCsrRoamInfo *pRoamInfo,
1794 tANI_U32 roamId,
1795 eRoamCmdStatus roamStatus,
1796 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07001797{
Jeff Johnson81c17882013-05-03 09:53:35 -07001798 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
1799 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
1800
Jeff Johnson295189b2012-06-20 16:38:30 -07001801 switch( roamResult )
1802 {
1803 // both IBSS Started and IBSS Join should come in here.
1804 case eCSR_ROAM_RESULT_IBSS_STARTED:
1805 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001806 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07001807 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001808 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1809 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001810
Jeff Johnson81c17882013-05-03 09:53:35 -07001811 if (NULL == pRoamInfo)
1812 {
1813 VOS_ASSERT(0);
1814 return;
1815 }
1816
1817 /* When IBSS Started comes from CSR, we need to move
1818 * connection state to IBSS Disconnected (meaning no peers
1819 * are in the IBSS).
1820 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05301821 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1822 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
1823 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07001824 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
1825 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05301826 /*notify wmm */
1827 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001828 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1829 hdd_roamRegisterSTA (pAdapter, pRoamInfo,
1830 IBSS_BROADCAST_STAID,
1831 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001832
Jeff Johnson81c17882013-05-03 09:53:35 -07001833 if (pRoamInfo->pBssDesc)
1834 {
1835 struct cfg80211_bss *bss;
1836
1837 /* we created the IBSS, notify supplicant */
1838 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
1839 MAC_ADDRESS_STR,
1840 __func__, pAdapter->dev->name,
1841 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
1842
1843 /* we must first give cfg80211 the BSS information */
1844 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1845 if (NULL == bss)
1846 {
1847 hddLog(VOS_TRACE_LEVEL_ERROR,
1848 "%s: %s: unable to create IBSS entry",
1849 __func__, pAdapter->dev->name);
1850 return;
1851 }
1852
1853 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07001854 cfg80211_put_bss(
1855#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1856 pHddCtx->wiphy,
1857#endif
1858 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07001859 }
1860
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 break;
1862 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001863
Jeff Johnson295189b2012-06-20 16:38:30 -07001864 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
1865 {
Jeff Johnson81c17882013-05-03 09:53:35 -07001866 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
1867 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07001868 break;
1869 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001870
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07001872 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
1873 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001874 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001875 }
1876
Jeff Johnson81c17882013-05-03 09:53:35 -07001877 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001878}
1879
1880/**============================================================================
1881 *
1882 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
1883 This information is passed to iwconfig later. The peer that joined
1884 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001885 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001886 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001887
Jeff Johnson295189b2012-06-20 16:38:30 -07001888 ===========================================================================*/
1889static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
1890{
1891 int fSuccess = FALSE;
1892 int idx = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001893
Jeff Johnson295189b2012-06-20 16:38:30 -07001894 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1895 {
1896 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
1897 {
1898 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001899
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001901
Jeff Johnson295189b2012-06-20 16:38:30 -07001902 fSuccess = TRUE;
1903 break;
1904 }
1905 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001906
1907 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07001908}
1909/**============================================================================
1910 *
1911 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001912 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001913 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001914
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07001916static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07001917{
1918 int fSuccess = FALSE;
1919 int idx = 0;
1920 v_U8_t valid_idx = 0;
1921 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07001922 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001923 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001924
Jeff Johnson295189b2012-06-20 16:38:30 -07001925 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1926 {
1927 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
1928 {
1929 pHddStaCtx->conn_info.staId[ idx ] = 0;
1930
1931 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
1932
1933 fSuccess = TRUE;
Ravi Joshi8a934352013-09-25 16:46:58 -07001934
Jeff Johnson295189b2012-06-20 16:38:30 -07001935 // Note the deleted Index, if its 0 we need special handling
1936 del_idx = idx;
Ravi Joshi8a934352013-09-25 16:46:58 -07001937
1938 empty_slots++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 }
1940 else
1941 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001942 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001943 {
1944 valid_idx = idx;
1945 }
Ravi Joshi8a934352013-09-25 16:46:58 -07001946 else
1947 {
1948 // Found an empty slot
1949 empty_slots++;
1950 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 }
1952 }
1953
Ravi Joshi8a934352013-09-25 16:46:58 -07001954 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
1955 {
1956 // Last peer departed, set the IBSS state appropriately
1957 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001958 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07001959 "Last IBSS Peer Departed!!!" );
1960 }
1961
Jeff Johnson295189b2012-06-20 16:38:30 -07001962 // Find next active staId, to have a valid sta trigger for TL.
1963 if (fSuccess == TRUE)
1964 {
1965 if (del_idx == 0)
1966 {
1967 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
1968 {
1969 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
1970 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
1971 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
1972
1973 pHddStaCtx->conn_info.staId[valid_idx] = 0;
1974 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
1975 }
1976 }
1977 }
1978 return( fSuccess );
1979}
1980
1981/**============================================================================
1982 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001983 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07001984 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001985
Jeff Johnson295189b2012-06-20 16:38:30 -07001986 ===========================================================================*/
1987static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
1988{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001989 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05301990 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1991 "%s: IBSS Connect Indication from SME!!! "
1992 "Set HDD connState to eConnectionState_IbssConnected",
1993 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001994 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
1995 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
1996
1997 // Save the connection info from CSR...
1998 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
1999
2000 // Send the bssid address to the wext.
2001 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002003 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2004 if (NULL == bss)
2005 {
2006 hddLog(VOS_TRACE_LEVEL_ERROR,
2007 "%s: %s: unable to create IBSS entry",
2008 __func__, pAdapter->dev->name);
2009 return eHAL_STATUS_FAILURE;
2010 }
Yue Maf49ba872013-08-19 12:04:25 -07002011 cfg80211_put_bss(
2012#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2013 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
2014#endif
2015 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07002016
2017 return( eHAL_STATUS_SUCCESS );
2018}
2019/**============================================================================
2020 *
Mukul Sharmad2589a52014-04-23 21:06:25 +05302021 @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
2022 suspend related data which was cleared during roaming in FWR.
2023
2024 ===========================================================================*/
2025static void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
2026{
2027 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
2028 hdd_adapter_t *pAdapter;
2029 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
2030 ENTER();
2031
2032 spin_lock(&pHddCtx->filter_lock);
2033 if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
2034 {
2035 pHddCtx->sus_res_mcastbcast_filter =
2036 pHddCtx->configuredMcastBcastFilter;
2037 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
2038 hddLog(VOS_TRACE_LEVEL_INFO, FL("offload: callback to associated"));
2039 hddLog(VOS_TRACE_LEVEL_INFO,
2040 FL("saving configuredMcastBcastFilter = %d"),
2041 pHddCtx->configuredMcastBcastFilter);
2042 hddLog(VOS_TRACE_LEVEL_INFO,
2043 FL("offload: calling hdd_conf_mcastbcast_filter"));
2044 }
2045 spin_unlock(&pHddCtx->filter_lock);
2046
2047 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
2048 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
2049 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
2050
2051 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
2052 //No need to configure GTK Offload from here because it might possible
2053 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
2054 //be handled as part of cfg80211_set_rekey_data processing.
2055 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
2056 {
2057 pAdapter = pAdapterNode->pAdapter;
2058 if( pAdapter &&
2059 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
2060 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
2061 {
2062 if (pHddCtx->cfg_ini->fhostArpOffload)
2063 {
2064 //Configure ARPOFFLOAD
2065 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
2066 if (!VOS_IS_STATUS_SUCCESS(vstatus))
2067 {
2068 hddLog(VOS_TRACE_LEVEL_ERROR,
2069 FL("Failed to disable ARPOffload Feature %d"), vstatus);
2070 }
2071 }
2072#ifdef WLAN_NS_OFFLOAD
2073 //Configure NSOFFLOAD
2074 if (pHddCtx->cfg_ini->fhostNSOffload)
2075 {
2076 hdd_conf_ns_offload(pAdapter, TRUE);
2077 }
2078#endif
Mukul Sharma25e70c32014-05-22 12:50:24 +05302079#ifdef WLAN_FEATURE_PACKET_FILTERING
2080 /* During suspend, configure MC Addr list filter to the firmware
2081 * function takes care of checking necessary conditions before
2082 * configuring.
2083 */
2084 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
2085#endif
Mukul Sharmad2589a52014-04-23 21:06:25 +05302086 }
2087 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2088 pAdapterNode = pNext;
2089 }
2090 EXIT();
2091}
2092
2093/**============================================================================
2094 *
Jeff Johnson295189b2012-06-20 16:38:30 -07002095 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002096
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002098static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2099 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002100 eCsrRoamResult roamResult )
2101{
2102 eCsrEncryptionType connectedCipherAlgo;
2103 v_BOOL_t fConnected = FALSE;
2104 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2105 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2106 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2107 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07002108
2109 if (NULL == pRoamInfo)
2110 {
2111 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
2112 return eHAL_STATUS_FAILURE;
2113 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002114 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002115 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07002116 // not require upper layer authentication) we can put TL directly into 'authenticated'
2117 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2119 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
2120 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002121
Jeff Johnson295189b2012-06-20 16:38:30 -07002122 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2123 if( fConnected )
2124 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002125 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
2126 {
2127 v_U8_t staId;
2128
2129 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2130
2131 if ( 0 == memcmp( pRoamInfo->peerMac,
2132 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
2133 {
2134 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2135 IBSS_BROADCAST_STAID);
2136 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2137 }
2138 else
2139 {
2140 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
2141 (v_MACADDR_t*)pRoamInfo->peerMac,
2142 &staId);
2143 if ( VOS_STATUS_SUCCESS == vosStatus )
2144 {
2145 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2146 "WLAN TL STA Ptk Installed for STAID=%d", staId);
2147 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2148 staId);
2149 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2150 }
2151 }
2152 }
2153 else
2154 {
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302155 // TODO: Considering getting a state machine in HDD later.
2156 // This routine is invoked twice. 1)set PTK 2)set GTK.
2157 // The folloing if statement will be TRUE when setting GTK.
2158 // At this time we don't handle the state in detail.
2159 // Related CR: 174048 - TL not in authenticated state
2160 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
2161 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
2162 {
2163 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
2164 "for StaId= %d. Changing TL state to AUTHENTICATED",
2165 pHddStaCtx->conn_info.staId[ 0 ] );
2166
2167 // Connections that do not need Upper layer authentication,
2168 // transition TL to 'Authenticated' state after the keys are set.
2169 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2170 pHddStaCtx->conn_info.staId[ 0 ],
2171 WLANTL_STA_AUTHENTICATED );
2172
2173 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Mukul Sharmad2589a52014-04-23 21:06:25 +05302174 //Need to call offload because when roaming happen at that time fwr
2175 //clean offload info as part of the DelBss
2176 // No need to configure offload if host was not suspended
2177 spin_lock(&pHddCtx->filter_lock);
2178 if(pHddCtx->hdd_wlan_suspended)
2179 {
2180 spin_unlock(&pHddCtx->filter_lock);
2181 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
2182 }
2183 else
2184 {
2185 spin_unlock(&pHddCtx->filter_lock);
2186 }
Mukul Sharma84f27252014-07-14 18:11:42 +05302187#ifdef DEBUG_ROAM_DELAY
2188 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
2189#endif
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302190 }
2191 else
2192 {
2193 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2194 pHddStaCtx->conn_info.staId[ 0 ]);
Mukul Sharma84f27252014-07-14 18:11:42 +05302195#ifdef DEBUG_ROAM_DELAY
2196 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
2197#endif
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302198 }
2199
2200 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002201 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002202 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302203 else
2204 {
2205 // possible disassoc after issuing set key and waiting set key complete
2206 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2207 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002208
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 EXIT();
2210 return( eHAL_STATUS_SUCCESS );
2211}
2212/**============================================================================
2213 *
2214 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2215 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002216static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002217 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002218{
Jeff Johnson295189b2012-06-20 16:38:30 -07002219 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2220
2221 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2222 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2223 {
2224 struct iw_michaelmicfailure msg;
2225 union iwreq_data wreq;
2226 memset(&msg, '\0', sizeof(msg));
2227 msg.src_addr.sa_family = ARPHRD_ETHER;
2228 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002229 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2230 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002231
Jeff Johnson295189b2012-06-20 16:38:30 -07002232 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2233 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002234 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002235 msg.flags = IW_MICFAILURE_PAIRWISE;
2236 memset(&wreq, 0, sizeof(wreq));
2237 wreq.data.length = sizeof(msg);
2238 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002239 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002240 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002241 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2242 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2243 NL80211_KEYTYPE_GROUP :
2244 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002245 pRoamInfo->u.pMICFailureInfo->keyId,
2246 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002247 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002248
Jeff Johnson295189b2012-06-20 16:38:30 -07002249 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002250
Jeff Johnson295189b2012-06-20 16:38:30 -07002251 return( eHAL_STATUS_SUCCESS );
2252}
2253
2254/**============================================================================
2255 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002256 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002257 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002258
Jeff Johnson295189b2012-06-20 16:38:30 -07002259 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002260static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2261 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 eCsrRoamResult roamResult )
2263{
2264 VOS_STATUS vosStatus;
2265
2266 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2267 switch( roamResult )
2268 {
2269 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2270 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002271 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002272 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002273
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002274 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002275 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2276 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2277 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002279
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
2281 {
2282 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2283 "New IBSS peer but we already have the max we can handle. Can't register this one" );
2284 break;
2285 }
2286
2287 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2288
Shailender Karmuchia734f332013-04-19 14:02:48 -07002289 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2290 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2291 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2292
2293 // Register the Station with TL for the new peer.
Jeff Johnson295189b2012-06-20 16:38:30 -07002294 vosStatus = hdd_roamRegisterSTA( pAdapter,
2295 pRoamInfo,
2296 pRoamInfo->staId,
2297 (v_MACADDR_t *)pRoamInfo->peerMac,
2298 pRoamInfo->pBssDesc );
2299 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2300 {
2301 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002302 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002303 vosStatus, vosStatus );
2304 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002305 pHddStaCtx->ibss_sta_generation++;
2306 memset(&staInfo, 0, sizeof(staInfo));
2307 staInfo.filled = 0;
2308 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2309
2310 cfg80211_new_sta(pAdapter->dev,
2311 (const u8 *)pRoamInfo->peerMac,
2312 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002313
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002314 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2315 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2316 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2317 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2318 {
2319 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2320 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2321 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2322
2323 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002324 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002325 pHddStaCtx->ibss_enc_key.encType);
2326
2327 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2328 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2329
2330 if ( VOS_STATUS_SUCCESS != vosStatus )
2331 {
2332 hddLog(VOS_TRACE_LEVEL_ERROR,
2333 "%s: sme_RoamSetKey failed, returned %d",
2334 __func__, vosStatus);
2335 return VOS_STATUS_E_FAILURE;
2336 }
2337 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002338 netif_carrier_on(pAdapter->dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302339 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002340 netif_tx_start_all_queues(pAdapter->dev);
2341 break;
2342 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002343
Jeff Johnson295189b2012-06-20 16:38:30 -07002344 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2345 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002346
Jeff Johnson295189b2012-06-20 16:38:30 -07002347 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002348
Jeff Johnson295189b2012-06-20 16:38:30 -07002349 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002350 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002351 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2352 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002353 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002354
Ravi Joshicc57ed42013-10-12 16:31:25 -07002355 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002356 {
2357 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2358 "IBSS peer departed by cannot find peer in our registration table with TL" );
2359 }
2360
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002361 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002362 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2363 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2364 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2365 pRoamInfo->staId );
2366
Jeff Johnson295189b2012-06-20 16:38:30 -07002367 hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
2368
2369 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002370 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002371
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002372 cfg80211_del_sta(pAdapter->dev,
2373 (const u8 *)&pRoamInfo->peerMac,
2374 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 break;
2376 }
2377 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2378 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002379 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2380 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 // Stop only when we are inactive
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302382 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002383 netif_tx_disable(pAdapter->dev);
2384 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05302385 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2386 "%s: Set HDD connState to eConnectionState_NotConnected",
2387 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002388 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002389
Jeff Johnson295189b2012-06-20 16:38:30 -07002390 // Send the bssid address to the wext.
2391 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2392 // clean up data path
2393 hdd_disconnect_tx_rx(pAdapter);
2394 break;
2395 }
2396 default:
2397 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002398
Jeff Johnson295189b2012-06-20 16:38:30 -07002399 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002400
Jeff Johnson295189b2012-06-20 16:38:30 -07002401 return( eHAL_STATUS_SUCCESS );
2402}
2403
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002404#ifdef FEATURE_WLAN_TDLS
2405/**============================================================================
2406 *
2407 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2408 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2409 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002410
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002411 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002412VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
2413 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002414{
2415 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002416 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002417 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2418 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002419 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2420 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002421 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2422 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002423
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002424 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2425 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002426 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002427 "%s not connected. ignored", __func__);
2428 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002429 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002430
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002431 /*
2432 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2433 * be peer MAC, here we are wokrking on direct Link
2434 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002435 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002436
2437 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002438
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002439 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002440 sizeof(tSirMacAddr) );
2441
2442 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2443 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2444
2445 /* set the QoS field appropriately ..*/
2446 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2447 : (staDesc.ucQosEnabled = 0) ;
2448
2449 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002450 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002451
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002452 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002453
2454 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002455 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002456
Shailender Karmuchia734f332013-04-19 14:02:48 -07002457 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002458 * UMA is ready we inform TL to do frame translation.
2459 */
2460 staDesc.ucSwFrameTXXlation = 1;
2461 staDesc.ucSwFrameRXXlation = 1;
2462 staDesc.ucAddRmvLLC = 1;
2463
2464 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002465 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002466
2467 /* tdls Direct Link do not need bcastSig */
2468 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002469
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002470#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2471 if(staDesc.ucProtectedFrame)
2472 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2473 else
2474 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2475#endif
2476
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302477 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002478
Shailender Karmuchia734f332013-04-19 14:02:48 -07002479 /* Register the Station with TL... */
2480 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2481 hdd_rx_packet_cbk,
2482 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002483 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002484
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002485 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2486 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002487 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002488 "%s: WLANTL_RegisterSTAClient() failed to register. "
2489 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002490 return vosStatus;
2491 }
2492
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002493 if ( cfg_param->dynSplitscan &&
2494 ( VOS_TIMER_STATE_RUNNING !=
2495 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2496 {
2497 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2498 cfg_param->trafficMntrTmrForSplitScan);
2499 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002500 return( vosStatus );
2501}
2502
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002503static VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
2504{
2505 VOS_STATUS vosStatus;
2506 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2507 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2508 {
2509 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2510 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002511 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002512 __func__, staId, vosStatus, vosStatus );
2513 }
2514 return( vosStatus );
2515}
2516
2517
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002518/*
2519 * HDD interface between SME and TL to ensure TDLS client registration with
2520 * TL in case of new TDLS client is added and deregistration at the time
2521 * TDLS client is deleted.
2522 */
2523
Shailender Karmuchia734f332013-04-19 14:02:48 -07002524eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2525 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002526 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002527 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002528 eCsrRoamResult roamResult)
2529{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002530 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002531 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002532 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002533
2534#ifdef WLAN_FEATURE_TDLS_DEBUG
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302535 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002536 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2537 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2538 "ADD_TDLS_PEER" :
2539 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2540 "DEL_TDLS_PEER" :
2541 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2542 "DEL_TDLS_PEER_IND" :
2543 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2544 "DEL_ALL_TDLS_PEER_IND" :
2545 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2546 "UPDATE_TDLS_PEER" :
2547 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2548 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2549 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002550#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002551 switch( roamResult )
2552 {
2553 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2554 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002555 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2556 {
2557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002558 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002559 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002560 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002561 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002562
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002563 /* check if there is available index for this new TDLS STA */
2564 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2565 {
2566 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2567 {
2568 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2569 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2570
2571 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002572 ("TDLS: STA IDX at %d is %d "
2573 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002574 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002575 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002576
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002577 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002578 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2579 status = eHAL_STATUS_SUCCESS ;
2580 break ;
2581 }
2582 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002583 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002584 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002585 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002586 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2587 "wlan_hdd_tdls_set_sta_id() failed");
2588 return VOS_FALSE;
2589 }
2590
2591 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302592 /* store the ucast signature , if required for further reference. */
2593
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002594 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302595 /* start TDLS client registration with TL */
2596 status = hdd_roamRegisterTDLSSTA( pAdapter,
2597 pRoamInfo->peerMac,
2598 pRoamInfo->staId,
2599 pRoamInfo->ucastSig);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002600 }
2601 else
2602 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002603 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002604 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002605 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002606 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002607 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002608 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002609 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002610 break ;
2611 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002612 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
2613 {
2614 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2615 {
2616 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2617 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
2618 }
2619 /* store the ucast signature which will be used later when
2620 * registering to TL
2621 */
2622 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
2623 complete(&pAdapter->tdls_add_station_comp);
2624 break;
2625 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302626 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
2627 {
2628 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2629 {
2630 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2631 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
2632 }
2633 complete(&pAdapter->tdls_link_establish_req_comp);
2634 break;
2635 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002636 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002637 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002638 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002639 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002640 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002641 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2642 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002643 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002645 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2646
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302647 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05302648 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002649 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05302650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2651 " Current status for peer" MAC_ADDRESS_STR "is %d",
2652 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
2653 if (TDLS_IS_CONNECTED(curr_peer))
2654 {
2655 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2656 wlan_hdd_tdls_decrement_peer_count(pAdapter);
2657 }
2658 else if (eTDLS_LINK_CONNECTING == curr_peer->link_status)
2659 {
2660 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2661 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002662 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002663 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002664
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002665 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2666 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
2667 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002668 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002669 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002670 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002671 break ;
2672 }
2673 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002674 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002675 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002676 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002677 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
2678 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002679 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002680 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2681 "%s: Sending teardown to supplicant with reason code %u",
2682 __func__, pRoamInfo->reasonCode);
2683
2684#ifdef CONFIG_TDLS_IMPLICIT
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302685 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002686 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002687#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002688 status = eHAL_STATUS_SUCCESS ;
2689 break ;
2690 }
2691 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
2692 {
2693 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002694 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002695 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002696 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2697 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002698 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002699 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002700 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002701 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002702 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002703 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
2704 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
2705 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002706
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002707 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002708 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002709 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2710 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002711
2712 status = eHAL_STATUS_SUCCESS ;
2713 }
2714 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05302715 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002716 break ;
2717 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002718 default:
2719 {
2720 break ;
2721 }
2722 }
2723
2724 return status ;
2725}
2726#endif
2727
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002728static void iw_full_power_cbfn (void *pContext, eHalStatus status)
2729{
2730 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
2731 hdd_context_t *pHddCtx = NULL;
2732 int ret;
2733
2734 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
2735 {
2736 hddLog(VOS_TRACE_LEVEL_ERROR,
2737 "%s: Bad param, pAdapter [%p]",
2738 __func__, pAdapter);
2739 return;
2740 }
2741
2742 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2743 ret = wlan_hdd_validate_context(pHddCtx);
2744 if (0 != ret)
2745 {
2746 hddLog(VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05302747 "%s: HDD context is not valid",__func__);
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002748 return;
2749 }
2750
2751 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2752 {
2753 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
2754 }
2755}
2756
Shailender Karmuchia734f332013-04-19 14:02:48 -07002757eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002758 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
2759{
2760 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2761 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302762 hdd_wext_state_t *pWextState = NULL;
2763 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002764 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07002765 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002766
2767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002768 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002769 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002770
2771 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302772 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002773 {
2774 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302775 "invalid adapter or adapter has invalid magic");
2776 return eHAL_STATUS_FAILURE;
2777 }
2778
2779 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2780 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2781
2782 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2783 {
2784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2785 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002786 return eHAL_STATUS_FAILURE;
2787 }
2788
Jeff Johnson295189b2012-06-20 16:38:30 -07002789 switch( roamStatus )
2790 {
2791 case eCSR_ROAM_SESSION_OPENED:
2792 if(pAdapter != NULL)
2793 {
2794 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2795 complete(&pAdapter->session_open_comp_var);
2796 }
2797 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002798
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002799#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
2800 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002801 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07002802 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 * interface down */
2804 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05302805 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
2806 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05302807 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07002808 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2809 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2810 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2812 }
2813 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05302814 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002815 break;
2816
2817 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002818 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07002819 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07002820 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07002821 // eCSR_ROAM_SHOULD_ROAM will be received.
2822 // Where in we will not mark the link down
2823 // Also we want to stop tx at this point when we will be
2824 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002825 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 {
2827 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302828 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002829 netif_tx_disable(dev);
Mukul Sharma84f27252014-07-14 18:11:42 +05302830#ifdef DEBUG_ROAM_DELAY
2831 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
2832#endif
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002833 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002834 * Deregister for this STA with TL with the objective to flush
2835 * all the packets for this STA from wmm_tx_queue. If not done here,
2836 * we would run into a race condition (CR390567) wherein TX
2837 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2838 * been deleted. And, these packets get assigned with a STA idx of
2839 * self-sta (since the peer STA has been deleted) and get transmitted
2840 * on the new channel before the reassoc request. Since there will be
2841 * no ACK on the new channel, each packet gets retransmitted which
2842 * takes several seconds before the transmission of reassoc request.
2843 * This leads to reassoc-timeout and roam failure.
2844 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002845 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2846 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2847 {
2848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2849 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2850 pHddStaCtx->conn_info.staId[0], status, status );
2851 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002852 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002853 }
2854 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002855 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002856 break;
2857#endif
2858
2859 case eCSR_ROAM_SHOULD_ROAM:
2860 // Dont need to do anything
2861 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 struct net_device *dev = pAdapter->dev;
2863 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2864 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302865 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002867#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002868 if (pHddStaCtx->ft_carrier_on == FALSE)
2869 {
2870#endif
2871 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002872#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 }
2874#endif
2875
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002876#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002877 //We should clear all sta register with TL, for now, only one.
2878 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2879 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2880 {
2881 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2882 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2883 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002884 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002886#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002887 }
2888 break;
2889 case eCSR_ROAM_LOSTLINK:
2890 case eCSR_ROAM_DISASSOCIATED:
2891 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2893 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05302894 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07002895 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2896 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07002897 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2898 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302899 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07002900 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08002901
2902 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
2903 pHddCtx->configuredMcastBcastFilter =
2904 pHddCtx->sus_res_mcastbcast_filter;
2905 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
2906 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302907
Amar Singhald53568e2013-09-26 11:03:45 -07002908 hddLog(VOS_TRACE_LEVEL_INFO,
2909 "offload: disassociation happening, restoring configuredMcastBcastFilter");
2910 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
2911 pHddCtx->configuredMcastBcastFilter);
2912 hddLog(VOS_TRACE_LEVEL_INFO,
2913 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2915 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002916#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302917 /* Call to clear any MC Addr List filter applied after
2918 * successful connection.
2919 */
2920 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002921#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 }
2923 break;
2924 case eCSR_ROAM_IBSS_LEAVE:
2925 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2926 "****eCSR_ROAM_IBSS_LEAVE****");
2927 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2928 break;
2929 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2931 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302932 // To Do - address probable memory leak with WEP encryption upon successful association
2933 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07002934 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302935 //Clear saved connection information in HDD
2936 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002937 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302938 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002939
2940 break;
2941 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002942 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002943 pRoamInfo, roamId, roamStatus, roamResult );
2944 break;
2945 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07002946 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
2947 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002948 break;
2949
2950 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2951 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002952 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002953
2954 case eCSR_ROAM_MIC_ERROR_IND:
2955 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2956 break;
2957
2958 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002959 {
2960 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2961
2962 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002963 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
2964 (TRUE == pHddCtx->hdd_wlan_suspended) &&
2965 (eCSR_ROAM_RESULT_NONE == roamResult))
2966 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002967 /* Send DTIM period to the FW; only if the wlan is already
2968 in suspend. This is the case with roaming (reassoc),
2969 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
2970 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
2971 before the ENTER_BMPS_REQ ensures Listen Interval is
2972 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002973 hdd_set_pwrparams(pHddCtx);
2974 pHddStaCtx->hdd_ReassocScenario = VOS_FALSE;
2975
2976 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002977 if due to unexpected scenario, if we are in BMPS,
2978 then trigger Exit and Enter BMPS to take DTIM period
2979 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002980 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
2981 {
2982 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
2983
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002984 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2985 iw_full_power_cbfn, pAdapter,
2986 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002987 }
2988 }
2989 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05302990 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002991 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002992 break;
2993#ifdef WLAN_FEATURE_VOWIFI_11R
2994 case eCSR_ROAM_FT_RESPONSE:
2995 hdd_SendFTEvent(pAdapter);
2996 break;
2997#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002998#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002999 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003000 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07003001 {
3002 /* Notify the supplicant of a new candidate */
3003 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
3004 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003005 break;
3006#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003007
Yue Maef608272013-04-08 23:09:17 -07003008#ifdef FEATURE_WLAN_LFR_METRICS
3009 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
3010 /* This event is to notify pre-auth initiation */
3011 if (VOS_STATUS_SUCCESS !=
3012 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
3013 {
3014 halStatus = eHAL_STATUS_FAILURE;
3015 }
3016 break;
3017 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
3018 /* This event will notify pre-auth completion in case of success */
3019 if (VOS_STATUS_SUCCESS !=
3020 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3021 pRoamInfo, 1))
3022 {
3023 halStatus = eHAL_STATUS_FAILURE;
3024 }
3025 break;
3026 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
3027 /* This event will notify pre-auth completion in case of failure. */
3028 if (VOS_STATUS_SUCCESS !=
3029 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3030 pRoamInfo, 0))
3031 {
3032 halStatus = eHAL_STATUS_FAILURE;
3033 }
3034 break;
3035 case eCSR_ROAM_HANDOVER_SUCCESS:
3036 /* This event is to notify handover success.
3037 It will be only invoked on success */
3038 if (VOS_STATUS_SUCCESS !=
3039 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
3040 {
3041 halStatus = eHAL_STATUS_FAILURE;
3042 }
3043 break;
3044#endif
3045
Jeff Johnson295189b2012-06-20 16:38:30 -07003046 case eCSR_ROAM_INDICATE_MGMT_FRAME:
3047 hdd_indicateMgmtFrame( pAdapter,
3048 pRoamInfo->nFrameLength,
3049 pRoamInfo->pbFrames,
3050 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05303051 pRoamInfo->rxChan,
3052 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07003053 break;
3054 case eCSR_ROAM_REMAIN_CHAN_READY:
3055 hdd_remainChanReadyHandler( pAdapter );
3056 break;
3057 case eCSR_ROAM_SEND_ACTION_CNF:
3058 hdd_sendActionCnf( pAdapter,
3059 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
3060 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003061#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08003062 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003063 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08003064 roamId, roamStatus, roamResult );
3065 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003066 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
3067 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
3068 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003069#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003070#ifdef WLAN_FEATURE_11W
3071 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
3072 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
3073 pRoamInfo->pbFrames,
3074 pRoamInfo->frameType);
3075 break;
3076#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003077#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003078 case eCSR_ROAM_TSM_IE_IND:
3079 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
3080 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
3081 break;
3082
3083 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
3084 {
3085 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
3086 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
3087 {
3088 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
3089 }
3090 break;
3091 }
3092
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003093 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003094 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003095 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003096 break;
3097 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003098
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003099 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003100 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003101 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003102 break;
3103 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003104#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05303105 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
3106 {
3107 pAdapter->maxRateFlags = roamResult;
3108 break;
3109 }
3110 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07003111 break;
3112 }
3113 return( halStatus );
3114}
Shailender Karmuchia734f332013-04-19 14:02:48 -07003115eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003116{
3117 eCsrAuthType auth_type;
3118 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003119 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 {
3121 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003122 } else
3123 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003124 {
3125 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003126 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003127#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003128 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 {
3130 // Check for 11r FT Authentication with PSK
3131 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003132 } else
3133 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 {
3135 // Check for 11R FT Authentication with 802.1X
3136 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003137 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003138#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003139#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003140 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003141 {
3142 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
3143 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003144#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07003145#ifdef WLAN_FEATURE_11W
3146 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
3147 {
3148 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3149 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303150 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
3151 {
3152 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3153 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003154#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003155 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3157 }
3158 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003159}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003160
Shailender Karmuchia734f332013-04-19 14:02:48 -07003161eCsrAuthType
3162hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003163{
3164 eCsrAuthType auth_type;
3165 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003166 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003167 {
3168 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003169 } else
3170 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003171 {
3172 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003173 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003174#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003175 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003176 {
3177 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003178 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003179#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003180 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003181 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3182 }
3183 hddLog(LOG1, FL("auth_type: %d"), auth_type);
3184 return auth_type;
3185}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003186
Shailender Karmuchia734f332013-04-19 14:02:48 -07003187eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003188hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003189{
3190 eCsrEncryptionType cipher_type;
3191 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003192 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 {
3194 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003195 }
3196 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003197 {
3198 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003199 }
3200 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 {
3202 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003203 }
3204 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 {
3206 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003207 }
3208 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
3209 {
3210 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3211 }
3212 else
3213 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003214 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3215 }
3216 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3217 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003218}
Jeff Johnson295189b2012-06-20 16:38:30 -07003219/* To find if the MAC address is NULL */
3220static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3221{
3222 int i;
3223 for (i = 0; i < length; i++)
3224 {
3225 if (0x00 != (macAddr[i]))
3226 {
3227 return FALSE;
3228 }
3229 }
3230 return TRUE;
3231} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003232
Shailender Karmuchia734f332013-04-19 14:02:48 -07003233eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003234hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003235{
3236 eCsrEncryptionType cipher_type;
3237 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003238 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003239 {
3240 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003241 } else
3242 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003243 {
3244 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003245 } else
3246 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003247 {
3248 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003249 } else
3250 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003251 {
3252 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003253 } else
3254 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003256 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3257 } else
3258 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3260 }
3261 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3262 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003263}
Jeff Johnson295189b2012-06-20 16:38:30 -07003264
Shailender Karmuchia734f332013-04-19 14:02:48 -07003265static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3266 struct ether_addr *pBssid,
3267 eCsrEncryptionType *pEncryptType,
3268 eCsrEncryptionType *mcEncryptType,
3269 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003270#ifdef WLAN_FEATURE_11W
3271 u_int8_t *pMfpRequired,
3272 u_int8_t *pMfpCapable,
3273#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003274 u_int16_t gen_ie_len,
3275 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003276{
3277 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003278 eHalStatus result;
3279 tDot11fIERSN dot11RSNIE;
3280 tDot11fIEWPA dot11WPAIE;
3281 tANI_U32 i;
3282 tANI_U8 *pRsnIe;
3283 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003285 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003286
3287 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3288 flag to 0 */
3289 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3290 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3291
3292 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003293 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
3294 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303295 {
3296 hddLog(LOGE, "%s: Invalid DOT11F IE Length passed :%d",
3297 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 return -EINVAL;
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303299 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003300 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003301 if ( gen_ie[0] == DOT11F_EID_RSN)
3302 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003303 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003304 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3306 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303307 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3308 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 return -EINVAL;
3310 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003311 // Skip past the EID byte and length byte
3312 pRsnIe = gen_ie + 2;
3313 RSNIeLen = gen_ie_len - 2;
3314 // Unpack the RSN IE
3315 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3316 pRsnIe,
3317 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003319 // Copy out the encryption and authentication types
3320 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003321 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003322 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003323 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003324 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003325 but probably I suspect we can do something different*/
3326 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003327 // Just translate the FIRST one
3328 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3329 //dot11RSNIE.pwise_cipher_suite_count
3330 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3331 //dot11RSNIE.gp_cipher_suite_count
3332 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003333#ifdef WLAN_FEATURE_11W
3334 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3335 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3336#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003338 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003339 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003340 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003341 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303342 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003343 break;
3344 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003345 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303347 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 break;
3349 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003350 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003351 // For right now, I assume setASSOCIATE() has passed in the bssid.
3352 vos_mem_copy(PMKIDCache[i].BSSID,
3353 pBssid, ETHER_ADDR_LEN);
3354 vos_mem_copy(PMKIDCache[i].PMKID,
3355 dot11RSNIE.pmkid[i],
3356 CSR_RSN_PMKID_SIZE);
3357 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003358
3359 if (updatePMKCache)
3360 {
3361 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003362 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003363 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003364 // Finally set the PMKSA ID Cache in CSR
3365 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3366 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05303367 dot11RSNIE.pmkid_count,
3368 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07003369 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003370 }
3371 else if (gen_ie[0] == DOT11F_EID_WPA)
3372 {
3373 // Validity checks
3374 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3375 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3376 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303377 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3378 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 return -EINVAL;
3380 }
3381 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003382 pRsnIe = gen_ie + 2 + 4;
3383 RSNIeLen = gen_ie_len - (2 + 4);
3384 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003385 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3386 pRsnIe,
3387 RSNIeLen,
3388 &dot11WPAIE);
3389 // Copy out the encryption and authentication types
3390 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003391 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003393 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 //dot11WPAIE.auth_suite_count
3395 // Just translate the FIRST one
3396 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3397 //dot11WPAIE.unicast_cipher_count
3398 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3399 //dot11WPAIE.unicast_cipher_count
3400 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3401 }
3402 else
3403 {
3404 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003405 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 }
3407 return 0;
3408}
3409int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3410{
3411 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3412 v_U32_t status = 0;
3413 eCsrEncryptionType RSNEncryptType;
3414 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003415#ifdef WLAN_FEATURE_11W
3416 u_int8_t RSNMfpRequired;
3417 u_int8_t RSNMfpCapable;
3418#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 struct ether_addr bSsid; // MAC address of assoc peer
3420 // MAC address of assoc peer
3421 // But, this routine is only called when we are NOT associated.
3422 vos_mem_copy(bSsid.ether_addr_octet,
3423 pWextState->roamProfile.BSSIDs.bssid,
3424 sizeof(bSsid.ether_addr_octet));
3425 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3426 {
3427 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003428 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003429 else
3430 {
3431 return 0;
3432 }
3433 // The actual processing may eventually be more extensive than this.
3434 // Right now, just consume any PMKIDs that are sent in by the app.
3435 status = hdd_ProcessGENIE(pAdapter,
3436 &bSsid, // MAC address of assoc peer
3437 &RSNEncryptType,
3438 &mcRSNEncryptType,
3439 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003440#ifdef WLAN_FEATURE_11W
3441 &RSNMfpRequired,
3442 &RSNMfpCapable,
3443#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 pWextState->WPARSNIE[1]+2,
3445 pWextState->WPARSNIE);
3446 if (status == 0)
3447 {
3448 // Now copy over all the security attributes you have parsed out
3449 pWextState->roamProfile.EncryptionType.numEntries = 1;
3450 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003451
Jeff Johnson295189b2012-06-20 16:38:30 -07003452 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3453 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003454
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003455 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3456 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3457 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3458 {
3459 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3460 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3461 either AES/TKIP based on group cipher configuration
3462 mentioned in the wpa_supplicant.conf.*/
3463
3464 /*Set the unicast cipher same as multicast cipher*/
3465 pWextState->roamProfile.EncryptionType.encryptionType[0]
3466 = mcRSNEncryptType;
3467 }
3468
Chet Lanctot186b5732013-03-18 10:26:30 -07003469#ifdef WLAN_FEATURE_11W
3470 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3471 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3472#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003473 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 }
3475 return 0;
3476}
3477int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3478{
3479 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3480 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3481 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3482 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003483
Jeff Johnson295189b2012-06-20 16:38:30 -07003484 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003485 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003486
Jeff Johnson295189b2012-06-20 16:38:30 -07003487 switch( pHddStaCtx->conn_info.authType)
3488 {
3489 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003490#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003491 case eCSR_AUTH_TYPE_CCKM_WPA:
3492 case eCSR_AUTH_TYPE_CCKM_RSN:
3493#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003494 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3495
Jeff Johnson295189b2012-06-20 16:38:30 -07003496 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003497 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003499
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003500#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003501 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3502 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3503 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003504 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003505 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3506 } else
3507 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003508 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003509 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003510 } else
3511#endif
3512 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3513 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003514 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3515 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003516 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3517 == IW_AUTH_KEY_MGMT_PSK) {
3518 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003519 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003520 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003521 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003522 }
3523 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003524#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003525 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3526 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3527 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003528 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003529 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003531 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003532 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003533 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003534 } else
3535#endif
3536
3537#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003538 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3539 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003540 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003541 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003542 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003543 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3545 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003546 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003547 } else
3548#endif
3549
Chet Lanctot186b5732013-03-18 10:26:30 -07003550#ifdef WLAN_FEATURE_11W
3551 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3552 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3553 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303554 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
3555 pRoamProfile->AuthType.authType[0] =
3556 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3557 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003558#endif
3559
Shailender Karmuchia734f332013-04-19 14:02:48 -07003560 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003561 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003562 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3563 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003564 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3565 == IW_AUTH_KEY_MGMT_PSK) {
3566 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003567 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003568 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003569 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003570 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003571 break;
3572
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003574
3575 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003576 break;
3577 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003578
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003579#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08003580 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003581#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003582 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3583 break;
3584 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003585
Jeff Johnson295189b2012-06-20 16:38:30 -07003586 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003587 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003588
Jeff Johnson295189b2012-06-20 16:38:30 -07003589 EXIT();
3590 return 0;
3591}
3592
3593/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003594
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303595 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07003597 to the CSR roam profile.
3598
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 \param - dev - Pointer to the net device.
3600 - info - Pointer to the iw_request_info.
3601 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003602 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003603 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003604
Jeff Johnson295189b2012-06-20 16:38:30 -07003605 --------------------------------------------------------------------------*/
3606
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303607int __iw_set_essid(struct net_device *dev,
3608 struct iw_request_info *info,
3609 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003610{
3611 v_U32_t status = 0;
3612 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303613 hdd_adapter_t *pAdapter;
3614 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003615 v_U32_t roamId;
3616 tCsrRoamProfile *pRoamProfile;
3617 eMib_dot11DesiredBssType connectedBssType;
3618 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303619 tHalHandle hHal;
3620 hdd_station_ctx_t *pHddStaCtx;
3621 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003622
Jeff Johnson295189b2012-06-20 16:38:30 -07003623 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303624 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3625 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07003626 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303627 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303628 "%s: Adapter is NULL",__func__);
3629 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003630 }
3631
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303632 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3633 ret = wlan_hdd_validate_context(pHddCtx);
3634 if (0 != ret)
3635 {
3636 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3637 "%s: HDD context is not valid",__func__);
3638 return ret;
3639 }
3640
3641 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3642 if (NULL == hHal)
3643 {
3644 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3645 "%s: Hal Context is NULL",__func__);
3646 return -EINVAL;
3647 }
3648 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3649 if (NULL == pHddStaCtx)
3650 {
3651 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3652 "%s: STA Context is NULL",__func__);
3653 return -EINVAL;
3654 }
3655 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3656 if (NULL == pWextState)
3657 {
3658 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3659 "%s: pWextState is NULL",__func__);
3660 return -EINVAL;
3661 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003662 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
3663 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
3664 return -EBUSY;
3665 }
3666 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
3667 return -EINVAL;
3668 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003669 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 {
3671 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
3672 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
3673 {
3674 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003675 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07003676 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3677 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
3678
3679 if(VOS_STATUS_SUCCESS == vosStatus)
3680 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3681 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3682 }
3683 }
3684 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003685 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 {
3687 return -EINVAL;
3688 }
3689 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003690 /** when cfg80211 defined, wpa_supplicant wext driver uses
3691 zero-length, null-string ssid for force disconnection.
3692 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07003693 driver MUST return success */
3694 if ( 0 == wrqu->essid.length ) {
3695 return 0;
3696 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003697
3698 status = hdd_wmm_get_uapsd_mask(pAdapter,
3699 &pWextState->roamProfile.uapsd_mask);
3700 if (VOS_STATUS_SUCCESS != status)
3701 {
3702 pWextState->roamProfile.uapsd_mask = 0;
3703 }
3704 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003705
Jeff Johnson295189b2012-06-20 16:38:30 -07003706 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003707
3708 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003709 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
3710 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
3711 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003712
Jeff Johnson295189b2012-06-20 16:38:30 -07003713 //set gen ie
3714 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
3715
3716 //set auth
3717 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
3718 }
3719#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003720 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003721 if (pAdapter->wapi_info.nWapiMode)
3722 {
3723 switch (pAdapter->wapi_info.wapiAuthMode)
3724 {
3725 case WAPI_AUTH_MODE_PSK:
3726 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003727 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003728 pRoamProfile->AuthType.numEntries = 1;
3729 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3730 break;
3731 }
3732 case WAPI_AUTH_MODE_CERT:
3733 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003734 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 pRoamProfile->AuthType.numEntries = 1;
3736 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3737 break;
3738 }
3739 } // End of switch
3740 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
3741 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
3742 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003743 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003744 pRoamProfile->EncryptionType.numEntries = 1;
3745 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3746 pRoamProfile->mcEncryptionType.numEntries = 1;
3747 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3748 }
3749 }
3750#endif /* FEATURE_WLAN_WAPI */
3751 /* if previous genIE is not NULL, update AssocIE */
3752 if (0 != pWextState->genIE.length)
3753 {
3754 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
3755 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
3756 pWextState->genIE.length);
3757 pWextState->assocAddIE.length = pWextState->genIE.length;
3758 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
3759 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
3760
3761 /* clear previous genIE after use it */
3762 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
3763 }
3764
3765 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
3766 pWextState->roamProfile.bWPSAssociation = FALSE;
3767
3768 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
3769 pWextState->roamProfile.nAddIEAssocLength))
3770 pWextState->roamProfile.bWPSAssociation = TRUE;
3771
3772
3773 // Disable auto BMPS entry by PMC until DHCP is done
3774 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
3775
Shailender Karmuchia734f332013-04-19 14:02:48 -07003776 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003777 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003778
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003779 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
3780 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003781 hdd_select_cbmode(pAdapter,
3782 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
3783 }
3784 status = sme_RoamConnect( hHal,pAdapter->sessionId,
3785 &(pWextState->roamProfile), &roamId);
3786 pRoamProfile->ChannelInfo.ChannelList = NULL;
3787 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003788
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003789 EXIT();
3790 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003791}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003792
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303793int iw_set_essid(struct net_device *dev,
3794 struct iw_request_info *info,
3795 union iwreq_data *wrqu, char *extra)
3796{
3797 int ret;
3798
3799 vos_ssr_protect(__func__);
3800 ret = __iw_set_essid(dev, info, wrqu, extra);
3801 vos_ssr_unprotect(__func__);
3802
3803 return ret;
3804}
3805
Jeff Johnson295189b2012-06-20 16:38:30 -07003806/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003807
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303808 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003809 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003810
Jeff Johnson295189b2012-06-20 16:38:30 -07003811 \param - dev - Pointer to the net device.
3812 - info - Pointer to the iw_request_info.
3813 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003814 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003815 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003816
Jeff Johnson295189b2012-06-20 16:38:30 -07003817 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303818int __iw_get_essid(struct net_device *dev,
3819 struct iw_request_info *info,
3820 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003821{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303822 hdd_adapter_t *pAdapter;
3823 hdd_context_t *pHddCtx;
3824 hdd_wext_state_t *wextBuf;
3825 hdd_station_ctx_t *pHddStaCtx;
3826 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 ENTER();
3828
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303829 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3830 if (NULL == pAdapter)
3831 {
3832 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3833 "%s: Adapter is NULL",__func__);
3834 return -EINVAL;
3835 }
3836
3837 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3838 ret = wlan_hdd_validate_context(pHddCtx);
3839 if (0 != ret)
3840 {
3841 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3842 "%s: HDD context is not valid",__func__);
3843 return ret;
3844 }
3845
3846 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3847 if (NULL == pHddStaCtx)
3848 {
3849 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3850 "%s: STA Context is NULL",__func__);
3851 return -EINVAL;
3852 }
3853
3854 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3855 if (NULL == wextBuf)
3856 {
3857 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3858 "%s: wextBuf is NULL",__func__);
3859 return -EINVAL;
3860 }
3861
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
3863 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
3864 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
3865 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
3866 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
3867 {
3868 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
3869 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
3870 dwrq->flags = 1;
3871 } else {
3872 memset(extra, 0, dwrq->length);
3873 dwrq->length = 0;
3874 dwrq->flags = 0;
3875 }
3876 EXIT();
3877 return 0;
3878}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303879
3880int iw_get_essid(struct net_device *dev,
3881 struct iw_request_info *info,
3882 struct iw_point *dwrq, char *extra)
3883{
3884 int ret;
3885
3886 vos_ssr_protect(__func__);
3887 ret = __iw_get_essid(dev, info, dwrq, extra);
3888 vos_ssr_unprotect(__func__);
3889
3890 return ret;
3891}
Jeff Johnson295189b2012-06-20 16:38:30 -07003892/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003893
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303894 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003895 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003896
Jeff Johnson295189b2012-06-20 16:38:30 -07003897 \param - dev - Pointer to the net device.
3898 - info - Pointer to the iw_request_info.
3899 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003900 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003902
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303904int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
3905 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003906{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303907 hdd_adapter_t *pAdapter;
3908 hdd_context_t *pHddCtx;
3909 hdd_wext_state_t *pWextState;
3910 hdd_station_ctx_t *pHddStaCtx;
3911 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003912 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303914 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003915
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003917
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303918 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3919 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003920 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303921 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3922 "%s: Adapter is NULL",__func__);
3923 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003924 }
3925
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303926 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3927 ret = wlan_hdd_validate_context(pHddCtx);
3928 if (0 != ret)
3929 {
3930 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3931 "%s: HDD context is not valid",__func__);
3932 return ret;
3933 }
3934
3935 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3936 if (NULL == pHddStaCtx)
3937 {
3938 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3939 "%s: STA Context is NULL",__func__);
3940 return -EINVAL;
3941 }
3942
3943 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3944 if (NULL == pWextState)
3945 {
3946 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3947 "%s: pWextState is NULL",__func__);
3948 return -EINVAL;
3949 }
3950
3951 pRoamProfile = &pWextState->roamProfile;
3952
Jeff Johnson295189b2012-06-20 16:38:30 -07003953 switch(wrqu->param.flags & IW_AUTH_INDEX)
3954 {
3955 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003956
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003958
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003960
Jeff Johnson295189b2012-06-20 16:38:30 -07003961 case IW_AUTH_CIPHER_PAIRWISE:
3962 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003963 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003964 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003966 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3967 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003968 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003969 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
3970 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003971 }
3972
Jeff Johnson295189b2012-06-20 16:38:30 -07003973 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003974
3975 if( (IW_AUTH_KEY_MGMT_802_1X
3976 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003977 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
3978 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003979 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07003980 else
3981 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003982 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3983 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003984 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003985
3986 if( ( IW_AUTH_KEY_MGMT_802_1X
3987 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3989 /*Dynamic WEP key*/
3990 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3991 else
3992 /*Static WEP key*/
3993 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003994
Jeff Johnson295189b2012-06-20 16:38:30 -07003995 }
3996 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003997
Jeff Johnson295189b2012-06-20 16:38:30 -07003998 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003999 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 return -EINVAL;
4001 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004002
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 pRoamProfile->EncryptionType.numEntries = 1;
4004 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004005 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004006 break;
4007 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004008 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004009 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
4010 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4011 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004012
Jeff Johnson295189b2012-06-20 16:38:30 -07004013 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4014 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
4015 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004016
4017 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004018 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
4019 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004020
Jeff Johnson295189b2012-06-20 16:38:30 -07004021 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004022
4023 if( ( IW_AUTH_KEY_MGMT_802_1X
4024 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
4025 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4026
Jeff Johnson295189b2012-06-20 16:38:30 -07004027 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004028
4029 else
4030 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004031 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004032
4033 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
4034 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004036 if( ( IW_AUTH_KEY_MGMT_802_1X
4037 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07004038 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4039 {
4040 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4041 }
4042 else
4043 {
4044 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4045 }
4046 }
4047 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004048
Jeff Johnson295189b2012-06-20 16:38:30 -07004049 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004050 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 return -EINVAL;
4052 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004053
Jeff Johnson295189b2012-06-20 16:38:30 -07004054 pRoamProfile->mcEncryptionType.numEntries = 1;
4055 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
4056 }
4057 break;
4058
4059 case IW_AUTH_80211_AUTH_ALG:
4060 {
4061 /*Save the auth algo here and set auth type to SME Roam profile
4062 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004063 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07004064 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004065
Jeff Johnson295189b2012-06-20 16:38:30 -07004066 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
4067 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
4068
4069 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
4070 /*Not supported*/
4071 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4072 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
4073 }
4074 break;
4075
4076 case IW_AUTH_KEY_MGMT:
4077 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004078#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004079#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
4080 /*Check for CCKM AKM type */
4081 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004082 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
4083 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004084 /* Set the CCKM bit in authKeyMgmt */
4085 /* Right now, this breaks all ref to authKeyMgmt because our
4086 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07004087 */
4088 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
4089 /*Set the key management to 802.1X*/
4090 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004091 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004092 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4093 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
4094 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
4095 /*Save the key management*/
4096 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
4097 //pWextState->authKeyMgmt = wrqu->param.value;
4098 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4099 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4100 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
4101 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
4102 /*Save the key management anyway*/
4103 pWextState->authKeyMgmt = wrqu->param.value;
4104 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
4105 /*Save the key management*/
4106 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
4107 //pWextState->authKeyMgmt = wrqu->param.value;
4108 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4109 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4110 }
4111#else
4112 /*Save the key management*/
4113 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004114#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 }
4116 break;
4117
4118 case IW_AUTH_TKIP_COUNTERMEASURES:
4119 {
4120 if(wrqu->param.value) {
4121 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4122 "Counter Measure started %d", wrqu->param.value);
4123 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
4124 }
4125 else {
4126 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4127 "Counter Measure stopped=%d", wrqu->param.value);
4128 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
4129 }
4130 }
4131 break;
4132 case IW_AUTH_DROP_UNENCRYPTED:
4133 case IW_AUTH_WPA_ENABLED:
4134 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
4135 case IW_AUTH_ROAMING_CONTROL:
4136 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004137
Jeff Johnson295189b2012-06-20 16:38:30 -07004138 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004139
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004140 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004141 wrqu->param.flags & IW_AUTH_INDEX);
4142 break;
4143 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004144
Jeff Johnson295189b2012-06-20 16:38:30 -07004145 EXIT();
4146 return 0;
4147}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304148
4149int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
4150 union iwreq_data *wrqu, char *extra)
4151{
4152 int ret;
4153
4154 vos_ssr_protect(__func__);
4155 ret = __iw_set_auth(dev, info, wrqu, extra);
4156 vos_ssr_unprotect(__func__);
4157
4158 return ret;
4159}
4160
Jeff Johnson295189b2012-06-20 16:38:30 -07004161/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004162
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304163 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004164 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004165
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 \param - dev - Pointer to the net device.
4167 - info - Pointer to the iw_request_info.
4168 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004169 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004170 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004171
Jeff Johnson295189b2012-06-20 16:38:30 -07004172 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304173int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4174 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004175{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304176 hdd_adapter_t* pAdapter;
4177 hdd_wext_state_t *pWextState;
4178 tCsrRoamProfile *pRoamProfile;
4179 hdd_context_t *pHddCtx;
4180 int ret = 0;
4181
Jeff Johnson295189b2012-06-20 16:38:30 -07004182 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004183
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304184 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4185 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004186 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304187 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4188 "%s: Adapter is NULL",__func__);
4189 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004190 }
4191
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304192 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4193 ret = wlan_hdd_validate_context(pHddCtx);
4194 if (0 != ret)
4195 {
4196 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4197 "%s: HDD context is not valid",__func__);
4198 return ret;
4199 }
4200
4201 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4202 if (NULL == pWextState)
4203 {
4204 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4205 "%s: pWextState is NULL",__func__);
4206 return -EINVAL;
4207 }
4208 pRoamProfile = &pWextState->roamProfile;
4209
Jeff Johnson295189b2012-06-20 16:38:30 -07004210 switch(pRoamProfile->negotiatedAuthType)
4211 {
4212 case eCSR_AUTH_TYPE_WPA_NONE:
4213 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4214 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
4215 break;
4216 case eCSR_AUTH_TYPE_WPA:
4217 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4218 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
4219 break;
4220#ifdef WLAN_FEATURE_VOWIFI_11R
4221 case eCSR_AUTH_TYPE_FT_RSN:
4222#endif
4223 case eCSR_AUTH_TYPE_RSN:
4224 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4225 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
4226 break;
4227 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4228 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4229 break;
4230 case eCSR_AUTH_TYPE_SHARED_KEY:
4231 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
4232 break;
4233 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004234 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004235 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4236 break;
4237 case eCSR_AUTH_TYPE_AUTOSWITCH:
4238 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4239 break;
4240 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304241 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004242 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4243 return -EIO;
4244#ifdef WLAN_FEATURE_VOWIFI_11R
4245 case eCSR_AUTH_TYPE_FT_RSN_PSK:
4246#endif
4247 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07004248#ifdef WLAN_FEATURE_11W
4249 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05304250 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07004251#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05304252 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004253 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4254 return -EIO;
4255 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304256 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004257 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4258 return -EIO;
4259 }
4260 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
4261 {
4262 switch(pRoamProfile->negotiatedUCEncryptionType)
4263 {
4264 case eCSR_ENCRYPT_TYPE_NONE:
4265 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4266 break;
4267 case eCSR_ENCRYPT_TYPE_WEP40:
4268 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4269 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4270 break;
4271 case eCSR_ENCRYPT_TYPE_TKIP:
4272 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4273 break;
4274 case eCSR_ENCRYPT_TYPE_WEP104:
4275 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4276 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4277 break;
4278 case eCSR_ENCRYPT_TYPE_AES:
4279 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4280 break;
4281 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304282 hddLog(LOG1, "%s called with unknown auth type %d ",
4283 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004284 return -EIO;
4285 }
4286 }
4287
Shailender Karmuchia734f332013-04-19 14:02:48 -07004288 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07004289 {
4290 switch(pRoamProfile->negotiatedMCEncryptionType)
4291 {
4292 case eCSR_ENCRYPT_TYPE_NONE:
4293 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4294 break;
4295 case eCSR_ENCRYPT_TYPE_WEP40:
4296 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4297 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4298 break;
4299 case eCSR_ENCRYPT_TYPE_TKIP:
4300 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4301 break;
4302 case eCSR_ENCRYPT_TYPE_WEP104:
4303 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4304 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4305 break;
4306 case eCSR_ENCRYPT_TYPE_AES:
4307 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4308 break;
4309 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304310 hddLog(LOG1, "%s called with unknown auth type %d ",
4311 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004312 return -EIO;
4313 }
4314 }
4315
4316 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004317 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004318 EXIT();
4319 return 0;
4320}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304321
4322int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4323 union iwreq_data *wrqu,char *extra)
4324{
4325 int ret;
4326
4327 vos_ssr_protect(__func__);
4328 ret = __iw_get_auth(dev, info, wrqu, extra);
4329 vos_ssr_unprotect(__func__);
4330
4331 return ret;
4332}
4333
Jeff Johnson295189b2012-06-20 16:38:30 -07004334/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004335
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304336 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07004337 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004339
Jeff Johnson295189b2012-06-20 16:38:30 -07004340 \param - dev - Pointer to the net device.
4341 - info - Pointer to the iw_request_info.
4342 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004343 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004344 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004345
Jeff Johnson295189b2012-06-20 16:38:30 -07004346 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304347int __iw_set_ap_address(struct net_device *dev,
4348 struct iw_request_info *info,
4349 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004350{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304351 hdd_station_ctx_t *pHddStaCtx;
4352 hdd_adapter_t *pAdapter;
4353 hdd_context_t *pHddCtx;
4354 v_U8_t *pMacAddress = NULL;
4355 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304357
4358 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4359 if (NULL == pAdapter)
4360 {
4361 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4362 "%s: Adapter is NULL", __func__);
4363 return -EINVAL;
4364 }
4365 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4366 ret = wlan_hdd_validate_context(pHddCtx);
4367 if (0 != ret)
4368 {
4369 hddLog(VOS_TRACE_LEVEL_ERROR,
4370 "%s: HDD context is not valid",__func__);
4371 return ret;
4372 }
4373 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4374 if (NULL == pHddStaCtx)
4375 {
4376 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4377 "%s: pHddStaCtx is NULL", __func__);
4378 return -EINVAL;
4379 }
4380
Jeff Johnson295189b2012-06-20 16:38:30 -07004381 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08004382 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
4383 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
4385 EXIT();
Shailender Karmuchia734f332013-04-19 14:02:48 -07004386
Jeff Johnson295189b2012-06-20 16:38:30 -07004387 return 0;
4388}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304389
4390int iw_set_ap_address(struct net_device *dev,
4391 struct iw_request_info *info,
4392 union iwreq_data *wrqu, char *extra)
4393{
4394 int ret;
4395
4396 vos_ssr_protect(__func__);
4397 ret = __iw_set_ap_address(dev, info, wrqu, extra);
4398 vos_ssr_unprotect(__func__);
4399
4400 return ret;
4401}
4402
Jeff Johnson295189b2012-06-20 16:38:30 -07004403/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004404
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304405 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004406 This function returns the BSSID to the wpa_supplicant
4407 \param - dev - Pointer to the net device.
4408 - info - Pointer to the iw_request_info.
4409 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004410 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004411 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004412
Jeff Johnson295189b2012-06-20 16:38:30 -07004413 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304414int __iw_get_ap_address(struct net_device *dev,
4415 struct iw_request_info *info,
4416 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004417{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304418 hdd_station_ctx_t *pHddStaCtx;
4419 hdd_adapter_t *pAdapter;
4420 hdd_context_t *pHddCtx;
4421 int ret = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 ENTER();
4423
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304424 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4425 if (NULL == pAdapter)
4426 {
4427 hddLog(VOS_TRACE_LEVEL_ERROR,
4428 "%s: Adapter is NULL", __func__);
4429 return -EINVAL;
4430 }
4431 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4432 ret = wlan_hdd_validate_context(pHddCtx);
4433 if (0 != ret)
4434 {
4435 hddLog(VOS_TRACE_LEVEL_ERROR,
4436 "%s: HDD context is not valid",__func__);
4437 return ret;
4438 }
4439 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4440 if (NULL == pHddStaCtx)
4441 {
4442 hddLog(VOS_TRACE_LEVEL_ERROR,
4443 "%s: pHddStaCtx is NULL", __func__);
4444 return -EINVAL;
4445 }
4446
Jeff Johnson295189b2012-06-20 16:38:30 -07004447 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
4448 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
4449 {
Jeff Johnson4416a782013-03-25 14:17:50 -07004450 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07004451 }
4452 else
4453 {
4454 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4455 }
4456 EXIT();
4457 return 0;
4458}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004459
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304460int iw_get_ap_address(struct net_device *dev,
4461 struct iw_request_info *info,
4462 union iwreq_data *wrqu, char *extra)
4463{
4464 int ret;
4465
4466 vos_ssr_protect(__func__);
4467 ret = __iw_get_ap_address(dev, info, wrqu, extra);
4468 vos_ssr_unprotect(__func__);
4469
4470 return ret;
4471}
4472
Chet Lanctot186b5732013-03-18 10:26:30 -07004473#ifdef WLAN_FEATURE_11W
4474/**---------------------------------------------------------------------------
4475
4476 \brief hdd_indicateUnprotMgmtFrame -
4477 This function forwards the unprotected management frame to the supplicant
4478 \param - pAdapter - Pointer to HDD adapter
4479 - nFrameLength - Length of the unprotected frame being passed
4480 - pbFrames - Pointer to the frame buffer
4481 - frameType - 802.11 frame type
4482 \return - nothing
4483
4484 --------------------------------------------------------------------------*/
4485void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
4486 tANI_U32 nFrameLength,
4487 tANI_U8* pbFrames,
4488 tANI_U8 frameType )
4489{
4490 tANI_U8 type = 0;
4491 tANI_U8 subType = 0;
4492
4493 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
4494 __func__, frameType, nFrameLength);
4495
4496 /* Sanity Checks */
4497 if (NULL == pAdapter)
4498 {
4499 hddLog( LOGE, FL("pAdapter is NULL"));
4500 return;
4501 }
4502
4503 if (NULL == pAdapter->dev)
4504 {
4505 hddLog( LOGE, FL("pAdapter->dev is NULL"));
4506 return;
4507 }
4508
4509 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
4510 {
4511 hddLog( LOGE, FL("pAdapter has invalid magic"));
4512 return;
4513 }
4514
4515 if( !nFrameLength )
4516 {
4517 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
4518 return;
4519 }
4520
4521 if (NULL == pbFrames) {
4522 hddLog( LOGE, FL("pbFrames is NULL"));
4523 return;
4524 }
4525
4526 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4527 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4528
4529 /* Get pAdapter from Destination mac address of the frame */
4530 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
4531 {
4532 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
4533 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4534 }
4535 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
4536 {
4537 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
4538 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4539 }
4540 else
4541 {
4542 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
4543 return;
4544 }
4545}
4546#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004547
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004548#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004549void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
4550 tANI_U8 state,
4551 tANI_U16 measInterval )
4552{
4553 union iwreq_data wrqu;
4554 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004555 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004556
4557 if (NULL == pAdapter)
4558 return;
4559
4560 // create the event
4561 memset(&wrqu, '\0', sizeof(wrqu));
4562 memset(buf, '\0', sizeof(buf));
4563
4564 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
4565 tid, state, measInterval);
4566
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004567 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004568
4569 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004570 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004571 // send the event
4572 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4573}
4574
4575void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4576{
4577 union iwreq_data wrqu;
4578 char buf[IW_CUSTOM_MAX + 1];
4579 char *pos = buf;
4580 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4581
4582 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4583 return;
4584
4585 // create the event
4586 memset(&wrqu, '\0', sizeof(wrqu));
4587 memset(buf, '\0', sizeof(buf));
4588
4589 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304590 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
4591 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
4592 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
4593 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004594
4595 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4596 pos += nBytes;
4597 freeBytes -= nBytes;
4598
4599 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
4600 pos += WNI_CFG_BSSID_LEN;
4601 freeBytes -= WNI_CFG_BSSID_LEN;
4602
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004603 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4604 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004605
4606 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004607 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004608
4609 // send the event
4610 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4611}
4612
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004613void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004614{
4615 union iwreq_data wrqu;
4616 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004617 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004618
4619 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4620 return;
4621
4622 // create the event
4623 memset(&wrqu, '\0', sizeof(wrqu));
4624 memset(buf, '\0', sizeof(buf));
4625
4626 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
4627
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004628 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004629
4630 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004631 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004632
4633 // send the event
4634 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4635}
4636
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004637void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
4638 const tANI_U16 measurementToken,
4639 const tANI_BOOLEAN flag,
4640 const tANI_U8 numBss)
4641{
4642 union iwreq_data wrqu;
4643 char buf[IW_CUSTOM_MAX];
4644 char *pos = buf;
4645 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4646
4647 memset(&wrqu, '\0', sizeof(wrqu));
4648 memset(buf, '\0', sizeof(buf));
4649
4650 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
4651 numBss);
4652
4653 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4654 flag, numBss);
4655
4656 wrqu.data.pointer = buf;
4657 wrqu.data.length = nBytes;
4658 // send the event
4659 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4660}
4661
4662
4663static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004664 const tCsrRoamInfo *pRoamInfo)
4665{
4666 union iwreq_data wrqu;
4667 char buf[IW_CUSTOM_MAX + 1];
4668 char *pos = buf;
4669 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4670 tANI_U8 i = 0, len = 0;
4671 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
4672 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004673 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
4674 tANI_U8 ieLenByte = 1;
4675 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
4676#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004677
4678 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4679 return;
4680
4681 /* Custom event can pass maximum of 256 bytes of data,
4682 based on the IE len we need to identify how many BSS info can
4683 be filled in to custom event data */
4684 /*
4685 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4686 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4687 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4688 */
4689
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004690 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004691 {
4692 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
4693 /* If the measurement is none and no scan results found,
4694 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004695 hdd_indicateEseBcnReportNoResults(pAdapter,
4696 pRoamInfo->pEseBcnReportRsp->measurementToken,
4697 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004698 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004699 }
4700 else
4701 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004702 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004703 {
4704 memset(&wrqu, '\0', sizeof(wrqu));
4705 memset(buf, '\0', sizeof(buf));
4706 tot_bcn_ieLen = 0;
4707 sendBss = 0;
4708 pos = buf;
4709 freeBytes = IW_CUSTOM_MAX;
4710
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004711 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004712 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004713 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
4714 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004715 {
4716 break;
4717 }
4718 tot_bcn_ieLen += len;
4719 sendBss++;
4720 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
4721 "IeLength(%d) Length of Ie(%d) totLen(%d)",
4722 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004723 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004724 tot_bcn_ieLen);
4725 }
4726
4727 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
4728 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004729 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4730 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004731
4732 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004733 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4734 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004735 pos += nBytes;
4736 freeBytes -= nBytes;
4737
4738 /* Copy total Beacon report data length */
4739 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
4740 pos += sizeof(tot_bcn_ieLen);
4741 freeBytes -= sizeof(tot_bcn_ieLen);
4742
4743 for (i = 0; i < sendBss; i++)
4744 {
4745 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304746 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4747 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004748 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004749 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
4750 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
4751 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
4752 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
4753 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
4754 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
4755 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
4756 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
4757 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
4758 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
4759 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
4760 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
4761 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
4762 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
4763 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
4764 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004765
4766 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004767 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
4768 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004769 pos += len;
4770 freeBytes -= len;
4771
4772 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004773 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004774 vos_mem_copy(pos, (char*)&len, sizeof(len));
4775 pos += sizeof(len);
4776 freeBytes -= sizeof(len);
4777
4778 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004779 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004780 pos += len;
4781 freeBytes -= len;
4782 }
4783
4784 wrqu.data.pointer = buf;
4785 wrqu.data.length = strlen(buf);
4786
4787 // send the event
4788 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4789 lastSent += sendBss;
4790 }
4791 }
4792}
4793
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004794#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004795