blob: d862b72cb024f677af85c8ee0d3820f44c144d8d [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"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080062#ifdef FEATURE_WLAN_TDLS
63#include "wlan_hdd_tdls.h"
64#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "sme_Api.h"
66
67v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
68
Shailender Karmuchia734f332013-04-19 14:02:48 -070069struct ether_addr
Jeff Johnson295189b2012-06-20 16:38:30 -070070{
71 u_char ether_addr_octet[6];
72};
73// These are needed to recognize WPA and RSN suite types
74#define HDD_WPA_OUI_SIZE 4
75v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
76v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
77v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
78v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
79v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
80v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080081#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070082v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080083#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070084#define HDD_RSN_OUI_SIZE 4
85v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
86v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
87v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
88v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
89v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
90v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080091#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070092v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080093#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -070094#ifdef WLAN_FEATURE_11W
95v_U8_t ccpRSNOui07[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x06 }; // RSN-PSK-SHA256
96#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070097
Shailender Karmuchia734f332013-04-19 14:02:48 -070098#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -070099// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700100#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
101#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700102#endif
103
104#define BEACON_FRAME_IES_OFFSET 12
105
Chet Lanctot186b5732013-03-18 10:26:30 -0700106#ifdef WLAN_FEATURE_11W
107void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
108 tANI_U32 nFrameLength,
109 tANI_U8* pbFrames,
110 tANI_U8 frameType );
111#endif
112
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800113#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700114static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
115 tANI_U8 state,
116 tANI_U16 measInterval );
117static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800118static void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
119static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700120
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800121#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700122
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530123static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
124 tCsrRoamInfo *pRoamInfo,
125 tANI_U32 roamId,
126 eRoamCmdStatus roamStatus,
127 eCsrRoamResult roamResult );
128
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530129v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
130 eConnectionState connState )
131{
132 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530133 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
134 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700135 pHddStaCtx->conn_info.connState = connState;
136}
137
138// returns FALSE if not connected.
139// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
140// returns the connection state. Can specify NULL if you dont' want to get the actual state.
141
Shailender Karmuchia734f332013-04-19 14:02:48 -0700142static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
143 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700144{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700145 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700146 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700147
Jeff Johnson295189b2012-06-20 16:38:30 -0700148 // get the connection state.
149 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700150 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700152 eConnectionState_IbssConnected == connState ||
153 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700154 {
155 fConnected = VOS_TRUE;
156 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700157 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700158 {
159 fConnected = VOS_FALSE;
160 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700161
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 if ( pConnState )
163 {
164 *pConnState = connState;
165 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700166
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 return( fConnected );
168}
169
170v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
171{
172 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700173}
Jeff Johnson295189b2012-06-20 16:38:30 -0700174
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530175eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx )
176{
177 v_U8_t staChannel = 0;
178
179 if ( eConnectionState_Associated == pHddStaCtx->conn_info.connState )
180 {
181 staChannel = pHddStaCtx->conn_info.operationChannel;
182 }
183
184 if ( staChannel > 0 && staChannel < 14 )
185 return eCSR_BAND_24;
186 else if (staChannel >= 36 && staChannel <= 165 )
187 return eCSR_BAND_5G;
188 else /* If station is not connected return as eCSR_BAND_ALL */
189 return eCSR_BAND_ALL;
190}
191
192
Jeff Johnson295189b2012-06-20 16:38:30 -0700193//TODO - Not used anyhwere. Can be removed.
194#if 0
195//
196v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
197{
198 v_BOOL_t fConnectedInfra = FALSE;
199 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700200
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700202 {
203 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700204 {
205 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700206 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700207 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700208
Jeff Johnson295189b2012-06-20 16:38:30 -0700209 return( fConnectedInfra );
210}
211#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700212
Jeff Johnson295189b2012-06-20 16:38:30 -0700213static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
214{
215 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700218
219 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700220 {
221 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
222 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700223
Jeff Johnson295189b2012-06-20 16:38:30 -0700224 return( fConnected );
225}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700226
Jeff Johnson295189b2012-06-20 16:38:30 -0700227inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
228{
229 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700230
Jeff Johnson295189b2012-06-20 16:38:30 -0700231 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700232
233 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700234 {
235 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
236 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700237
Jeff Johnson295189b2012-06-20 16:38:30 -0700238 return( fConnected );
239}
240
241static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
242{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700243 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700244 {
245 case eCSR_BSS_TYPE_INFRASTRUCTURE:
246 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
247 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700248
Jeff Johnson295189b2012-06-20 16:38:30 -0700249 case eCSR_BSS_TYPE_IBSS:
250 case eCSR_BSS_TYPE_START_IBSS:
251 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
252 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700253
254 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700256 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700257 default:
258 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700259 break;
260 }
261
Jeff Johnson295189b2012-06-20 16:38:30 -0700262}
263
264void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
265{
266 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
267 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700268
Jeff Johnson295189b2012-06-20 16:38:30 -0700269 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700270
271 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700272 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700273 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700274 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
275 {
276 VOS_ASSERT( pRoamInfo->pBssDesc );
277 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
278
279 // Save the Station ID for this station from the 'Roam Info'.
280 //For IBSS mode, staId is assigned in NEW_PEER_IND
281 //For reassoc, the staID doesn't change and it may be invalid in this structure
282 //so no change here.
283 if( !pRoamInfo->fReassocReq )
284 {
285 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
286 }
287 }
288 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700289 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700290 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700291 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700292 else
293 {
294 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
295 // or we can't function.
296 VOS_ASSERT( 0 );
297 }
298
299 // notify WMM
300 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
301
302 if( !pRoamInfo->u.pConnectedProfile )
303 {
304 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
305 }
306 else
307 {
308 // Get Multicast Encryption Type
309 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
310 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
311 // Get Unicast Encrytion Type
312 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
313 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
314
315 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
316
317 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
318
319 // Save the ssid for the connection
320 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530321
322 // Save dot11mode in which STA associated to AP
323 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700324 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700325 }
326
Jeff Johnson295189b2012-06-20 16:38:30 -0700327 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700328 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
329
Jeff Johnson295189b2012-06-20 16:38:30 -0700330}
331
332#if defined(WLAN_FEATURE_VOWIFI_11R)
333/*
334 * Send the 11R key information to the supplicant.
335 * Only then can the supplicant generate the PMK-R1.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800336 * (BTW, the ESE supplicant also needs the Assoc Resp IEs
Jeff Johnson295189b2012-06-20 16:38:30 -0700337 * for the same purpose.)
338 *
339 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
340 * this contains the R1KHID, R0KHID and the MDID.
341 * For FT, this consists of the Reassoc Rsp FTIEs.
342 * This is the Assoc Response.
343 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700344static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700345 tCsrRoamInfo *pCsrRoamInfo)
346{
347 union iwreq_data wrqu;
348 char *buff;
349 unsigned int len = 0;
350 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700351
352 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700353 {
354 hddLog(LOGE,
355 "%s: pCsrRoamInfo->nAssocRspLength=%d",
356 __func__, (int)pCsrRoamInfo->nAssocRspLength);
357 return;
358 }
359
Shailender Karmuchia734f332013-04-19 14:02:48 -0700360 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700361 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700362 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700363 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700364 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 return;
366 }
367
368 // pFTAssocRsp needs to point to the IEs
369 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
370 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
371 (unsigned int)pFTAssocRsp[0],
372 (unsigned int)pFTAssocRsp[1]);
373
374 // We need to send the IEs to the supplicant.
375 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700376 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700377 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700378 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700379 return;
380 }
381
382 // Send the Assoc Resp, the supplicant needs this for initial Auth.
383 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700384 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700385 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700386 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700387 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
388
389 kfree(buff);
390}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700391#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700392
393#ifdef WLAN_FEATURE_VOWIFI_11R
394
395/*---------------------------------------------------
396 *
397 * Send the FTIEs, RIC IEs during FT. This is eventually
398 * used to send the FT events to the supplicant
399 *
400 * At the reception of Auth2 we send the RIC followed
401 * by the auth response IEs to the supplicant.
402 * Once both are received in the supplicant, an FT
403 * event is generated to the supplicant.
404 *
405 *---------------------------------------------------
406 */
407void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
408{
Jeff Johnson295189b2012-06-20 16:38:30 -0700409 tANI_U16 auth_resp_len = 0;
410 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700411 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
412
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530413#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700414 struct cfg80211_ft_event_params ftEvent;
415 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
416 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
417 struct net_device *dev = pAdapter->dev;
418#else
419 char *buff;
420 union iwreq_data wrqu;
421 tANI_U16 str_len;
422#endif
423
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530424#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530425 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
426 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700427
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530428 sme_GetRICIEs( pHddCtx->hHal, (u8 *)ricIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800429 DOT11F_IE_FTINFO_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530430 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700431 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530432 hddLog(LOGW,
433 "%s: RIC IEs is of length 0 not sending RIC Information for now",
434 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700435 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700436
437 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530438 ftEvent.ric_ies_len = ric_ies_length;
439 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700440
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530441 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800442 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700443
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530444 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700445 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530446 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700447 return;
448 }
449
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530450 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530451
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530452 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700453
454 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
455 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
456
Jeff Johnson59a121e2013-11-30 09:46:08 -0800457 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
458 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
459 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530460 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800461 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
462 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
463 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700464
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530465 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700466
467#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530468 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -0700469 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530470 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700471 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530472 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700473 return;
474 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530475 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700476
Shailender Karmuchia734f332013-04-19 14:02:48 -0700477 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -0700478 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530479 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800480 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530481 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700482 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530483 hddLog(LOGW,
484 "%s: RIC IEs is of length 0 not sending RIC Information for now",
485 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700486 }
487 else
488 {
489 wrqu.data.length = str_len + ric_ies_length;
490 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
491 }
492
493 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530494 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700495 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530496 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
497 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700498
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530499 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700500 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530501 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700502 return;
503 }
504
505 wrqu.data.length = str_len + auth_resp_len;
506 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
507
508 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700509#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700510}
511
512#endif /* WLAN_FEATURE_VOWIFI_11R */
513
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800514#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700515
516/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800517 * Send the ESE required "new AP Channel info" to the supplicant.
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 * (This keeps the supplicant "up to date" on the current channel.)
519 *
520 * The current (new AP) channel information is passed in.
521 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700522static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700523 tCsrRoamInfo *pCsrRoamInfo)
524{
525 union iwreq_data wrqu;
526 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700527
Shailender Karmuchia734f332013-04-19 14:02:48 -0700528
529 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700530 {
531 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800532 "%s: pCsrRoamInfo->pBssDesc=%p",
Jeff Johnson295189b2012-06-20 16:38:30 -0700533 __func__, descriptor);
534 return;
535 }
536
537 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -0800538 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700539 memset(&wrqu, '\0', sizeof(wrqu));
540 wrqu.freq.m = descriptor->channelId;
541 wrqu.freq.e = 0;
542 wrqu.freq.i = 0;
543 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
544}
545
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800546#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700547
548void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
549{
550 union iwreq_data wrqu;
551 u8 *pBeaconIes;
552 u8 currentLen = 0;
553 char *buff;
554 int totalIeLen = 0, currentOffset = 0, strLen;
555
556 memset(&wrqu, '\0', sizeof(wrqu));
557
558 if (0 == pCsrRoamInfo->nBeaconLength)
559 {
560 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
561 return;
562 }
563 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700564 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700565 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700566 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700567 return;
568 }
569
570 // pBeaconIes needs to point to the IEs
571 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
572 (unsigned int)pBeaconIes[0],
573 (unsigned int)pBeaconIes[1]);
574 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700575
Jeff Johnson295189b2012-06-20 16:38:30 -0700576 // We need to send the IEs to the supplicant.
577 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700578 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700579 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700580 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700581 return;
582 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700583 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700584
585 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
586 currentLen = strLen + 1;
587
588 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
589 do
590 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700591 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -0700592 * max size and send it to supplicant. Changes are done in supplicant to handle this */
593 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
594 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
595 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
596 currentOffset += currentLen;
597 totalIeLen -= currentLen;
598 wrqu.data.length = strLen + 1 + currentLen;
599 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700600 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -0700601 else
602 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
603
604 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
605 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
606 } while (totalIeLen > 0);
607
608 kfree(buff);
609}
610
611static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
612{
613 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
614 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
615 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
616 union iwreq_data wrqu;
617 int we_event;
618 char *msg;
619 int type = -1;
620
Shailender Karmuchia734f332013-04-19 14:02:48 -0700621#if defined (WLAN_FEATURE_VOWIFI_11R)
622 // Added to find the auth type on the fly at run time
623 // rather than with cfg to see if FT is enabled
624 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
626#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700627
Jeff Johnson295189b2012-06-20 16:38:30 -0700628 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -0700629 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700630 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700631
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
633 {
634 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
635 type = WLAN_STA_ASSOC_DONE_IND;
636
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700637#ifdef WLAN_FEATURE_P2P_DEBUG
638 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
639 {
640 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
641 {
642 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
643 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
644 "Connecting state to Connected State for 8-way "
645 "Handshake");
646 }
647 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
648 {
649 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
650 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
651 "Connecting state to P2P Client Connection Completed");
652 }
653 }
654#endif
Arif Hussain77d044f2014-01-03 19:56:04 -0800655 pr_info("wlan: " MAC_ADDRESS_STR " connected to " MAC_ADDRESS_STR "\n",
656 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
Kiet Lam34947452014-01-21 23:23:40 -0800657 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700658 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
659
660 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
661 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
662 * and fFTEnable is TRUE */
663#ifdef WLAN_FEATURE_VOWIFI_11R
664 // Send FT Keys to the supplicant when FT is enabled
665 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700666 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800667#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
669 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
670#endif
671 )
672 {
673 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
674 }
675#endif
676 }
677 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
678 {
Jeff Johnson4416a782013-03-25 14:17:50 -0700679 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700680 type = WLAN_STA_ASSOC_DONE_IND;
Arif Hussain24bafea2013-11-15 15:10:03 -0800681 pr_info("wlan: new IBSS connection to " MAC_ADDRESS_STR"\n",
682 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 }
684 else /* Not Associated */
685 {
686 pr_info("wlan: disconnected\n");
687 type = WLAN_STA_DISASSOC_DONE_IND;
688 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
689 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700690 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700691
692 msg = NULL;
693 /*During the WLAN uninitialization,supplicant is stopped before the
694 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530695 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 {
697 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800698#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700700 {
701 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
702 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700703 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
704 }
705#endif
706 }
707 send_btc_nlink_msg(type, 0);
708}
709
710void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
711{
712 // Remove staId, bssId and peerMacAddress
713 pHddStaCtx->conn_info.staId [ 0 ] = 0;
714 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
715 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
716
717 // Clear all security settings
718 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
719 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
720 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
721
722 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700723 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700724
725 // Set not-connected state
726 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700727 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Jeff Johnson295189b2012-06-20 16:38:30 -0700728
729 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
730}
731/* TODO Revist this function. and data path */
732static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
733{
734 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700735 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
736
737 if (WLAN_HDD_IBSS != pAdapter->device_mode)
738 {
739 hdd_disconnect_tx_rx(pAdapter);
740 }
741 else
742 {
743 // Need to cleanup all queues only if the last peer leaves
744 if (eConnectionState_IbssDisconnected == pHddStaCtx->conn_info.connState)
745 {
746 netif_tx_disable(pAdapter->dev);
747 netif_carrier_off(pAdapter->dev);
748 hdd_disconnect_tx_rx(pAdapter);
749 }
750 else
751 {
752 // There is atleast one more peer, do not cleanup all queues
753 hdd_flush_ibss_tx_queues(pAdapter, staId);
754 }
755 }
756
Jeff Johnson295189b2012-06-20 16:38:30 -0700757 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
758 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
759 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530760 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700761 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700762 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700763 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700764 }
765 return( vosStatus );
766}
767
768
769static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
770 tANI_U32 roamId, eRoamCmdStatus roamStatus,
771 eCsrRoamResult roamResult )
772{
773 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700774 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700775 struct net_device *dev = pAdapter->dev;
776 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
777 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700778 v_U8_t sta_id;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700779
780 // Sanity check
781 if(dev == NULL)
782 {
Agarwal Ashish971c2882013-10-30 20:11:12 +0530783 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700784 "%s: net_dev is released return", __func__);
785 return eHAL_STATUS_FAILURE;
786 }
787
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 // notify apps that we can't pass traffic anymore
789 netif_tx_disable(dev);
790 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700791
Jeff Johnsone7245742012-09-05 17:12:55 -0700792 INIT_COMPLETION(pAdapter->disconnect_comp_var);
793 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
Jeff Johnson295189b2012-06-20 16:38:30 -0700794 /* If only STA mode is on */
795 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
796 {
797 pHddCtx->isAmpAllowed = VOS_TRUE;
798 }
799 hdd_clearRoamProfileIe( pAdapter );
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -0700800 if(pAdapter->device_mode == WLAN_HDD_INFRA_STATION)
801 {
802 hdd_wmm_init( pHddCtx, hddWmmDscpToUpMapInfra );
803 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700804
805 // indicate 'disconnect' status to wpa_supplicant...
806 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700807 /* indicate disconnected event to nl80211 */
808 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
809 {
810 /*During the WLAN uninitialization,supplicant is stopped before the
811 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530812 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700813 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700814 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
815 "%s: sent disconnected event to nl80211",
Jeff Johnson295189b2012-06-20 16:38:30 -0700816 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700817#ifdef WLAN_FEATURE_P2P_DEBUG
818 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
819 {
820 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
821 {
822 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
823 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
824 "and moved to disconnected state");
825 }
826 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
827 {
828 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
829 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
830 "and moved to inactive state");
831 }
832 }
833#endif
834
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
836 if( eCSR_ROAM_LOSTLINK == roamStatus )
837 {
Mohit Khanna99d5fd02012-09-11 14:51:20 -0700838 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 }
840 else
841 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700842 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700843 }
844
845 //If the Device Mode is Station
846 // and the P2P Client is Connected
847 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -0700848
849 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -0700850 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -0700851 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -0700852 {
853 //Enable BMPS only of other Session is P2P Client
854 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700855 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -0700856
857 if (NULL != pVosContext)
858 {
859 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
860
861 if(NULL != pHddCtx)
862 {
863 //Only P2P Client is there Enable Bmps back
864 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
Jeff Johnsone7245742012-09-05 17:12:55 -0700865 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700866 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530867 if (pHddCtx->hdd_wlan_suspended)
868 {
869 hdd_set_pwrparams(pHddCtx);
870 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530872 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700873 }
874 }
875 }
876 }
877 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700878
krunal soni3fc26642013-10-08 22:41:42 -0700879 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
880 {
881 sta_id = IBSS_BROADCAST_STAID;
882 }
883 else
884 {
885 sta_id = pHddStaCtx->conn_info.staId[0];
886 }
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +0530887 hdd_wmm_adapter_clear(pAdapter);
Mukul Sharmac159c432014-01-15 15:42:46 +0530888#if defined(WLAN_FEATURE_VOWIFI_11R)
889 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
890#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700891 //We should clear all sta register with TL, for now, only one.
krunal soni3fc26642013-10-08 22:41:42 -0700892 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
Jeff Johnson43971f52012-07-17 12:26:56 -0700893 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700894 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530895 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700896 "hdd_roamDeregisterSTA() failed to for staID %d. "
897 "Status= %d [0x%x]",
krunal soni3fc26642013-10-08 22:41:42 -0700898 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700899
900 status = eHAL_STATUS_FAILURE;
901 }
902
krunal soni3fc26642013-10-08 22:41:42 -0700903 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700904 // Clear saved connection information in HDD
905 hdd_connRemoveConnectInfo( pHddStaCtx );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530906#ifdef WLAN_FEATURE_GTK_OFFLOAD
907 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
908 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
909 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +0530910 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
911 sizeof (tSirGtkOffloadParams));
912 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530913 }
914#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700915
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800916#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -0700917 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
918 {
919 wlan_hdd_tdls_disconnection_callback(pAdapter);
920 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800921#endif
922
Jeff Johnson295189b2012-06-20 16:38:30 -0700923 //Unblock anyone waiting for disconnect to complete
924 complete(&pAdapter->disconnect_comp_var);
925 return( status );
926}
927static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
928 tCsrRoamInfo *pRoamInfo,
929 v_U8_t staId,
930 v_MACADDR_t *pPeerMacAddress,
931 tSirBssDescription *pBssDesc )
932{
933 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
934 WLAN_STADescType staDesc = {0};
935 eCsrEncryptionType connectedCipherAlgo;
936 v_BOOL_t fConnected;
937 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
938 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -0700939 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700940
941 if ( NULL == pBssDesc)
942 {
943 return VOS_STATUS_E_FAILURE;
944 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 // Get the Station ID from the one saved during the assocation.
946 staDesc.ucSTAId = staId;
947
948 if ( pHddStaCtx->conn_info.connDot11DesiredBssType == eMib_dot11DesiredBssType_infrastructure)
Jeff Johnson295189b2012-06-20 16:38:30 -0700949 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700950 staDesc.wSTAType = WLAN_STA_INFRA;
951
952 // grab the bssid from the connection info in the adapter structure and hand that
953 // over to TL when registering.
954 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) );
955 }
956 else
957 {
958 // for an IBSS 'connect', setup the Station Descriptor for TL.
Jeff Johnson295189b2012-06-20 16:38:30 -0700959 staDesc.wSTAType = WLAN_STA_IBSS;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700960
Jeff Johnson295189b2012-06-20 16:38:30 -0700961 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
962 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
963 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
964 // pass when making an Infrastructure connection.
965 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) );
966 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
967 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700968
Jeff Johnson295189b2012-06-20 16:38:30 -0700969 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
970
971 // set the QoS field appropriately
972 if (hdd_wmm_is_active(pAdapter))
973 {
974 staDesc.ucQosEnabled = 1;
975 }
976 else
977 {
978 staDesc.ucQosEnabled = 0;
979 }
980
981 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
982 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
983 {
984 staDesc.ucProtectedFrame = 1;
985 }
986 else
987 {
988 staDesc.ucProtectedFrame = 0;
989
990 }
991
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800992#ifdef FEATURE_WLAN_ESE
993 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
994#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700995
996#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
997 /* check whether replay check is valid for the station or not */
998 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
999 {
1000 /* Encryption mode is either TKIP or AES
1001 and replay check is valid for only these
1002 two encryption modes */
1003 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1004 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1005 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1006 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001007
Jeff Johnson295189b2012-06-20 16:38:30 -07001008 else
1009 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001010 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001012 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001013 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1014 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1015 }
1016#endif
1017
1018#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001019 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001020 if (pAdapter->wapi_info.fIsWapiSta)
1021 {
1022 staDesc.ucIsWapiSta = 1;
1023 }
1024 else
1025 {
1026 staDesc.ucIsWapiSta = 0;
1027 }
1028#endif /* FEATURE_WLAN_WAPI */
1029
1030 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1031 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1032
Jeff Johnson295189b2012-06-20 16:38:30 -07001033 // UMA is Not ready yet, Xlation will be done by TL
1034 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001035 staDesc.ucSwFrameRXXlation = 1;
1036 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001037 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001038 staDesc.ucQosEnabled );
1039 // Initialize signatures and state
1040 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1041 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1042 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1043 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001044 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001045 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 -07001046 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1047 hdd_rx_packet_cbk,
1048 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001049 hdd_tx_fetch_packet_cbk, &staDesc,
1050 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001051
Jeff Johnson295189b2012-06-20 16:38:30 -07001052 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1053 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001054 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001055 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001057 return vosStatus;
1058 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001059
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001060 if ( cfg_param->dynSplitscan &&
1061 ( VOS_TIMER_STATE_RUNNING !=
1062 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1063 {
1064 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1065 cfg_param->trafficMntrTmrForSplitScan);
1066 }
1067
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301068 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1069 // then go to 'authenticated'. For all other authentication types
1070 // (those that donot require upper layer authentication) we can put
1071 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001072 if (staDesc.wSTAType != WLAN_STA_IBSS)
1073 VOS_ASSERT( fConnected );
1074
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301075 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001076 {
1077 // Connections that do not need Upper layer auth, transition TL directly
1078 // to 'Authenticated' state.
1079 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1080 WLANTL_STA_AUTHENTICATED );
1081
1082 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1083 }
1084 else
1085 {
1086 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301087 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1088 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001089 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301090 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001091 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1092 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001093 return( vosStatus );
1094}
1095
Jeff Johnson295189b2012-06-20 16:38:30 -07001096static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1097 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1098{
1099 unsigned int len = 0;
1100 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001101 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001102 tANI_U32 rspRsnLength = 0;
1103 struct ieee80211_channel *chan;
1104
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001105 if (!rspRsnIe)
1106 {
1107 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001108 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001109 }
1110
Jeff Johnson295189b2012-06-20 16:38:30 -07001111 if (pCsrRoamInfo == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001112 {
1113 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1114 goto done;
1115 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001116
1117 if (pCsrRoamInfo->nAssocRspLength == 0)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001118 {
1119 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1120 goto done;
1121 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001122
1123 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1124 pCsrRoamInfo->nAssocReqLength);
1125 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001126 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001127
1128 //pFTAssocRsp needs to point to the IEs
1129 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001130 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001131 (unsigned int)pFTAssocRsp[0],
1132 (unsigned int)pFTAssocRsp[1]);
1133
1134 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001135 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001136 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001137 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001138 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001139
1140 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1141 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1142 reqRsnIe, reqRsnLength,
1143 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001144
1145done:
1146 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001147}
Jeff Johnson295189b2012-06-20 16:38:30 -07001148
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301149void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1150{
1151 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1152 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1153 tCsrRoamInfo roamInfo;
1154 roamInfo.fAuthRequired = FALSE;
1155 vos_mem_copy(roamInfo.bssid,
1156 pHddStaCtx->roam_info.bssid,
1157 WNI_CFG_BSSID_LEN);
1158 vos_mem_copy(roamInfo.peerMac,
1159 pHddStaCtx->roam_info.peerMac,
1160 WNI_CFG_BSSID_LEN);
1161
1162 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1163 &roamInfo,
1164 pHddStaCtx->roam_info.roamId,
1165 pHddStaCtx->roam_info.roamStatus,
1166 eCSR_ROAM_RESULT_AUTHENTICATED);
1167 if (halStatus != eHAL_STATUS_SUCCESS)
1168 {
1169 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1170 }
1171 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1172}
1173
Shailender Karmuchia734f332013-04-19 14:02:48 -07001174static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1175 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001176 eCsrRoamResult roamResult )
1177{
1178 struct net_device *dev = pAdapter->dev;
1179 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1180 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1181 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001182 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1183 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001184#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001185 int ft_carrier_on = FALSE;
1186#endif
1187 int status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001188
Jeff Johnson295189b2012-06-20 16:38:30 -07001189 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1190 {
1191 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1192
c_hpothu44ff4e02014-05-08 00:13:57 +05301193 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001194 // Save the connection info from CSR...
1195 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1196#ifdef FEATURE_WLAN_WAPI
1197 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1198 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1199 {
1200 pAdapter->wapi_info.fIsWapiSta = 1;
1201 }
1202 else
1203 {
1204 pAdapter->wapi_info.fIsWapiSta = 0;
1205 }
1206#endif /* FEATURE_WLAN_WAPI */
1207
1208 // indicate 'connect' status to userspace
1209 hdd_SendAssociationEvent(dev,pRoamInfo);
1210
1211
Shailender Karmuchia734f332013-04-19 14:02:48 -07001212 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001213 INIT_COMPLETION(pAdapter->linkup_event_var);
1214
1215 /*
1216 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1217 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 -07001218 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001219 know that the device is getting activated properly.
1220 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001221#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001222 if (pHddStaCtx->ft_carrier_on == FALSE)
1223 {
1224#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001225 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001226 pAdapter->isLinkUpSvcNeeded = TRUE;
1227
Shailender Karmuchia734f332013-04-19 14:02:48 -07001228 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 pAdapter->isLinkUpSvcNeeded = TRUE;
1230
1231 // Switch on the Carrier to activate the device
1232 netif_carrier_on(dev);
1233
1234 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1235 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1236 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001237 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001238 {
1239 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1240 }
1241
1242 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1243 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001244#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001245 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001246 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001247 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001248 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001249 }
1250#endif
1251 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1252
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001253#ifdef FEATURE_WLAN_TDLS
1254 wlan_hdd_tdls_connection_callback(pAdapter);
1255#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 //For reassoc, the station is already registered, all we need is to change the state
1257 //of the STA in TL.
1258 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
1259 if( !pRoamInfo->fReassocReq )
1260 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001261 struct cfg80211_bss *bss;
1262#ifdef WLAN_FEATURE_VOWIFI_11R
1263 u8 *pFTAssocRsp = NULL;
1264 unsigned int assocRsplen = 0;
1265 u8 *pFTAssocReq = NULL;
1266 unsigned int assocReqlen = 0;
1267 struct ieee80211_channel *chan;
1268#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001269 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001270 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001271
1272 /* add bss_id to cfg80211 data base */
1273 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1274 if (NULL == bss)
1275 {
1276 pr_err("wlan: Not able to create BSS entry\n");
1277 return eHAL_STATUS_FAILURE;
1278 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001279#ifdef WLAN_FEATURE_VOWIFI_11R
1280 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001281 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001282 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001283
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001284 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001285 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001286 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001287 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001288 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001289 // pFTAssocRsp needs to point to the IEs
1290 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1291 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1292 (unsigned int)pFTAssocRsp[0],
1293 (unsigned int)pFTAssocRsp[1]);
1294 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001295 }
1296 else
1297 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001298 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1299 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001300 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001301
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001302 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001303 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001304 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001305 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001306 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001307 if(!ft_carrier_on)
1308 {
1309 // pFTAssocReq needs to point to the IEs
1310 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1311 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1312 (unsigned int)pFTAssocReq[0],
1313 (unsigned int)pFTAssocReq[1]);
1314 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1315 }
1316 else
1317 {
1318 /* This should contain only the FTIEs */
1319 assocReqlen = pRoamInfo->nAssocReqLength;
1320 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001321 }
1322 else
1323 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001324 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1325 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001326 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001327
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001328 if(ft_carrier_on)
1329 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001330 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001331 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001332 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1333 (int)pRoamInfo->pBssDesc->channelId);
Arif Hussain6d2a3322013-11-17 19:50:10 -08001334 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001335 assocRsplen);
1336 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
1337 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1338 GFP_KERNEL);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301339 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1340 {
1341 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1342 pRoamInfo->fAuthRequired = FALSE;
1343
1344 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1345 pRoamInfo->bssid,
1346 HDD_MAC_ADDR_LEN);
1347 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1348 pRoamInfo->peerMac,
1349 HDD_MAC_ADDR_LEN);
1350 pHddStaCtx->roam_info.roamId = roamId;
1351 pHddStaCtx->roam_info.roamStatus = roamStatus;
1352 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1353 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001354 }
1355 else
1356 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001357 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001358 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001359 cfg80211_connect_result(dev, pRoamInfo->bssid,
1360 pFTAssocReq, assocReqlen,
1361 pFTAssocRsp, assocRsplen,
1362 WLAN_STATUS_SUCCESS,
1363 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001364 }
1365 }
1366 else
1367#endif
1368 {
1369 /* wpa supplicant expecting WPA/RSN IE in connect result */
1370 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1371 pAdapter->sessionId,
1372 &reqRsnLength,
1373 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001374
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001375 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1376 pAdapter->sessionId,
1377 &rspRsnLength,
1378 rspRsnIe);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001379#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001380 if(ft_carrier_on)
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001381 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001382 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001383#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001384
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001385 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301386 hddLog(VOS_TRACE_LEVEL_INFO,
1387 "%s: sending connect indication to nl80211:"
1388 " for bssid " MAC_ADDRESS_STR
1389 " reason:%d and Status:%d\n",
1390 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1391 roamResult, roamStatus);
1392
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001393 /* inform connect result to nl80211 */
1394 cfg80211_connect_result(dev, pRoamInfo->bssid,
1395 reqRsnIe, reqRsnLength,
1396 rspRsnIe, rspRsnLength,
1397 WLAN_STATUS_SUCCESS,
1398 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001399 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 }
Yue Maf49ba872013-08-19 12:04:25 -07001401 cfg80211_put_bss(
1402#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1403 pHddCtx->wiphy,
1404#endif
1405 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001406 // Register the Station with TL after associated...
1407 vosStatus = hdd_roamRegisterSTA( pAdapter,
1408 pRoamInfo,
1409 pHddStaCtx->conn_info.staId[ 0 ],
1410 NULL,
1411 pRoamInfo->pBssDesc );
1412 }
1413 else
1414 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001415 /* wpa supplicant expecting WPA/RSN IE in connect result */
1416 /* in case of reassociation also need to indicate it to supplicant */
1417 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1418 pAdapter->sessionId,
1419 &reqRsnLength,
1420 reqRsnIe);
1421
1422 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001423 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301424 if( pRoamInfo->fAuthRequired )
1425 {
1426 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1427 pHddStaCtx->conn_info.staId[ 0 ],
1428 WLANTL_STA_CONNECTED );
1429 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1430 }
1431 else
1432 {
1433 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1434 "%s: staId: %d Changing TL state to AUTHENTICATED",
1435 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1436 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1437 pHddStaCtx->conn_info.staId[ 0 ],
1438 WLANTL_STA_AUTHENTICATED );
1439 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1440 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001441 }
1442
1443 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1444 {
1445 // perform any WMM-related association processing
1446 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1447 }
1448 else
1449 {
1450 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001451 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001452 vosStatus, vosStatus );
1453 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001454#ifdef WLAN_FEATURE_11W
1455 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1456 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1457#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001458 // Start the Queue
1459 netif_tx_wake_all_queues(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001460 }
1461 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001462 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001463 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1464
1465 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001466 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001467 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1468 " reason:%d and Status:%d\n",
1469 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1470 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001471 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001472 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1473 " reason:%d and Status:%d\n",
1474 MAC_ADDR_ARRAY(pWextState->req_bssId),
1475 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001476
1477 /*Handle all failure conditions*/
1478 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
Rashmi Ramanna45350fc2014-02-24 18:58:29 +05301479
Jeff Johnson295189b2012-06-20 16:38:30 -07001480 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
1481 {
1482 pHddCtx->isAmpAllowed = VOS_TRUE;
1483 }
1484
1485 //If the Device Mode is Station
1486 // and the P2P Client is Connected
1487 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001488
1489 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001490 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001491 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1492 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 (vos_concurrent_sessions_running()))
1494 {
1495 //Enable BMPS only of other Session is P2P Client
1496 hdd_context_t *pHddCtx = NULL;
1497 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1498
1499 if (NULL != pVosContext)
1500 {
1501 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1502
1503 if(NULL != pHddCtx)
1504 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301505 //Only P2P Client is there Enable Bmps back
1506 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
1507 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
1508 {
1509 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001510 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301511 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001512 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301513 hdd_enable_bmps_imps(pHddCtx);
1514 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001515 }
1516 }
1517 }
1518
James Zmudafbf5ffc2013-03-25 12:45:35 -07001519 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001520 * completed operation - with a ASSOCIATION_FAILURE status.*/
1521 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus )
Jeff Johnsone7245742012-09-05 17:12:55 -07001522 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301523 if (pRoamInfo)
1524 hddLog(VOS_TRACE_LEVEL_ERROR,
1525 "%s: send connect failure to nl80211:"
1526 " for bssid " MAC_ADDRESS_STR
1527 " reason:%d and Status:%d\n" ,
1528 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1529 roamResult, roamStatus);
1530 else
1531 hddLog(VOS_TRACE_LEVEL_ERROR,
1532 "%s: connect failed:"
1533 " for bssid " MAC_ADDRESS_STR
1534 " reason:%d and Status:%d\n" ,
1535 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
1536 roamResult, roamStatus);
1537
James Zmudafbf5ffc2013-03-25 12:45:35 -07001538 /* inform association failure event to nl80211 */
1539 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1540 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001541 if (pRoamInfo)
1542 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1543 NULL, 0, NULL, 0,
1544 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1545 GFP_KERNEL );
1546 else
1547 cfg80211_connect_result ( dev, pWextState->req_bssId,
1548 NULL, 0, NULL, 0,
1549 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1550 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001551 }
1552 else
1553 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001554 if (pRoamInfo)
1555 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1556 NULL, 0, NULL, 0,
1557 WLAN_STATUS_UNSPECIFIED_FAILURE,
1558 GFP_KERNEL );
1559 else
1560 cfg80211_connect_result ( dev, pWextState->req_bssId,
1561 NULL, 0, NULL, 0,
1562 WLAN_STATUS_UNSPECIFIED_FAILURE,
1563 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001564 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001565 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001566
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001567 /*Clear the roam profile*/
1568 hdd_clearRoamProfileIe( pAdapter );
Leela Venkata Kiran Kumar Reddy Chirala8e69fbc2013-10-30 18:51:13 -07001569 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode)
1570 {
1571 hdd_wmm_init( pHddCtx, hddWmmDscpToUpMapInfra );
1572 }
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001573
c_hpothu24f40982014-04-18 18:00:36 +05301574 if (pRoamInfo)
1575 {
1576 WLANTL_AssocFailed(pRoamInfo->staId);
1577 }
Mihir Sheteb7337272014-04-11 15:53:08 +05301578
Jeff Johnson295189b2012-06-20 16:38:30 -07001579 netif_tx_disable(dev);
1580 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001581
Jeff Johnson295189b2012-06-20 16:38:30 -07001582 }
1583
1584 return eHAL_STATUS_SUCCESS;
1585}
1586
1587/**============================================================================
1588 *
Jeff Johnson81c17882013-05-03 09:53:35 -07001589 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07001590 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07001591
Jeff Johnson295189b2012-06-20 16:38:30 -07001592 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07001593static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
1594 tCsrRoamInfo *pRoamInfo,
1595 tANI_U32 roamId,
1596 eRoamCmdStatus roamStatus,
1597 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07001598{
Jeff Johnson81c17882013-05-03 09:53:35 -07001599 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
1600 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
1601
Jeff Johnson295189b2012-06-20 16:38:30 -07001602 switch( roamResult )
1603 {
1604 // both IBSS Started and IBSS Join should come in here.
1605 case eCSR_ROAM_RESULT_IBSS_STARTED:
1606 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001607 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07001608 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001609 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1610 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001611
Jeff Johnson81c17882013-05-03 09:53:35 -07001612 if (NULL == pRoamInfo)
1613 {
1614 VOS_ASSERT(0);
1615 return;
1616 }
1617
1618 /* When IBSS Started comes from CSR, we need to move
1619 * connection state to IBSS Disconnected (meaning no peers
1620 * are in the IBSS).
1621 */
1622 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
1623 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05301624 /*notify wmm */
1625 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001626 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1627 hdd_roamRegisterSTA (pAdapter, pRoamInfo,
1628 IBSS_BROADCAST_STAID,
1629 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001630
Jeff Johnson81c17882013-05-03 09:53:35 -07001631 if (pRoamInfo->pBssDesc)
1632 {
1633 struct cfg80211_bss *bss;
1634
1635 /* we created the IBSS, notify supplicant */
1636 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
1637 MAC_ADDRESS_STR,
1638 __func__, pAdapter->dev->name,
1639 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
1640
1641 /* we must first give cfg80211 the BSS information */
1642 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1643 if (NULL == bss)
1644 {
1645 hddLog(VOS_TRACE_LEVEL_ERROR,
1646 "%s: %s: unable to create IBSS entry",
1647 __func__, pAdapter->dev->name);
1648 return;
1649 }
1650
1651 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07001652 cfg80211_put_bss(
1653#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1654 pHddCtx->wiphy,
1655#endif
1656 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07001657 }
1658
Jeff Johnson295189b2012-06-20 16:38:30 -07001659 break;
1660 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001661
Jeff Johnson295189b2012-06-20 16:38:30 -07001662 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
1663 {
Jeff Johnson81c17882013-05-03 09:53:35 -07001664 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
1665 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 break;
1667 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001668
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07001670 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
1671 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001672 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001673 }
1674
Jeff Johnson81c17882013-05-03 09:53:35 -07001675 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001676}
1677
1678/**============================================================================
1679 *
1680 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
1681 This information is passed to iwconfig later. The peer that joined
1682 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001683 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001684 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001685
Jeff Johnson295189b2012-06-20 16:38:30 -07001686 ===========================================================================*/
1687static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
1688{
1689 int fSuccess = FALSE;
1690 int idx = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001691
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1693 {
1694 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
1695 {
1696 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001697
Jeff Johnson295189b2012-06-20 16:38:30 -07001698 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001699
Jeff Johnson295189b2012-06-20 16:38:30 -07001700 fSuccess = TRUE;
1701 break;
1702 }
1703 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001704
1705 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07001706}
1707/**============================================================================
1708 *
1709 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001710 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001711 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001712
Jeff Johnson295189b2012-06-20 16:38:30 -07001713 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07001714static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07001715{
1716 int fSuccess = FALSE;
1717 int idx = 0;
1718 v_U8_t valid_idx = 0;
1719 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07001720 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001721 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001722
Jeff Johnson295189b2012-06-20 16:38:30 -07001723 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1724 {
1725 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
1726 {
1727 pHddStaCtx->conn_info.staId[ idx ] = 0;
1728
1729 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
1730
1731 fSuccess = TRUE;
Ravi Joshi8a934352013-09-25 16:46:58 -07001732
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 // Note the deleted Index, if its 0 we need special handling
1734 del_idx = idx;
Ravi Joshi8a934352013-09-25 16:46:58 -07001735
1736 empty_slots++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 }
1738 else
1739 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001740 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001741 {
1742 valid_idx = idx;
1743 }
Ravi Joshi8a934352013-09-25 16:46:58 -07001744 else
1745 {
1746 // Found an empty slot
1747 empty_slots++;
1748 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001749 }
1750 }
1751
Ravi Joshi8a934352013-09-25 16:46:58 -07001752 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
1753 {
1754 // Last peer departed, set the IBSS state appropriately
1755 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001756 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07001757 "Last IBSS Peer Departed!!!" );
1758 }
1759
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 // Find next active staId, to have a valid sta trigger for TL.
1761 if (fSuccess == TRUE)
1762 {
1763 if (del_idx == 0)
1764 {
1765 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
1766 {
1767 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
1768 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
1769 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
1770
1771 pHddStaCtx->conn_info.staId[valid_idx] = 0;
1772 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
1773 }
1774 }
1775 }
1776 return( fSuccess );
1777}
1778
1779/**============================================================================
1780 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001781 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07001782 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001783
Jeff Johnson295189b2012-06-20 16:38:30 -07001784 ===========================================================================*/
1785static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
1786{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001787 struct cfg80211_bss *bss;
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "IBSS Connect Indication from SME!!!" );
1789 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
1790 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
1791
1792 // Save the connection info from CSR...
1793 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
1794
1795 // Send the bssid address to the wext.
1796 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001797 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001798 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1799 if (NULL == bss)
1800 {
1801 hddLog(VOS_TRACE_LEVEL_ERROR,
1802 "%s: %s: unable to create IBSS entry",
1803 __func__, pAdapter->dev->name);
1804 return eHAL_STATUS_FAILURE;
1805 }
Yue Maf49ba872013-08-19 12:04:25 -07001806 cfg80211_put_bss(
1807#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1808 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
1809#endif
1810 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001811
1812 return( eHAL_STATUS_SUCCESS );
1813}
1814/**============================================================================
1815 *
Mukul Sharmad2589a52014-04-23 21:06:25 +05301816 @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
1817 suspend related data which was cleared during roaming in FWR.
1818
1819 ===========================================================================*/
1820static void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
1821{
1822 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
1823 hdd_adapter_t *pAdapter;
1824 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
1825 ENTER();
1826
1827 spin_lock(&pHddCtx->filter_lock);
1828 if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
1829 {
1830 pHddCtx->sus_res_mcastbcast_filter =
1831 pHddCtx->configuredMcastBcastFilter;
1832 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
1833 hddLog(VOS_TRACE_LEVEL_INFO, FL("offload: callback to associated"));
1834 hddLog(VOS_TRACE_LEVEL_INFO,
1835 FL("saving configuredMcastBcastFilter = %d"),
1836 pHddCtx->configuredMcastBcastFilter);
1837 hddLog(VOS_TRACE_LEVEL_INFO,
1838 FL("offload: calling hdd_conf_mcastbcast_filter"));
1839 }
1840 spin_unlock(&pHddCtx->filter_lock);
1841
1842 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
1843 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
1844 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
1845
1846 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
1847 //No need to configure GTK Offload from here because it might possible
1848 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
1849 //be handled as part of cfg80211_set_rekey_data processing.
1850 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
1851 {
1852 pAdapter = pAdapterNode->pAdapter;
1853 if( pAdapter &&
1854 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1855 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
1856 {
1857 if (pHddCtx->cfg_ini->fhostArpOffload)
1858 {
1859 //Configure ARPOFFLOAD
1860 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
1861 if (!VOS_IS_STATUS_SUCCESS(vstatus))
1862 {
1863 hddLog(VOS_TRACE_LEVEL_ERROR,
1864 FL("Failed to disable ARPOffload Feature %d"), vstatus);
1865 }
1866 }
1867#ifdef WLAN_NS_OFFLOAD
1868 //Configure NSOFFLOAD
1869 if (pHddCtx->cfg_ini->fhostNSOffload)
1870 {
1871 hdd_conf_ns_offload(pAdapter, TRUE);
1872 }
1873#endif
1874 }
1875 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
1876 pAdapterNode = pNext;
1877 }
1878 EXIT();
1879}
1880
1881/**============================================================================
1882 *
Jeff Johnson295189b2012-06-20 16:38:30 -07001883 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001884
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001886static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1887 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001888 eCsrRoamResult roamResult )
1889{
1890 eCsrEncryptionType connectedCipherAlgo;
1891 v_BOOL_t fConnected = FALSE;
1892 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1893 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1894 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1895 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07001896
1897 if (NULL == pRoamInfo)
1898 {
1899 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
1900 return eHAL_STATUS_FAILURE;
1901 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001902 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001903 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07001904 // not require upper layer authentication) we can put TL directly into 'authenticated'
1905 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001906 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1907 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
1908 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001909
Jeff Johnson295189b2012-06-20 16:38:30 -07001910 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1911 if( fConnected )
1912 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001913 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
1914 {
1915 v_U8_t staId;
1916
1917 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
1918
1919 if ( 0 == memcmp( pRoamInfo->peerMac,
1920 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
1921 {
1922 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1923 IBSS_BROADCAST_STAID);
1924 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1925 }
1926 else
1927 {
1928 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
1929 (v_MACADDR_t*)pRoamInfo->peerMac,
1930 &staId);
1931 if ( VOS_STATUS_SUCCESS == vosStatus )
1932 {
1933 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1934 "WLAN TL STA Ptk Installed for STAID=%d", staId);
1935 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1936 staId);
1937 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1938 }
1939 }
1940 }
1941 else
1942 {
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301943 // TODO: Considering getting a state machine in HDD later.
1944 // This routine is invoked twice. 1)set PTK 2)set GTK.
1945 // The folloing if statement will be TRUE when setting GTK.
1946 // At this time we don't handle the state in detail.
1947 // Related CR: 174048 - TL not in authenticated state
1948 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
1949 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
1950 {
1951 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
1952 "for StaId= %d. Changing TL state to AUTHENTICATED",
1953 pHddStaCtx->conn_info.staId[ 0 ] );
1954
1955 // Connections that do not need Upper layer authentication,
1956 // transition TL to 'Authenticated' state after the keys are set.
1957 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1958 pHddStaCtx->conn_info.staId[ 0 ],
1959 WLANTL_STA_AUTHENTICATED );
1960
1961 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Mukul Sharmad2589a52014-04-23 21:06:25 +05301962 //Need to call offload because when roaming happen at that time fwr
1963 //clean offload info as part of the DelBss
1964 // No need to configure offload if host was not suspended
1965 spin_lock(&pHddCtx->filter_lock);
1966 if(pHddCtx->hdd_wlan_suspended)
1967 {
1968 spin_unlock(&pHddCtx->filter_lock);
1969 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
1970 }
1971 else
1972 {
1973 spin_unlock(&pHddCtx->filter_lock);
1974 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301975 }
1976 else
1977 {
1978 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1979 pHddStaCtx->conn_info.staId[ 0 ]);
1980 }
1981
1982 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001983 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001984 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301985 else
1986 {
1987 // possible disassoc after issuing set key and waiting set key complete
1988 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1989 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001990
Jeff Johnson295189b2012-06-20 16:38:30 -07001991 EXIT();
1992 return( eHAL_STATUS_SUCCESS );
1993}
1994/**============================================================================
1995 *
1996 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
1997 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001998static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07001999 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002000{
Jeff Johnson295189b2012-06-20 16:38:30 -07002001 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2002
2003 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2004 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2005 {
2006 struct iw_michaelmicfailure msg;
2007 union iwreq_data wreq;
2008 memset(&msg, '\0', sizeof(msg));
2009 msg.src_addr.sa_family = ARPHRD_ETHER;
2010 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002011 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2012 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002013
Jeff Johnson295189b2012-06-20 16:38:30 -07002014 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2015 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002016 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002017 msg.flags = IW_MICFAILURE_PAIRWISE;
2018 memset(&wreq, 0, sizeof(wreq));
2019 wreq.data.length = sizeof(msg);
2020 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002022 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002023 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2024 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2025 NL80211_KEYTYPE_GROUP :
2026 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002027 pRoamInfo->u.pMICFailureInfo->keyId,
2028 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002029 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002030
Jeff Johnson295189b2012-06-20 16:38:30 -07002031 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002032
Jeff Johnson295189b2012-06-20 16:38:30 -07002033 return( eHAL_STATUS_SUCCESS );
2034}
2035
2036/**============================================================================
2037 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002038 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002039 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002040
Jeff Johnson295189b2012-06-20 16:38:30 -07002041 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002042static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2043 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002044 eCsrRoamResult roamResult )
2045{
2046 VOS_STATUS vosStatus;
2047
2048 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2049 switch( roamResult )
2050 {
2051 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2052 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002053 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002054 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002055
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002056 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002057 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2058 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2059 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002060 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002061
Jeff Johnson295189b2012-06-20 16:38:30 -07002062 if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
2063 {
2064 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2065 "New IBSS peer but we already have the max we can handle. Can't register this one" );
2066 break;
2067 }
2068
2069 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2070
Shailender Karmuchia734f332013-04-19 14:02:48 -07002071 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2072 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2073 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2074
2075 // Register the Station with TL for the new peer.
Jeff Johnson295189b2012-06-20 16:38:30 -07002076 vosStatus = hdd_roamRegisterSTA( pAdapter,
2077 pRoamInfo,
2078 pRoamInfo->staId,
2079 (v_MACADDR_t *)pRoamInfo->peerMac,
2080 pRoamInfo->pBssDesc );
2081 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2082 {
2083 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002084 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002085 vosStatus, vosStatus );
2086 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002087 pHddStaCtx->ibss_sta_generation++;
2088 memset(&staInfo, 0, sizeof(staInfo));
2089 staInfo.filled = 0;
2090 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2091
2092 cfg80211_new_sta(pAdapter->dev,
2093 (const u8 *)pRoamInfo->peerMac,
2094 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002095
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002096 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2097 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2098 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2099 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2100 {
2101 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2102 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2103 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2104
2105 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002106 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002107 pHddStaCtx->ibss_enc_key.encType);
2108
2109 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2110 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2111
2112 if ( VOS_STATUS_SUCCESS != vosStatus )
2113 {
2114 hddLog(VOS_TRACE_LEVEL_ERROR,
2115 "%s: sme_RoamSetKey failed, returned %d",
2116 __func__, vosStatus);
2117 return VOS_STATUS_E_FAILURE;
2118 }
2119 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002120 netif_carrier_on(pAdapter->dev);
2121 netif_tx_start_all_queues(pAdapter->dev);
2122 break;
2123 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002124
Jeff Johnson295189b2012-06-20 16:38:30 -07002125 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2126 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002127
Jeff Johnson295189b2012-06-20 16:38:30 -07002128 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002129
Jeff Johnson295189b2012-06-20 16:38:30 -07002130 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002131 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002132 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2133 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002134 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002135
Ravi Joshicc57ed42013-10-12 16:31:25 -07002136 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002137 {
2138 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2139 "IBSS peer departed by cannot find peer in our registration table with TL" );
2140 }
2141
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002142 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002143 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2144 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2145 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2146 pRoamInfo->staId );
2147
Jeff Johnson295189b2012-06-20 16:38:30 -07002148 hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
2149
2150 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002151 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002152
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002153 cfg80211_del_sta(pAdapter->dev,
2154 (const u8 *)&pRoamInfo->peerMac,
2155 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002156 break;
2157 }
2158 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2159 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002160 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2161 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002162 // Stop only when we are inactive
2163 netif_tx_disable(pAdapter->dev);
2164 netif_carrier_off(pAdapter->dev);
2165 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002166
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 // Send the bssid address to the wext.
2168 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2169 // clean up data path
2170 hdd_disconnect_tx_rx(pAdapter);
2171 break;
2172 }
2173 default:
2174 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002175
Jeff Johnson295189b2012-06-20 16:38:30 -07002176 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002177
Jeff Johnson295189b2012-06-20 16:38:30 -07002178 return( eHAL_STATUS_SUCCESS );
2179}
2180
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002181#ifdef FEATURE_WLAN_TDLS
2182/**============================================================================
2183 *
2184 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2185 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2186 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002187
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002188 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002189VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
2190 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002191{
2192 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002193 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002194 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2195 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002196 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2197 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002198 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2199 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002200
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002201 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2202 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002203 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002204 "%s not connected. ignored", __func__);
2205 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002206 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002207
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002208 /*
2209 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2210 * be peer MAC, here we are wokrking on direct Link
2211 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002212 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002213
2214 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002215
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002216 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002217 sizeof(tSirMacAddr) );
2218
2219 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2220 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2221
2222 /* set the QoS field appropriately ..*/
2223 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2224 : (staDesc.ucQosEnabled = 0) ;
2225
2226 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002227 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002228
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002229 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002230
2231 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002232 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002233
Shailender Karmuchia734f332013-04-19 14:02:48 -07002234 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002235 * UMA is ready we inform TL to do frame translation.
2236 */
2237 staDesc.ucSwFrameTXXlation = 1;
2238 staDesc.ucSwFrameRXXlation = 1;
2239 staDesc.ucAddRmvLLC = 1;
2240
2241 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002242 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002243
2244 /* tdls Direct Link do not need bcastSig */
2245 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002246
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002247#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2248 if(staDesc.ucProtectedFrame)
2249 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2250 else
2251 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2252#endif
2253
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302254 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002255
Shailender Karmuchia734f332013-04-19 14:02:48 -07002256 /* Register the Station with TL... */
2257 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2258 hdd_rx_packet_cbk,
2259 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002260 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002261
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002262 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2263 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002264 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002265 "%s: WLANTL_RegisterSTAClient() failed to register. "
2266 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002267 return vosStatus;
2268 }
2269
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002270 if ( cfg_param->dynSplitscan &&
2271 ( VOS_TIMER_STATE_RUNNING !=
2272 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2273 {
2274 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2275 cfg_param->trafficMntrTmrForSplitScan);
2276 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002277 return( vosStatus );
2278}
2279
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002280static VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
2281{
2282 VOS_STATUS vosStatus;
2283 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2284 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2285 {
2286 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2287 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002288 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002289 __func__, staId, vosStatus, vosStatus );
2290 }
2291 return( vosStatus );
2292}
2293
2294
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002295/*
2296 * HDD interface between SME and TL to ensure TDLS client registration with
2297 * TL in case of new TDLS client is added and deregistration at the time
2298 * TDLS client is deleted.
2299 */
2300
Shailender Karmuchia734f332013-04-19 14:02:48 -07002301eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2302 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002303 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002304 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002305 eCsrRoamResult roamResult)
2306{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002307 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002308 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002309 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002310
2311#ifdef WLAN_FEATURE_TDLS_DEBUG
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302312 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002313 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2314 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2315 "ADD_TDLS_PEER" :
2316 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2317 "DEL_TDLS_PEER" :
2318 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2319 "DEL_TDLS_PEER_IND" :
2320 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2321 "DEL_ALL_TDLS_PEER_IND" :
2322 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2323 "UPDATE_TDLS_PEER" :
2324 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2325 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2326 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002327#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002328 switch( roamResult )
2329 {
2330 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2331 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002332 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2333 {
2334 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002335 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002336 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002337 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002338 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002339
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002340 /* check if there is available index for this new TDLS STA */
2341 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2342 {
2343 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2344 {
2345 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2346 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2347
2348 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002349 ("TDLS: STA IDX at %d is %d "
2350 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002351 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002352 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002353
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002354 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002355 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2356 status = eHAL_STATUS_SUCCESS ;
2357 break ;
2358 }
2359 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002360 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002361 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002362 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002363 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2364 "wlan_hdd_tdls_set_sta_id() failed");
2365 return VOS_FALSE;
2366 }
2367
2368 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302369 /* store the ucast signature , if required for further reference. */
2370
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002371 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302372 /* start TDLS client registration with TL */
2373 status = hdd_roamRegisterTDLSSTA( pAdapter,
2374 pRoamInfo->peerMac,
2375 pRoamInfo->staId,
2376 pRoamInfo->ucastSig);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002377 }
2378 else
2379 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002380 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002382 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002383 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002384 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002385 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002386 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002387 break ;
2388 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002389 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
2390 {
2391 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2392 {
2393 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2394 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
2395 }
2396 /* store the ucast signature which will be used later when
2397 * registering to TL
2398 */
2399 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
2400 complete(&pAdapter->tdls_add_station_comp);
2401 break;
2402 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302403 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
2404 {
2405 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2406 {
2407 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2408 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
2409 }
2410 complete(&pAdapter->tdls_link_establish_req_comp);
2411 break;
2412 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002413 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002414 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002415 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002416 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002417 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002418 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2419 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002420 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002421 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002422 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2423
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302424 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002425 if (NULL != curr_peer && TDLS_IS_CONNECTED(curr_peer))
2426 {
2427 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2428 wlan_hdd_tdls_decrement_peer_count(pAdapter);
2429 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002430 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002431
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002432 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2433 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
2434 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002435 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002436 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002437 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002438 break ;
2439 }
2440 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002441 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002442 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002443 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002444 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
2445 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002446 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002447 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2448 "%s: Sending teardown to supplicant with reason code %u",
2449 __func__, pRoamInfo->reasonCode);
2450
2451#ifdef CONFIG_TDLS_IMPLICIT
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302452 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002453 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002454#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002455 status = eHAL_STATUS_SUCCESS ;
2456 break ;
2457 }
2458 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
2459 {
2460 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002461 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002462 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002463 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2464 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002465 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002466 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002467 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002468 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002469 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002470 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
2471 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
2472 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002473
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002474 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002475 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002476 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2477 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002478
2479 status = eHAL_STATUS_SUCCESS ;
2480 }
2481 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05302482 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002483 break ;
2484 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002485 default:
2486 {
2487 break ;
2488 }
2489 }
2490
2491 return status ;
2492}
2493#endif
2494
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002495static void iw_full_power_cbfn (void *pContext, eHalStatus status)
2496{
2497 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
2498 hdd_context_t *pHddCtx = NULL;
2499 int ret;
2500
2501 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
2502 {
2503 hddLog(VOS_TRACE_LEVEL_ERROR,
2504 "%s: Bad param, pAdapter [%p]",
2505 __func__, pAdapter);
2506 return;
2507 }
2508
2509 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2510 ret = wlan_hdd_validate_context(pHddCtx);
2511 if (0 != ret)
2512 {
2513 hddLog(VOS_TRACE_LEVEL_ERROR,
2514 "%s: HDD context is not valid (%d)", __func__, ret);
2515 return;
2516 }
2517
2518 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2519 {
2520 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
2521 }
2522}
2523
Shailender Karmuchia734f332013-04-19 14:02:48 -07002524eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002525 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
2526{
2527 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2528 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302529 hdd_wext_state_t *pWextState = NULL;
2530 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002531 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07002532 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002533
2534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002535 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002536 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002537
2538 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302539 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002540 {
2541 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302542 "invalid adapter or adapter has invalid magic");
2543 return eHAL_STATUS_FAILURE;
2544 }
2545
2546 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2547 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2548
2549 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2550 {
2551 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2552 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002553 return eHAL_STATUS_FAILURE;
2554 }
2555
Jeff Johnson295189b2012-06-20 16:38:30 -07002556 switch( roamStatus )
2557 {
2558 case eCSR_ROAM_SESSION_OPENED:
2559 if(pAdapter != NULL)
2560 {
2561 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2562 complete(&pAdapter->session_open_comp_var);
2563 }
2564 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002565
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002566#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
2567 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002568 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07002569 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 * interface down */
2571 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05302572 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
2573 roamStatus, roamResult, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2575 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2576 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002577 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2578 }
2579 pHddStaCtx->ft_carrier_on = FALSE;
2580 break;
2581
2582 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002583 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07002585 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07002586 // eCSR_ROAM_SHOULD_ROAM will be received.
2587 // Where in we will not mark the link down
2588 // Also we want to stop tx at this point when we will be
2589 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002590 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002591 {
2592 struct net_device *dev = pAdapter->dev;
2593 netif_tx_disable(dev);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002594 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002595 * Deregister for this STA with TL with the objective to flush
2596 * all the packets for this STA from wmm_tx_queue. If not done here,
2597 * we would run into a race condition (CR390567) wherein TX
2598 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2599 * been deleted. And, these packets get assigned with a STA idx of
2600 * self-sta (since the peer STA has been deleted) and get transmitted
2601 * on the new channel before the reassoc request. Since there will be
2602 * no ACK on the new channel, each packet gets retransmitted which
2603 * takes several seconds before the transmission of reassoc request.
2604 * This leads to reassoc-timeout and roam failure.
2605 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002606 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2607 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2608 {
2609 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2610 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2611 pHddStaCtx->conn_info.staId[0], status, status );
2612 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002613 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002614 }
2615 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002616 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 break;
2618#endif
2619
2620 case eCSR_ROAM_SHOULD_ROAM:
2621 // Dont need to do anything
2622 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002623 struct net_device *dev = pAdapter->dev;
2624 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2625 // notify apps that we can't pass traffic anymore
2626 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002627#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002628 if (pHddStaCtx->ft_carrier_on == FALSE)
2629 {
2630#endif
2631 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002632#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002633 }
2634#endif
2635
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002636#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002637 //We should clear all sta register with TL, for now, only one.
2638 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2639 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2640 {
2641 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2642 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2643 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002644 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002645 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002646#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002647 }
2648 break;
2649 case eCSR_ROAM_LOSTLINK:
2650 case eCSR_ROAM_DISASSOCIATED:
2651 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002652 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2653 "****eCSR_ROAM_DISASSOCIATED****");
2654 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2655 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07002656 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2657 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302658 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07002659 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08002660
2661 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
2662 pHddCtx->configuredMcastBcastFilter =
2663 pHddCtx->sus_res_mcastbcast_filter;
2664 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
2665 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302666
Amar Singhald53568e2013-09-26 11:03:45 -07002667 hddLog(VOS_TRACE_LEVEL_INFO,
2668 "offload: disassociation happening, restoring configuredMcastBcastFilter");
2669 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
2670 pHddCtx->configuredMcastBcastFilter);
2671 hddLog(VOS_TRACE_LEVEL_INFO,
2672 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07002673 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2674 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002675#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302676 /* Call to clear any MC Addr List filter applied after
2677 * successful connection.
2678 */
2679 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002680#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002681 }
2682 break;
2683 case eCSR_ROAM_IBSS_LEAVE:
2684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2685 "****eCSR_ROAM_IBSS_LEAVE****");
2686 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2687 break;
2688 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2689 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2690 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Gopichand Nakkala29149562013-05-10 21:43:41 +05302691 if ( (roamResult != eCSR_ROAM_RESULT_ASSOCIATED) &&
2692 ( (pWextState->roamProfile.EncryptionType.encryptionType[0] ==
2693 eCSR_ENCRYPT_TYPE_WEP40) ||
2694 (pWextState->roamProfile.EncryptionType.encryptionType[0] ==
2695 eCSR_ENCRYPT_TYPE_WEP104)
2696 ) &&
2697 (eCSR_AUTH_TYPE_SHARED_KEY != pWextState->roamProfile.AuthType.authType[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07002698 )
2699 {
2700 v_U32_t roamId = 0;
2701 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2702 "****WEP open authentication failed, trying with shared authentication****");
2703 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
2704 pWextState->roamProfile.AuthType.authType[0] = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2705 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
2706 halStatus = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &(pWextState->roamProfile), &roamId);
2707 }
2708 else
2709 {
Arun Kumar Khandavalli700037e2014-01-24 17:56:31 +05302710 // To Do - address probable memory leak with WEP encryption upon successful association
2711 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
2712 {
2713 //Clear saved connection information in HDD
2714 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
2715 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002716 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2717 }
2718
2719 break;
2720 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002721 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002722 pRoamInfo, roamId, roamStatus, roamResult );
2723 break;
2724 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07002725 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
2726 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002727 break;
2728
2729 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2730 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002731 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002732
2733 case eCSR_ROAM_MIC_ERROR_IND:
2734 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2735 break;
2736
2737 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002738 {
2739 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2740
2741 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002742 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
2743 (TRUE == pHddCtx->hdd_wlan_suspended) &&
2744 (eCSR_ROAM_RESULT_NONE == roamResult))
2745 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002746 /* Send DTIM period to the FW; only if the wlan is already
2747 in suspend. This is the case with roaming (reassoc),
2748 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
2749 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
2750 before the ENTER_BMPS_REQ ensures Listen Interval is
2751 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002752 hdd_set_pwrparams(pHddCtx);
2753 pHddStaCtx->hdd_ReassocScenario = VOS_FALSE;
2754
2755 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002756 if due to unexpected scenario, if we are in BMPS,
2757 then trigger Exit and Enter BMPS to take DTIM period
2758 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002759 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
2760 {
2761 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
2762
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002763 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2764 iw_full_power_cbfn, pAdapter,
2765 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002766 }
2767 }
2768 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2769 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 break;
2771#ifdef WLAN_FEATURE_VOWIFI_11R
2772 case eCSR_ROAM_FT_RESPONSE:
2773 hdd_SendFTEvent(pAdapter);
2774 break;
2775#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002776#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002777 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002778 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07002779 {
2780 /* Notify the supplicant of a new candidate */
2781 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
2782 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002783 break;
2784#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002785
Yue Maef608272013-04-08 23:09:17 -07002786#ifdef FEATURE_WLAN_LFR_METRICS
2787 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
2788 /* This event is to notify pre-auth initiation */
2789 if (VOS_STATUS_SUCCESS !=
2790 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
2791 {
2792 halStatus = eHAL_STATUS_FAILURE;
2793 }
2794 break;
2795 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
2796 /* This event will notify pre-auth completion in case of success */
2797 if (VOS_STATUS_SUCCESS !=
2798 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2799 pRoamInfo, 1))
2800 {
2801 halStatus = eHAL_STATUS_FAILURE;
2802 }
2803 break;
2804 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
2805 /* This event will notify pre-auth completion in case of failure. */
2806 if (VOS_STATUS_SUCCESS !=
2807 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2808 pRoamInfo, 0))
2809 {
2810 halStatus = eHAL_STATUS_FAILURE;
2811 }
2812 break;
2813 case eCSR_ROAM_HANDOVER_SUCCESS:
2814 /* This event is to notify handover success.
2815 It will be only invoked on success */
2816 if (VOS_STATUS_SUCCESS !=
2817 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
2818 {
2819 halStatus = eHAL_STATUS_FAILURE;
2820 }
2821 break;
2822#endif
2823
Jeff Johnson295189b2012-06-20 16:38:30 -07002824 case eCSR_ROAM_INDICATE_MGMT_FRAME:
2825 hdd_indicateMgmtFrame( pAdapter,
2826 pRoamInfo->nFrameLength,
2827 pRoamInfo->pbFrames,
2828 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05302829 pRoamInfo->rxChan,
2830 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07002831 break;
2832 case eCSR_ROAM_REMAIN_CHAN_READY:
2833 hdd_remainChanReadyHandler( pAdapter );
2834 break;
2835 case eCSR_ROAM_SEND_ACTION_CNF:
2836 hdd_sendActionCnf( pAdapter,
2837 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
2838 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002839#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08002840 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002841 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08002842 roamId, roamStatus, roamResult );
2843 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002844 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
2845 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
2846 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002847#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002848#ifdef WLAN_FEATURE_11W
2849 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
2850 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
2851 pRoamInfo->pbFrames,
2852 pRoamInfo->frameType);
2853 break;
2854#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002855#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002856 case eCSR_ROAM_TSM_IE_IND:
2857 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
2858 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
2859 break;
2860
2861 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
2862 {
2863 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
2864 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
2865 {
2866 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
2867 }
2868 break;
2869 }
2870
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002871 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002872 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002873 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002874 break;
2875 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002876
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002877 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002878 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002879 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002880 break;
2881 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002882#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07002883 default:
2884 break;
2885 }
2886 return( halStatus );
2887}
Shailender Karmuchia734f332013-04-19 14:02:48 -07002888eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002889{
2890 eCsrAuthType auth_type;
2891 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002892 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002893 {
2894 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002895 } else
2896 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002897 {
2898 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002899 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002900#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07002901 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002902 {
2903 // Check for 11r FT Authentication with PSK
2904 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002905 } else
2906 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002907 {
2908 // Check for 11R FT Authentication with 802.1X
2909 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002910 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002911#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002912#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07002913 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002914 {
2915 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
2916 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002917#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07002918#ifdef WLAN_FEATURE_11W
2919 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
2920 {
2921 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
2922 } else
2923#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002924 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002925 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2926 }
2927 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002928}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002929
Shailender Karmuchia734f332013-04-19 14:02:48 -07002930eCsrAuthType
2931hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002932{
2933 eCsrAuthType auth_type;
2934 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002935 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002936 {
2937 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002938 } else
2939 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002940 {
2941 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002942 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002943#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07002944 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 {
2946 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002947 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002948#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002949 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002950 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2951 }
2952 hddLog(LOG1, FL("auth_type: %d"), auth_type);
2953 return auth_type;
2954}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002955
Shailender Karmuchia734f332013-04-19 14:02:48 -07002956eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07002957hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002958{
2959 eCsrEncryptionType cipher_type;
2960 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002961 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002962 {
2963 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002964 }
2965 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002966 {
2967 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002968 }
2969 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002970 {
2971 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002972 }
2973 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002974 {
2975 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002976 }
2977 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
2978 {
2979 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2980 }
2981 else
2982 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002983 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2984 }
2985 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2986 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002987}
Jeff Johnson295189b2012-06-20 16:38:30 -07002988/* To find if the MAC address is NULL */
2989static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
2990{
2991 int i;
2992 for (i = 0; i < length; i++)
2993 {
2994 if (0x00 != (macAddr[i]))
2995 {
2996 return FALSE;
2997 }
2998 }
2999 return TRUE;
3000} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003001
Shailender Karmuchia734f332013-04-19 14:02:48 -07003002eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003003hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003004{
3005 eCsrEncryptionType cipher_type;
3006 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003007 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003008 {
3009 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003010 } else
3011 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 {
3013 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003014 } else
3015 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003016 {
3017 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003018 } else
3019 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 {
3021 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003022 } else
3023 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003024 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003025 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3026 } else
3027 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003028 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3029 }
3030 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3031 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003032}
Jeff Johnson295189b2012-06-20 16:38:30 -07003033
Shailender Karmuchia734f332013-04-19 14:02:48 -07003034static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3035 struct ether_addr *pBssid,
3036 eCsrEncryptionType *pEncryptType,
3037 eCsrEncryptionType *mcEncryptType,
3038 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003039#ifdef WLAN_FEATURE_11W
3040 u_int8_t *pMfpRequired,
3041 u_int8_t *pMfpCapable,
3042#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003043 u_int16_t gen_ie_len,
3044 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003045{
3046 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003047 eHalStatus result;
3048 tDot11fIERSN dot11RSNIE;
3049 tDot11fIEWPA dot11WPAIE;
3050 tANI_U32 i;
3051 tANI_U8 *pRsnIe;
3052 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003053 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003054 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003055
3056 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3057 flag to 0 */
3058 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3059 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3060
3061 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003062 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
3063 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303064 {
3065 hddLog(LOGE, "%s: Invalid DOT11F IE Length passed :%d",
3066 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003067 return -EINVAL;
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303068 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003069 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003070 if ( gen_ie[0] == DOT11F_EID_RSN)
3071 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003072 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003073 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003074 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3075 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303076 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3077 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 return -EINVAL;
3079 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003080 // Skip past the EID byte and length byte
3081 pRsnIe = gen_ie + 2;
3082 RSNIeLen = gen_ie_len - 2;
3083 // Unpack the RSN IE
3084 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3085 pRsnIe,
3086 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003088 // Copy out the encryption and authentication types
3089 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003090 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003091 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003092 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003093 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003094 but probably I suspect we can do something different*/
3095 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003096 // Just translate the FIRST one
3097 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3098 //dot11RSNIE.pwise_cipher_suite_count
3099 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3100 //dot11RSNIE.gp_cipher_suite_count
3101 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003102#ifdef WLAN_FEATURE_11W
3103 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3104 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3105#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003107 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003108 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003109 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303111 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003112 break;
3113 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003114 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303116 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 break;
3118 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003119 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 // For right now, I assume setASSOCIATE() has passed in the bssid.
3121 vos_mem_copy(PMKIDCache[i].BSSID,
3122 pBssid, ETHER_ADDR_LEN);
3123 vos_mem_copy(PMKIDCache[i].PMKID,
3124 dot11RSNIE.pmkid[i],
3125 CSR_RSN_PMKID_SIZE);
3126 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003127
3128 if (updatePMKCache)
3129 {
3130 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003131 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003132 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003133 // Finally set the PMKSA ID Cache in CSR
3134 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3135 PMKIDCache,
3136 dot11RSNIE.pmkid_count );
3137 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 }
3139 else if (gen_ie[0] == DOT11F_EID_WPA)
3140 {
3141 // Validity checks
3142 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3143 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3144 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303145 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3146 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003147 return -EINVAL;
3148 }
3149 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003150 pRsnIe = gen_ie + 2 + 4;
3151 RSNIeLen = gen_ie_len - (2 + 4);
3152 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3154 pRsnIe,
3155 RSNIeLen,
3156 &dot11WPAIE);
3157 // Copy out the encryption and authentication types
3158 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003159 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003160 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003161 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 //dot11WPAIE.auth_suite_count
3163 // Just translate the FIRST one
3164 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3165 //dot11WPAIE.unicast_cipher_count
3166 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3167 //dot11WPAIE.unicast_cipher_count
3168 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3169 }
3170 else
3171 {
3172 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003173 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003174 }
3175 return 0;
3176}
3177int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3178{
3179 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3180 v_U32_t status = 0;
3181 eCsrEncryptionType RSNEncryptType;
3182 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003183#ifdef WLAN_FEATURE_11W
3184 u_int8_t RSNMfpRequired;
3185 u_int8_t RSNMfpCapable;
3186#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 struct ether_addr bSsid; // MAC address of assoc peer
3188 // MAC address of assoc peer
3189 // But, this routine is only called when we are NOT associated.
3190 vos_mem_copy(bSsid.ether_addr_octet,
3191 pWextState->roamProfile.BSSIDs.bssid,
3192 sizeof(bSsid.ether_addr_octet));
3193 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3194 {
3195 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003196 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003197 else
3198 {
3199 return 0;
3200 }
3201 // The actual processing may eventually be more extensive than this.
3202 // Right now, just consume any PMKIDs that are sent in by the app.
3203 status = hdd_ProcessGENIE(pAdapter,
3204 &bSsid, // MAC address of assoc peer
3205 &RSNEncryptType,
3206 &mcRSNEncryptType,
3207 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003208#ifdef WLAN_FEATURE_11W
3209 &RSNMfpRequired,
3210 &RSNMfpCapable,
3211#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 pWextState->WPARSNIE[1]+2,
3213 pWextState->WPARSNIE);
3214 if (status == 0)
3215 {
3216 // Now copy over all the security attributes you have parsed out
3217 pWextState->roamProfile.EncryptionType.numEntries = 1;
3218 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003219
Jeff Johnson295189b2012-06-20 16:38:30 -07003220 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3221 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003222
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003223 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3224 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3225 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3226 {
3227 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3228 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3229 either AES/TKIP based on group cipher configuration
3230 mentioned in the wpa_supplicant.conf.*/
3231
3232 /*Set the unicast cipher same as multicast cipher*/
3233 pWextState->roamProfile.EncryptionType.encryptionType[0]
3234 = mcRSNEncryptType;
3235 }
3236
Chet Lanctot186b5732013-03-18 10:26:30 -07003237#ifdef WLAN_FEATURE_11W
3238 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3239 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3240#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003241 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003242 }
3243 return 0;
3244}
3245int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3246{
3247 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3248 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3249 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3250 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003251
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003253 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003254
Jeff Johnson295189b2012-06-20 16:38:30 -07003255 switch( pHddStaCtx->conn_info.authType)
3256 {
3257 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003258#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 case eCSR_AUTH_TYPE_CCKM_WPA:
3260 case eCSR_AUTH_TYPE_CCKM_RSN:
3261#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003262 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3263
Jeff Johnson295189b2012-06-20 16:38:30 -07003264 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003265 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003266 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003267
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003268#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003269 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3270 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3271 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003272 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003273 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3274 } else
3275 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003276 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003277 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 } else
3279#endif
3280 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3281 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003282 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3283 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3285 == IW_AUTH_KEY_MGMT_PSK) {
3286 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003287 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003289 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003290 }
3291 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003292#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003293 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3294 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3295 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003296 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003297 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003299 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003300 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003301 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003302 } else
3303#endif
3304
3305#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003306 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3307 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003308 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003309 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003310 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003311 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003312 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3313 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003314 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003315 } else
3316#endif
3317
Chet Lanctot186b5732013-03-18 10:26:30 -07003318#ifdef WLAN_FEATURE_11W
3319 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3320 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3321 } else
3322#endif
3323
Shailender Karmuchia734f332013-04-19 14:02:48 -07003324 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003325 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003326 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3327 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3329 == IW_AUTH_KEY_MGMT_PSK) {
3330 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003331 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003332 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003333 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003334 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003335 break;
3336
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003338
3339 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003340 break;
3341 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003342
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003343#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08003344 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003345#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003346 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3347 break;
3348 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003349
Jeff Johnson295189b2012-06-20 16:38:30 -07003350 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003351 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003352
Jeff Johnson295189b2012-06-20 16:38:30 -07003353 EXIT();
3354 return 0;
3355}
3356
3357/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003358
3359 \brief iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07003361 to the CSR roam profile.
3362
Jeff Johnson295189b2012-06-20 16:38:30 -07003363 \param - dev - Pointer to the net device.
3364 - info - Pointer to the iw_request_info.
3365 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003366 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003368
Jeff Johnson295189b2012-06-20 16:38:30 -07003369 --------------------------------------------------------------------------*/
3370
Shailender Karmuchia734f332013-04-19 14:02:48 -07003371int iw_set_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 struct iw_request_info *info,
3373 union iwreq_data *wrqu, char *extra)
3374{
3375 v_U32_t status = 0;
3376 hdd_wext_state_t *pWextState;
3377 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3378 v_U32_t roamId;
3379 tCsrRoamProfile *pRoamProfile;
3380 eMib_dot11DesiredBssType connectedBssType;
3381 eCsrAuthType RSNAuthType;
3382 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3383 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003384
3385 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3386
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 ENTER();
3388
3389 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3390 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003392 "%s:LOGP in Progress. Ignore!!!",__func__);
3393 return 0;
3394 }
3395
3396 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
3397 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
3398 return -EBUSY;
3399 }
3400 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
3401 return -EINVAL;
3402 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003403 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 {
3405 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
3406 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
3407 {
3408 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003409 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3411 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
3412
3413 if(VOS_STATUS_SUCCESS == vosStatus)
3414 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3415 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3416 }
3417 }
3418 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003419 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 {
3421 return -EINVAL;
3422 }
3423 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003424 /** when cfg80211 defined, wpa_supplicant wext driver uses
3425 zero-length, null-string ssid for force disconnection.
3426 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07003427 driver MUST return success */
3428 if ( 0 == wrqu->essid.length ) {
3429 return 0;
3430 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003431
3432 status = hdd_wmm_get_uapsd_mask(pAdapter,
3433 &pWextState->roamProfile.uapsd_mask);
3434 if (VOS_STATUS_SUCCESS != status)
3435 {
3436 pWextState->roamProfile.uapsd_mask = 0;
3437 }
3438 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003439
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003441
3442 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003443 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
3444 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
3445 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003446
Jeff Johnson295189b2012-06-20 16:38:30 -07003447 //set gen ie
3448 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
3449
3450 //set auth
3451 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
3452 }
3453#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003454 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 if (pAdapter->wapi_info.nWapiMode)
3456 {
3457 switch (pAdapter->wapi_info.wapiAuthMode)
3458 {
3459 case WAPI_AUTH_MODE_PSK:
3460 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003461 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003462 pRoamProfile->AuthType.numEntries = 1;
3463 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3464 break;
3465 }
3466 case WAPI_AUTH_MODE_CERT:
3467 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003468 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003469 pRoamProfile->AuthType.numEntries = 1;
3470 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3471 break;
3472 }
3473 } // End of switch
3474 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
3475 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
3476 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003477 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 pRoamProfile->EncryptionType.numEntries = 1;
3479 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3480 pRoamProfile->mcEncryptionType.numEntries = 1;
3481 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3482 }
3483 }
3484#endif /* FEATURE_WLAN_WAPI */
3485 /* if previous genIE is not NULL, update AssocIE */
3486 if (0 != pWextState->genIE.length)
3487 {
3488 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
3489 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
3490 pWextState->genIE.length);
3491 pWextState->assocAddIE.length = pWextState->genIE.length;
3492 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
3493 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
3494
3495 /* clear previous genIE after use it */
3496 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
3497 }
3498
3499 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
3500 pWextState->roamProfile.bWPSAssociation = FALSE;
3501
3502 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
3503 pWextState->roamProfile.nAddIEAssocLength))
3504 pWextState->roamProfile.bWPSAssociation = TRUE;
3505
3506
3507 // Disable auto BMPS entry by PMC until DHCP is done
3508 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
3509
Shailender Karmuchia734f332013-04-19 14:02:48 -07003510 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003512
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003513 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
3514 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003515 hdd_select_cbmode(pAdapter,
3516 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
3517 }
3518 status = sme_RoamConnect( hHal,pAdapter->sessionId,
3519 &(pWextState->roamProfile), &roamId);
3520 pRoamProfile->ChannelInfo.ChannelList = NULL;
3521 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003522
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003523 EXIT();
3524 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003525}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003526
Jeff Johnson295189b2012-06-20 16:38:30 -07003527/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003528
3529 \brief iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003530 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003531
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 \param - dev - Pointer to the net device.
3533 - info - Pointer to the iw_request_info.
3534 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003535 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003536 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003537
Jeff Johnson295189b2012-06-20 16:38:30 -07003538 --------------------------------------------------------------------------*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003539int iw_get_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003540 struct iw_request_info *info,
3541 struct iw_point *dwrq, char *extra)
3542{
3543 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003544 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003545 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3546 ENTER();
3547
3548 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
3549 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
3550 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
3551 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
3552 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
3553 {
3554 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
3555 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
3556 dwrq->flags = 1;
3557 } else {
3558 memset(extra, 0, dwrq->length);
3559 dwrq->length = 0;
3560 dwrq->flags = 0;
3561 }
3562 EXIT();
3563 return 0;
3564}
3565/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003566
3567 \brief iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003568 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003569
Jeff Johnson295189b2012-06-20 16:38:30 -07003570 \param - dev - Pointer to the net device.
3571 - info - Pointer to the iw_request_info.
3572 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003573 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003574 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003575
Jeff Johnson295189b2012-06-20 16:38:30 -07003576 --------------------------------------------------------------------------*/
3577int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
3578 union iwreq_data *wrqu,char *extra)
3579{
3580 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003581 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003582 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3583 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003584 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07003585 eCsrEncryptionType ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003586
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003588
3589 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3590 {
3591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3592 "%s:LOGP in Progress. Ignore!!!", __func__);
3593 return -EBUSY;
3594 }
3595
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 switch(wrqu->param.flags & IW_AUTH_INDEX)
3597 {
3598 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003599
Jeff Johnson295189b2012-06-20 16:38:30 -07003600 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003601
Jeff Johnson295189b2012-06-20 16:38:30 -07003602 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003603
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 case IW_AUTH_CIPHER_PAIRWISE:
3605 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003606 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003607 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003608 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003609 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3610 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003611 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
3613 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003614 }
3615
Jeff Johnson295189b2012-06-20 16:38:30 -07003616 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003617
3618 if( (IW_AUTH_KEY_MGMT_802_1X
3619 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003620 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
3621 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003622 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07003623 else
3624 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003625 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3626 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003627 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003628
3629 if( ( IW_AUTH_KEY_MGMT_802_1X
3630 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3632 /*Dynamic WEP key*/
3633 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3634 else
3635 /*Static WEP key*/
3636 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003637
Jeff Johnson295189b2012-06-20 16:38:30 -07003638 }
3639 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003640
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003642 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003643 return -EINVAL;
3644 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003645
Jeff Johnson295189b2012-06-20 16:38:30 -07003646 pRoamProfile->EncryptionType.numEntries = 1;
3647 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003648 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 break;
3650 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003651 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003652 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
3653 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3654 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003655
Jeff Johnson295189b2012-06-20 16:38:30 -07003656 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3657 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
3658 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003659
3660 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003661 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
3662 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003663
Jeff Johnson295189b2012-06-20 16:38:30 -07003664 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003665
3666 if( ( IW_AUTH_KEY_MGMT_802_1X
3667 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
3668 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3669
Jeff Johnson295189b2012-06-20 16:38:30 -07003670 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003671
3672 else
3673 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003674 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003675
3676 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
3677 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003678 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003679 if( ( IW_AUTH_KEY_MGMT_802_1X
3680 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3682 {
3683 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3684 }
3685 else
3686 {
3687 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3688 }
3689 }
3690 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003691
Jeff Johnson295189b2012-06-20 16:38:30 -07003692 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003693 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 return -EINVAL;
3695 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003696
Jeff Johnson295189b2012-06-20 16:38:30 -07003697 pRoamProfile->mcEncryptionType.numEntries = 1;
3698 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
3699 }
3700 break;
3701
3702 case IW_AUTH_80211_AUTH_ALG:
3703 {
3704 /*Save the auth algo here and set auth type to SME Roam profile
3705 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003706 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07003707 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003708
Jeff Johnson295189b2012-06-20 16:38:30 -07003709 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
3710 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
3711
3712 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
3713 /*Not supported*/
3714 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3715 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
3716 }
3717 break;
3718
3719 case IW_AUTH_KEY_MGMT:
3720 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003721#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003722#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
3723 /*Check for CCKM AKM type */
3724 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003725 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
3726 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003727 /* Set the CCKM bit in authKeyMgmt */
3728 /* Right now, this breaks all ref to authKeyMgmt because our
3729 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 */
3731 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
3732 /*Set the key management to 802.1X*/
3733 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003734 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003735 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3736 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3737 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
3738 /*Save the key management*/
3739 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
3740 //pWextState->authKeyMgmt = wrqu->param.value;
3741 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3742 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3743 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
3744 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
3745 /*Save the key management anyway*/
3746 pWextState->authKeyMgmt = wrqu->param.value;
3747 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
3748 /*Save the key management*/
3749 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
3750 //pWextState->authKeyMgmt = wrqu->param.value;
3751 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3752 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3753 }
3754#else
3755 /*Save the key management*/
3756 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003757#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003758 }
3759 break;
3760
3761 case IW_AUTH_TKIP_COUNTERMEASURES:
3762 {
3763 if(wrqu->param.value) {
3764 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3765 "Counter Measure started %d", wrqu->param.value);
3766 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
3767 }
3768 else {
3769 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3770 "Counter Measure stopped=%d", wrqu->param.value);
3771 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3772 }
3773 }
3774 break;
3775 case IW_AUTH_DROP_UNENCRYPTED:
3776 case IW_AUTH_WPA_ENABLED:
3777 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3778 case IW_AUTH_ROAMING_CONTROL:
3779 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003780
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003782
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003783 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 wrqu->param.flags & IW_AUTH_INDEX);
3785 break;
3786 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003787
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 EXIT();
3789 return 0;
3790}
3791/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003792
3793 \brief iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003794 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003795
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 \param - dev - Pointer to the net device.
3797 - info - Pointer to the iw_request_info.
3798 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003799 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003800 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003801
Jeff Johnson295189b2012-06-20 16:38:30 -07003802 --------------------------------------------------------------------------*/
3803int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
3804 union iwreq_data *wrqu,char *extra)
3805{
3806 hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003807 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003808 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3809 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003810
3811 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3812 {
3813 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3814 "%s:LOGP in Progress. Ignore!!!", __func__);
3815 return -EBUSY;
3816 }
3817
Jeff Johnson295189b2012-06-20 16:38:30 -07003818 switch(pRoamProfile->negotiatedAuthType)
3819 {
3820 case eCSR_AUTH_TYPE_WPA_NONE:
3821 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3822 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
3823 break;
3824 case eCSR_AUTH_TYPE_WPA:
3825 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3826 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
3827 break;
3828#ifdef WLAN_FEATURE_VOWIFI_11R
3829 case eCSR_AUTH_TYPE_FT_RSN:
3830#endif
3831 case eCSR_AUTH_TYPE_RSN:
3832 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3833 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
3834 break;
3835 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3836 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3837 break;
3838 case eCSR_AUTH_TYPE_SHARED_KEY:
3839 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
3840 break;
3841 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003842 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3844 break;
3845 case eCSR_AUTH_TYPE_AUTOSWITCH:
3846 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3847 break;
3848 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303849 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3851 return -EIO;
3852#ifdef WLAN_FEATURE_VOWIFI_11R
3853 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3854#endif
3855 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07003856#ifdef WLAN_FEATURE_11W
3857 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3858#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05303859 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3861 return -EIO;
3862 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303863 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3865 return -EIO;
3866 }
3867 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
3868 {
3869 switch(pRoamProfile->negotiatedUCEncryptionType)
3870 {
3871 case eCSR_ENCRYPT_TYPE_NONE:
3872 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3873 break;
3874 case eCSR_ENCRYPT_TYPE_WEP40:
3875 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3876 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3877 break;
3878 case eCSR_ENCRYPT_TYPE_TKIP:
3879 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3880 break;
3881 case eCSR_ENCRYPT_TYPE_WEP104:
3882 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3883 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3884 break;
3885 case eCSR_ENCRYPT_TYPE_AES:
3886 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3887 break;
3888 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303889 hddLog(LOG1, "%s called with unknown auth type %d ",
3890 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 return -EIO;
3892 }
3893 }
3894
Shailender Karmuchia734f332013-04-19 14:02:48 -07003895 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07003896 {
3897 switch(pRoamProfile->negotiatedMCEncryptionType)
3898 {
3899 case eCSR_ENCRYPT_TYPE_NONE:
3900 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3901 break;
3902 case eCSR_ENCRYPT_TYPE_WEP40:
3903 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3904 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3905 break;
3906 case eCSR_ENCRYPT_TYPE_TKIP:
3907 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3908 break;
3909 case eCSR_ENCRYPT_TYPE_WEP104:
3910 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3911 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3912 break;
3913 case eCSR_ENCRYPT_TYPE_AES:
3914 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3915 break;
3916 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303917 hddLog(LOG1, "%s called with unknown auth type %d ",
3918 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003919 return -EIO;
3920 }
3921 }
3922
3923 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003924 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003925 EXIT();
3926 return 0;
3927}
3928/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003929
3930 \brief iw_set_ap_address() -
3931 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07003932 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003933
Jeff Johnson295189b2012-06-20 16:38:30 -07003934 \param - dev - Pointer to the net device.
3935 - info - Pointer to the iw_request_info.
3936 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003937 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003938 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003939
Jeff Johnson295189b2012-06-20 16:38:30 -07003940 --------------------------------------------------------------------------*/
3941int iw_set_ap_address(struct net_device *dev,
3942 struct iw_request_info *info,
3943 union iwreq_data *wrqu, char *extra)
3944{
3945 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3946 v_U8_t *pMacAddress=NULL;
3947 ENTER();
3948 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08003949 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
3950 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07003951 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
3952 EXIT();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003953
Jeff Johnson295189b2012-06-20 16:38:30 -07003954 return 0;
3955}
3956/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003957
3958 \brief iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003959 This function returns the BSSID to the wpa_supplicant
3960 \param - dev - Pointer to the net device.
3961 - info - Pointer to the iw_request_info.
3962 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003963 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003964 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003965
Jeff Johnson295189b2012-06-20 16:38:30 -07003966 --------------------------------------------------------------------------*/
3967int iw_get_ap_address(struct net_device *dev,
3968 struct iw_request_info *info,
3969 union iwreq_data *wrqu, char *extra)
3970{
3971 //hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3972 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3973
3974 ENTER();
3975
3976 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
3977 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
3978 {
Jeff Johnson4416a782013-03-25 14:17:50 -07003979 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003980 }
3981 else
3982 {
3983 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
3984 }
3985 EXIT();
3986 return 0;
3987}
Jeff Johnsond13512a2012-07-17 11:42:19 -07003988
Chet Lanctot186b5732013-03-18 10:26:30 -07003989#ifdef WLAN_FEATURE_11W
3990/**---------------------------------------------------------------------------
3991
3992 \brief hdd_indicateUnprotMgmtFrame -
3993 This function forwards the unprotected management frame to the supplicant
3994 \param - pAdapter - Pointer to HDD adapter
3995 - nFrameLength - Length of the unprotected frame being passed
3996 - pbFrames - Pointer to the frame buffer
3997 - frameType - 802.11 frame type
3998 \return - nothing
3999
4000 --------------------------------------------------------------------------*/
4001void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
4002 tANI_U32 nFrameLength,
4003 tANI_U8* pbFrames,
4004 tANI_U8 frameType )
4005{
4006 tANI_U8 type = 0;
4007 tANI_U8 subType = 0;
4008
4009 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
4010 __func__, frameType, nFrameLength);
4011
4012 /* Sanity Checks */
4013 if (NULL == pAdapter)
4014 {
4015 hddLog( LOGE, FL("pAdapter is NULL"));
4016 return;
4017 }
4018
4019 if (NULL == pAdapter->dev)
4020 {
4021 hddLog( LOGE, FL("pAdapter->dev is NULL"));
4022 return;
4023 }
4024
4025 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
4026 {
4027 hddLog( LOGE, FL("pAdapter has invalid magic"));
4028 return;
4029 }
4030
4031 if( !nFrameLength )
4032 {
4033 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
4034 return;
4035 }
4036
4037 if (NULL == pbFrames) {
4038 hddLog( LOGE, FL("pbFrames is NULL"));
4039 return;
4040 }
4041
4042 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4043 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4044
4045 /* Get pAdapter from Destination mac address of the frame */
4046 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
4047 {
4048 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
4049 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4050 }
4051 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
4052 {
4053 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
4054 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4055 }
4056 else
4057 {
4058 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
4059 return;
4060 }
4061}
4062#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004063
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004064#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004065void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
4066 tANI_U8 state,
4067 tANI_U16 measInterval )
4068{
4069 union iwreq_data wrqu;
4070 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004071 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004072
4073 if (NULL == pAdapter)
4074 return;
4075
4076 // create the event
4077 memset(&wrqu, '\0', sizeof(wrqu));
4078 memset(buf, '\0', sizeof(buf));
4079
4080 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
4081 tid, state, measInterval);
4082
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004083 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004084
4085 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004086 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004087 // send the event
4088 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4089}
4090
4091void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4092{
4093 union iwreq_data wrqu;
4094 char buf[IW_CUSTOM_MAX + 1];
4095 char *pos = buf;
4096 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4097
4098 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4099 return;
4100
4101 // create the event
4102 memset(&wrqu, '\0', sizeof(wrqu));
4103 memset(buf, '\0', sizeof(buf));
4104
4105 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304106 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
4107 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
4108 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
4109 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004110
4111 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4112 pos += nBytes;
4113 freeBytes -= nBytes;
4114
4115 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
4116 pos += WNI_CFG_BSSID_LEN;
4117 freeBytes -= WNI_CFG_BSSID_LEN;
4118
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004119 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4120 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004121
4122 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004123 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004124
4125 // send the event
4126 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4127}
4128
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004129void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004130{
4131 union iwreq_data wrqu;
4132 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004133 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004134
4135 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4136 return;
4137
4138 // create the event
4139 memset(&wrqu, '\0', sizeof(wrqu));
4140 memset(buf, '\0', sizeof(buf));
4141
4142 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
4143
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004144 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004145
4146 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004147 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004148
4149 // send the event
4150 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4151}
4152
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004153void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004154 const tCsrRoamInfo *pRoamInfo)
4155{
4156 union iwreq_data wrqu;
4157 char buf[IW_CUSTOM_MAX + 1];
4158 char *pos = buf;
4159 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4160 tANI_U8 i = 0, len = 0;
4161 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
4162 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004163 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
4164 tANI_U8 ieLenByte = 1;
4165 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
4166#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004167
4168 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4169 return;
4170
4171 /* Custom event can pass maximum of 256 bytes of data,
4172 based on the IE len we need to identify how many BSS info can
4173 be filled in to custom event data */
4174 /*
4175 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4176 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4177 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4178 */
4179
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004180 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004181 {
4182 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
4183 /* If the measurement is none and no scan results found,
4184 indicate the supplicant about measurement done */
4185 memset(&wrqu, '\0', sizeof(wrqu));
4186 memset(buf, '\0', sizeof(buf));
4187
4188 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004189 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4190 pRoamInfo->pEseBcnReportRsp->numBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004191
4192 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004193 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4194 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004195
4196 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004197 wrqu.data.length = nBytes;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004198 // send the event
4199 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4200 }
4201 else
4202 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004203 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004204 {
4205 memset(&wrqu, '\0', sizeof(wrqu));
4206 memset(buf, '\0', sizeof(buf));
4207 tot_bcn_ieLen = 0;
4208 sendBss = 0;
4209 pos = buf;
4210 freeBytes = IW_CUSTOM_MAX;
4211
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004212 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004213 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004214 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
4215 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004216 {
4217 break;
4218 }
4219 tot_bcn_ieLen += len;
4220 sendBss++;
4221 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
4222 "IeLength(%d) Length of Ie(%d) totLen(%d)",
4223 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004224 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004225 tot_bcn_ieLen);
4226 }
4227
4228 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
4229 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004230 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4231 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004232
4233 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004234 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4235 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004236 pos += nBytes;
4237 freeBytes -= nBytes;
4238
4239 /* Copy total Beacon report data length */
4240 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
4241 pos += sizeof(tot_bcn_ieLen);
4242 freeBytes -= sizeof(tot_bcn_ieLen);
4243
4244 for (i = 0; i < sendBss; i++)
4245 {
4246 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304247 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4248 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004249 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004250 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
4251 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
4252 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
4253 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
4254 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
4255 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
4256 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
4257 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
4258 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
4259 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
4260 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
4261 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
4262 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
4263 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
4264 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
4265 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004266
4267 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004268 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
4269 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004270 pos += len;
4271 freeBytes -= len;
4272
4273 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004274 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004275 vos_mem_copy(pos, (char*)&len, sizeof(len));
4276 pos += sizeof(len);
4277 freeBytes -= sizeof(len);
4278
4279 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004280 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004281 pos += len;
4282 freeBytes -= len;
4283 }
4284
4285 wrqu.data.pointer = buf;
4286 wrqu.data.length = strlen(buf);
4287
4288 // send the event
4289 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4290 lastSent += sendBss;
4291 }
4292 }
4293}
4294
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004295#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004296