blob: 4577696b3cb06c6184e2bf376d7ad2ff87afccea [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"
Sushant Kaushikba6764e2014-06-30 19:52:09 +053066#include "wlan_hdd_hostapd.h"
Mukul Sharma84f27252014-07-14 18:11:42 +053067#ifdef DEBUG_ROAM_DELAY
68#include "vos_utils.h"
69#endif
70
Jeff Johnson295189b2012-06-20 16:38:30 -070071v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
72
Shailender Karmuchia734f332013-04-19 14:02:48 -070073struct ether_addr
Jeff Johnson295189b2012-06-20 16:38:30 -070074{
75 u_char ether_addr_octet[6];
76};
77// These are needed to recognize WPA and RSN suite types
78#define HDD_WPA_OUI_SIZE 4
79v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
80v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
81v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
82v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
83v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
84v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080085#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070086v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080087#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -070088#define HDD_RSN_OUI_SIZE 4
89v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
90v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
91v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
92v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
93v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
94v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080095#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -070096v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -080097#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -070098#ifdef WLAN_FEATURE_11W
99v_U8_t ccpRSNOui07[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x06 }; // RSN-PSK-SHA256
100#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700101
Shailender Karmuchia734f332013-04-19 14:02:48 -0700102#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700103// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700104#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
105#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700106#endif
107
108#define BEACON_FRAME_IES_OFFSET 12
109
Chet Lanctot186b5732013-03-18 10:26:30 -0700110#ifdef WLAN_FEATURE_11W
111void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
112 tANI_U32 nFrameLength,
113 tANI_U8* pbFrames,
114 tANI_U8 frameType );
115#endif
116
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800117#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700118static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
119 tANI_U8 state,
120 tANI_U16 measInterval );
121static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800122static void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
123static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700124
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800125#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700126
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530127static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
128 tCsrRoamInfo *pRoamInfo,
129 tANI_U32 roamId,
130 eRoamCmdStatus roamStatus,
131 eCsrRoamResult roamResult );
132
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530133v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
134 eConnectionState connState )
135{
136 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530137 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
138 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700139 pHddStaCtx->conn_info.connState = connState;
140}
141
142// returns FALSE if not connected.
143// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
144// returns the connection state. Can specify NULL if you dont' want to get the actual state.
145
Shailender Karmuchia734f332013-04-19 14:02:48 -0700146static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
147 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700148{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700149 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700150 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700151
Jeff Johnson295189b2012-06-20 16:38:30 -0700152 // get the connection state.
153 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700154 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700155 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700156 eConnectionState_IbssConnected == connState ||
157 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700158 {
159 fConnected = VOS_TRUE;
160 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700161 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700162 {
163 fConnected = VOS_FALSE;
164 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700165
Jeff Johnson295189b2012-06-20 16:38:30 -0700166 if ( pConnState )
167 {
168 *pConnState = connState;
169 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700170
Jeff Johnson295189b2012-06-20 16:38:30 -0700171 return( fConnected );
172}
173
174v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
175{
176 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700177}
Jeff Johnson295189b2012-06-20 16:38:30 -0700178
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530179eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx )
180{
181 v_U8_t staChannel = 0;
182
183 if ( eConnectionState_Associated == pHddStaCtx->conn_info.connState )
184 {
185 staChannel = pHddStaCtx->conn_info.operationChannel;
186 }
187
188 if ( staChannel > 0 && staChannel < 14 )
189 return eCSR_BAND_24;
190 else if (staChannel >= 36 && staChannel <= 165 )
191 return eCSR_BAND_5G;
192 else /* If station is not connected return as eCSR_BAND_ALL */
193 return eCSR_BAND_ALL;
194}
195
196
Jeff Johnson295189b2012-06-20 16:38:30 -0700197//TODO - Not used anyhwere. Can be removed.
198#if 0
199//
200v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
201{
202 v_BOOL_t fConnectedInfra = FALSE;
203 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700204
Jeff Johnson295189b2012-06-20 16:38:30 -0700205 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700206 {
207 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700208 {
209 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700210 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700211 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700212
Jeff Johnson295189b2012-06-20 16:38:30 -0700213 return( fConnectedInfra );
214}
215#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700216
Jeff Johnson295189b2012-06-20 16:38:30 -0700217static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
218{
219 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700220
Jeff Johnson295189b2012-06-20 16:38:30 -0700221 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700222
223 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700224 {
225 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
226 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700227
Jeff Johnson295189b2012-06-20 16:38:30 -0700228 return( fConnected );
229}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700230
Jeff Johnson295189b2012-06-20 16:38:30 -0700231inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
232{
233 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700234
Jeff Johnson295189b2012-06-20 16:38:30 -0700235 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700236
237 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700238 {
239 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
240 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700241
Jeff Johnson295189b2012-06-20 16:38:30 -0700242 return( fConnected );
243}
244
245static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
246{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700247 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700248 {
249 case eCSR_BSS_TYPE_INFRASTRUCTURE:
250 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
251 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700252
Jeff Johnson295189b2012-06-20 16:38:30 -0700253 case eCSR_BSS_TYPE_IBSS:
254 case eCSR_BSS_TYPE_START_IBSS:
255 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
256 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700257
258 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700259 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700260 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700261 default:
262 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700263 break;
264 }
265
Jeff Johnson295189b2012-06-20 16:38:30 -0700266}
267
268void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
269{
270 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
271 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700272
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700274
275 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700276 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700277 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
279 {
280 VOS_ASSERT( pRoamInfo->pBssDesc );
281 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
282
283 // Save the Station ID for this station from the 'Roam Info'.
284 //For IBSS mode, staId is assigned in NEW_PEER_IND
285 //For reassoc, the staID doesn't change and it may be invalid in this structure
286 //so no change here.
287 if( !pRoamInfo->fReassocReq )
288 {
289 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
290 }
291 }
292 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700293 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700294 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700295 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700296 else
297 {
298 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
299 // or we can't function.
300 VOS_ASSERT( 0 );
301 }
302
303 // notify WMM
304 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
305
306 if( !pRoamInfo->u.pConnectedProfile )
307 {
308 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
309 }
310 else
311 {
312 // Get Multicast Encryption Type
313 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
314 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
315 // Get Unicast Encrytion Type
316 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
317 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
318
319 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
320
321 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
322
323 // Save the ssid for the connection
324 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530325
326 // Save dot11mode in which STA associated to AP
327 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700328 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700329 }
330
Jeff Johnson295189b2012-06-20 16:38:30 -0700331 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700332 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
333
Jeff Johnson295189b2012-06-20 16:38:30 -0700334}
335
336#if defined(WLAN_FEATURE_VOWIFI_11R)
337/*
338 * Send the 11R key information to the supplicant.
339 * Only then can the supplicant generate the PMK-R1.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800340 * (BTW, the ESE supplicant also needs the Assoc Resp IEs
Jeff Johnson295189b2012-06-20 16:38:30 -0700341 * for the same purpose.)
342 *
343 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
344 * this contains the R1KHID, R0KHID and the MDID.
345 * For FT, this consists of the Reassoc Rsp FTIEs.
346 * This is the Assoc Response.
347 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700348static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700349 tCsrRoamInfo *pCsrRoamInfo)
350{
351 union iwreq_data wrqu;
352 char *buff;
353 unsigned int len = 0;
354 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700355
356 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700357 {
358 hddLog(LOGE,
359 "%s: pCsrRoamInfo->nAssocRspLength=%d",
360 __func__, (int)pCsrRoamInfo->nAssocRspLength);
361 return;
362 }
363
Shailender Karmuchia734f332013-04-19 14:02:48 -0700364 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700365 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700366 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700367 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700368 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 return;
370 }
371
372 // pFTAssocRsp needs to point to the IEs
373 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
374 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
375 (unsigned int)pFTAssocRsp[0],
376 (unsigned int)pFTAssocRsp[1]);
377
378 // We need to send the IEs to the supplicant.
379 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700380 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700381 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700382 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700383 return;
384 }
385
386 // Send the Assoc Resp, the supplicant needs this for initial Auth.
387 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700388 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700389 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700390 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
392
393 kfree(buff);
394}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700395#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700396
397#ifdef WLAN_FEATURE_VOWIFI_11R
398
399/*---------------------------------------------------
400 *
401 * Send the FTIEs, RIC IEs during FT. This is eventually
402 * used to send the FT events to the supplicant
403 *
404 * At the reception of Auth2 we send the RIC followed
405 * by the auth response IEs to the supplicant.
406 * Once both are received in the supplicant, an FT
407 * event is generated to the supplicant.
408 *
409 *---------------------------------------------------
410 */
411void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
412{
Jeff Johnson295189b2012-06-20 16:38:30 -0700413 tANI_U16 auth_resp_len = 0;
414 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
416
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530417#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700418 struct cfg80211_ft_event_params ftEvent;
419 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
420 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
421 struct net_device *dev = pAdapter->dev;
422#else
423 char *buff;
424 union iwreq_data wrqu;
425 tANI_U16 str_len;
426#endif
427
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530428#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530429 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
430 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700431
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530432 sme_GetRICIEs( pHddCtx->hHal, (u8 *)ricIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800433 DOT11F_IE_FTINFO_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530434 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700435 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530436 hddLog(LOGW,
437 "%s: RIC IEs is of length 0 not sending RIC Information for now",
438 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700439 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700440
441 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530442 ftEvent.ric_ies_len = ric_ies_length;
443 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700444
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530445 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800446 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700447
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530448 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700449 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530450 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700451 return;
452 }
453
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530454 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530455
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530456 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700457
458 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
459 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
460
Jeff Johnson59a121e2013-11-30 09:46:08 -0800461 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
462 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
463 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530464 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800465 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
466 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
467 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700468
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530469 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700470
471#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530472 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -0700473 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530474 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700475 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530476 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 return;
478 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530479 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700480
Shailender Karmuchia734f332013-04-19 14:02:48 -0700481 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -0700482 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530483 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800484 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530485 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700486 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530487 hddLog(LOGW,
488 "%s: RIC IEs is of length 0 not sending RIC Information for now",
489 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 }
491 else
492 {
493 wrqu.data.length = str_len + ric_ies_length;
494 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
495 }
496
497 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530498 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700499 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530500 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
501 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700502
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530503 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700504 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530505 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 return;
507 }
508
509 wrqu.data.length = str_len + auth_resp_len;
510 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
511
512 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700513#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700514}
515
516#endif /* WLAN_FEATURE_VOWIFI_11R */
517
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800518#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700519
520/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800521 * Send the ESE required "new AP Channel info" to the supplicant.
Jeff Johnson295189b2012-06-20 16:38:30 -0700522 * (This keeps the supplicant "up to date" on the current channel.)
523 *
524 * The current (new AP) channel information is passed in.
525 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700526static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700527 tCsrRoamInfo *pCsrRoamInfo)
528{
529 union iwreq_data wrqu;
530 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700531
Shailender Karmuchia734f332013-04-19 14:02:48 -0700532
533 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700534 {
535 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800536 "%s: pCsrRoamInfo->pBssDesc=%p",
Jeff Johnson295189b2012-06-20 16:38:30 -0700537 __func__, descriptor);
538 return;
539 }
540
541 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -0800542 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700543 memset(&wrqu, '\0', sizeof(wrqu));
544 wrqu.freq.m = descriptor->channelId;
545 wrqu.freq.e = 0;
546 wrqu.freq.i = 0;
547 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
548}
549
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800550#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700551
552void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
553{
554 union iwreq_data wrqu;
555 u8 *pBeaconIes;
556 u8 currentLen = 0;
557 char *buff;
558 int totalIeLen = 0, currentOffset = 0, strLen;
559
560 memset(&wrqu, '\0', sizeof(wrqu));
561
562 if (0 == pCsrRoamInfo->nBeaconLength)
563 {
564 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
565 return;
566 }
567 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700568 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700569 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700570 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 return;
572 }
573
574 // pBeaconIes needs to point to the IEs
575 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
576 (unsigned int)pBeaconIes[0],
577 (unsigned int)pBeaconIes[1]);
578 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700579
Jeff Johnson295189b2012-06-20 16:38:30 -0700580 // We need to send the IEs to the supplicant.
581 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700582 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700583 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700584 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 return;
586 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700587 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700588
589 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
590 currentLen = strLen + 1;
591
592 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
593 do
594 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700595 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 * max size and send it to supplicant. Changes are done in supplicant to handle this */
597 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
598 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
599 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
600 currentOffset += currentLen;
601 totalIeLen -= currentLen;
602 wrqu.data.length = strLen + 1 + currentLen;
603 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700604 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -0700605 else
606 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
607
608 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
609 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
610 } while (totalIeLen > 0);
611
612 kfree(buff);
613}
614
615static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
616{
617 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
618 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
619 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
620 union iwreq_data wrqu;
621 int we_event;
622 char *msg;
623 int type = -1;
624
Shailender Karmuchia734f332013-04-19 14:02:48 -0700625#if defined (WLAN_FEATURE_VOWIFI_11R)
626 // Added to find the auth type on the fly at run time
627 // rather than with cfg to see if FT is enabled
628 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700629 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
630#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700631
Jeff Johnson295189b2012-06-20 16:38:30 -0700632 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -0700633 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700635
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
637 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530638 /* In case of roaming ; We are not doing disconnect.
639 * If disconnect is not being done for roam; We will not
640 * decrease count for Active sessions. We should not increase active
641 * active session in case of roaming.
642 */
643 if(pHddStaCtx->ft_carrier_on == FALSE)
644 {
645 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
646 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700647 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
648 type = WLAN_STA_ASSOC_DONE_IND;
649
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700650#ifdef WLAN_FEATURE_P2P_DEBUG
651 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
652 {
653 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
654 {
655 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
656 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
657 "Connecting state to Connected State for 8-way "
658 "Handshake");
659 }
660 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
661 {
662 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
663 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
664 "Connecting state to P2P Client Connection Completed");
665 }
666 }
667#endif
Arif Hussain77d044f2014-01-03 19:56:04 -0800668 pr_info("wlan: " MAC_ADDRESS_STR " connected to " MAC_ADDRESS_STR "\n",
669 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
Kiet Lam34947452014-01-21 23:23:40 -0800670 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700671 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
672
673 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
674 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
675 * and fFTEnable is TRUE */
676#ifdef WLAN_FEATURE_VOWIFI_11R
677 // Send FT Keys to the supplicant when FT is enabled
678 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700679 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800680#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700681 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
682 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
683#endif
684 )
685 {
686 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
687 }
688#endif
689 }
690 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
691 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530692 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -0700693 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700694 type = WLAN_STA_ASSOC_DONE_IND;
Arif Hussain24bafea2013-11-15 15:10:03 -0800695 pr_info("wlan: new IBSS connection to " MAC_ADDRESS_STR"\n",
696 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 }
698 else /* Not Associated */
699 {
700 pr_info("wlan: disconnected\n");
701 type = WLAN_STA_DISASSOC_DONE_IND;
702 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
703 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700704 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700705
706 msg = NULL;
707 /*During the WLAN uninitialization,supplicant is stopped before the
708 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530709 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700710 {
711 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800712#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700713 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700714 {
715 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
716 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700717 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
718 }
719#endif
720 }
721 send_btc_nlink_msg(type, 0);
722}
723
724void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
725{
726 // Remove staId, bssId and peerMacAddress
727 pHddStaCtx->conn_info.staId [ 0 ] = 0;
728 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
729 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
730
731 // Clear all security settings
732 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
733 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
734 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
735
736 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700737 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700738
739 // Set not-connected state
740 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -0700741
742 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
743}
744/* TODO Revist this function. and data path */
745static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
746{
747 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700748 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
749
750 if (WLAN_HDD_IBSS != pAdapter->device_mode)
751 {
752 hdd_disconnect_tx_rx(pAdapter);
753 }
754 else
755 {
756 // Need to cleanup all queues only if the last peer leaves
757 if (eConnectionState_IbssDisconnected == pHddStaCtx->conn_info.connState)
758 {
759 netif_tx_disable(pAdapter->dev);
760 netif_carrier_off(pAdapter->dev);
761 hdd_disconnect_tx_rx(pAdapter);
762 }
763 else
764 {
765 // There is atleast one more peer, do not cleanup all queues
766 hdd_flush_ibss_tx_queues(pAdapter, staId);
767 }
768 }
769
Jeff Johnson295189b2012-06-20 16:38:30 -0700770 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
771 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
772 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530773 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700774 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700775 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700776 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700777 }
778 return( vosStatus );
779}
780
781
782static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
783 tANI_U32 roamId, eRoamCmdStatus roamStatus,
784 eCsrRoamResult roamResult )
785{
786 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700787 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 struct net_device *dev = pAdapter->dev;
789 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
790 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700791 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530792 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700793
794 // Sanity check
795 if(dev == NULL)
796 {
Agarwal Ashish971c2882013-10-30 20:11:12 +0530797 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700798 "%s: net_dev is released return", __func__);
799 return eHAL_STATUS_FAILURE;
800 }
801
Jeff Johnson295189b2012-06-20 16:38:30 -0700802 // notify apps that we can't pass traffic anymore
803 netif_tx_disable(dev);
804 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700805
Jeff Johnsone7245742012-09-05 17:12:55 -0700806 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530807 /* HDD has initiated disconnect, do not send disconnect indication
808 * to kernel as it will be handled by __cfg80211_disconnect.
809 */
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530810 /* If only STA mode is on */
811 if((pHddCtx->concurrency_mode <= 1) &&
812 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
813 {
814 pHddCtx->isAmpAllowed = VOS_TRUE;
815 }
816
Agarwal Ashish47d18112014-08-04 19:55:07 +0530817 /* Need to apply spin lock before decreasing active sessions
818 * as there can be chance for double decrement if context switch
819 * Calls wlan_hdd_disconnect.
820 */
821
822 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530823 if ( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState )
824 {
825 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
826 FL(" HDD has initiated a disconnect, no need to send"
827 " disconnect indication to kernel"));
828 sendDisconInd = FALSE;
829 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530830 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700831 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530832 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +0530833 FL(" Set HDD connState to eConnectionState_Disconnecting from %d "),
834 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530835 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
836 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 }
Agarwal Ashish47d18112014-08-04 19:55:07 +0530838 spin_unlock_bh(&pAdapter->lock_for_active_session);
839
Jeff Johnson295189b2012-06-20 16:38:30 -0700840 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -0700841
842 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -0700843
844 // indicate 'disconnect' status to wpa_supplicant...
845 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700846 /* indicate disconnected event to nl80211 */
847 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
848 {
849 /*During the WLAN uninitialization,supplicant is stopped before the
850 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530851 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700852 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700853 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
854 "%s: sent disconnected event to nl80211",
Jeff Johnson295189b2012-06-20 16:38:30 -0700855 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700856#ifdef WLAN_FEATURE_P2P_DEBUG
857 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
858 {
859 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
860 {
861 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
862 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
863 "and moved to disconnected state");
864 }
865 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
866 {
867 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
868 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
869 "and moved to inactive state");
870 }
871 }
872#endif
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530873 /*Only send indication to kernel if not initiated by kernel*/
874 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530876 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
877 if ( eCSR_ROAM_LOSTLINK == roamStatus )
878 {
879 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
880 }
881 else
882 {
883 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
884 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700885 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700886 //If the Device Mode is Station
887 // and the P2P Client is Connected
888 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -0700889
890 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -0700891 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -0700892 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 {
894 //Enable BMPS only of other Session is P2P Client
895 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700896 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -0700897
898 if (NULL != pVosContext)
899 {
900 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
901
902 if(NULL != pHddCtx)
903 {
904 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +0530905 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
906 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700907 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530908 if (pHddCtx->hdd_wlan_suspended)
909 {
910 hdd_set_pwrparams(pHddCtx);
911 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700912 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530913 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 }
915 }
916 }
917 }
918 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700919
krunal soni3fc26642013-10-08 22:41:42 -0700920 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
921 {
922 sta_id = IBSS_BROADCAST_STAID;
923 }
924 else
925 {
926 sta_id = pHddStaCtx->conn_info.staId[0];
927 }
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +0530928 hdd_wmm_adapter_clear(pAdapter);
Mukul Sharmac159c432014-01-15 15:42:46 +0530929#if defined(WLAN_FEATURE_VOWIFI_11R)
930 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
931#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 //We should clear all sta register with TL, for now, only one.
krunal soni3fc26642013-10-08 22:41:42 -0700933 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
Jeff Johnson43971f52012-07-17 12:26:56 -0700934 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700935 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530936 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700937 "hdd_roamDeregisterSTA() failed to for staID %d. "
938 "Status= %d [0x%x]",
krunal soni3fc26642013-10-08 22:41:42 -0700939 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700940
941 status = eHAL_STATUS_FAILURE;
942 }
943
krunal soni3fc26642013-10-08 22:41:42 -0700944 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700945 // Clear saved connection information in HDD
946 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhf4669da2014-05-26 15:07:49 +0530947 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
948 "%s: Set HDD connState to eConnectionState_NotConnected",
949 __func__);
950 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530951#ifdef WLAN_FEATURE_GTK_OFFLOAD
952 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
953 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
954 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +0530955 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
956 sizeof (tSirGtkOffloadParams));
957 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530958 }
959#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700960
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800961#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -0700962 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
963 {
964 wlan_hdd_tdls_disconnection_callback(pAdapter);
965 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800966#endif
967
Jeff Johnson295189b2012-06-20 16:38:30 -0700968 //Unblock anyone waiting for disconnect to complete
969 complete(&pAdapter->disconnect_comp_var);
970 return( status );
971}
972static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
973 tCsrRoamInfo *pRoamInfo,
974 v_U8_t staId,
975 v_MACADDR_t *pPeerMacAddress,
976 tSirBssDescription *pBssDesc )
977{
978 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
979 WLAN_STADescType staDesc = {0};
980 eCsrEncryptionType connectedCipherAlgo;
981 v_BOOL_t fConnected;
982 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
983 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -0700984 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700985
986 if ( NULL == pBssDesc)
987 {
988 return VOS_STATUS_E_FAILURE;
989 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 // Get the Station ID from the one saved during the assocation.
991 staDesc.ucSTAId = staId;
992
993 if ( pHddStaCtx->conn_info.connDot11DesiredBssType == eMib_dot11DesiredBssType_infrastructure)
Jeff Johnson295189b2012-06-20 16:38:30 -0700994 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700995 staDesc.wSTAType = WLAN_STA_INFRA;
996
997 // grab the bssid from the connection info in the adapter structure and hand that
998 // over to TL when registering.
999 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) );
1000 }
1001 else
1002 {
1003 // for an IBSS 'connect', setup the Station Descriptor for TL.
Jeff Johnson295189b2012-06-20 16:38:30 -07001004 staDesc.wSTAType = WLAN_STA_IBSS;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001005
Jeff Johnson295189b2012-06-20 16:38:30 -07001006 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
1007 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
1008 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
1009 // pass when making an Infrastructure connection.
1010 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) );
1011 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
1012 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001013
Jeff Johnson295189b2012-06-20 16:38:30 -07001014 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1015
1016 // set the QoS field appropriately
1017 if (hdd_wmm_is_active(pAdapter))
1018 {
1019 staDesc.ucQosEnabled = 1;
1020 }
1021 else
1022 {
1023 staDesc.ucQosEnabled = 0;
1024 }
1025
1026 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1027 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1028 {
1029 staDesc.ucProtectedFrame = 1;
1030 }
1031 else
1032 {
1033 staDesc.ucProtectedFrame = 0;
1034
1035 }
1036
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001037#ifdef FEATURE_WLAN_ESE
1038 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
1039#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001040
1041#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1042 /* check whether replay check is valid for the station or not */
1043 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
1044 {
1045 /* Encryption mode is either TKIP or AES
1046 and replay check is valid for only these
1047 two encryption modes */
1048 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1049 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1050 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1051 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001052
Jeff Johnson295189b2012-06-20 16:38:30 -07001053 else
1054 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001055 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001057 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001058 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1059 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1060 }
1061#endif
1062
1063#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001064 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001065 if (pAdapter->wapi_info.fIsWapiSta)
1066 {
1067 staDesc.ucIsWapiSta = 1;
1068 }
1069 else
1070 {
1071 staDesc.ucIsWapiSta = 0;
1072 }
1073#endif /* FEATURE_WLAN_WAPI */
1074
1075 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1076 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1077
Jeff Johnson295189b2012-06-20 16:38:30 -07001078 // UMA is Not ready yet, Xlation will be done by TL
1079 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 staDesc.ucSwFrameRXXlation = 1;
1081 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001082 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001083 staDesc.ucQosEnabled );
1084 // Initialize signatures and state
1085 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1086 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1087 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1088 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001089 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001090 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 -07001091 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1092 hdd_rx_packet_cbk,
1093 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001094 hdd_tx_fetch_packet_cbk, &staDesc,
1095 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001096
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1098 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001099 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001100 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001101 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001102 return vosStatus;
1103 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001104
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001105 if ( cfg_param->dynSplitscan &&
1106 ( VOS_TIMER_STATE_RUNNING !=
1107 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1108 {
1109 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1110 cfg_param->trafficMntrTmrForSplitScan);
1111 }
1112
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301113 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1114 // then go to 'authenticated'. For all other authentication types
1115 // (those that donot require upper layer authentication) we can put
1116 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001117 if (staDesc.wSTAType != WLAN_STA_IBSS)
1118 VOS_ASSERT( fConnected );
1119
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301120 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001121 {
1122 // Connections that do not need Upper layer auth, transition TL directly
1123 // to 'Authenticated' state.
1124 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1125 WLANTL_STA_AUTHENTICATED );
1126
1127 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1128 }
1129 else
1130 {
1131 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301132 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1133 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001134 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301135 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001136 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1137 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001138 return( vosStatus );
1139}
1140
Jeff Johnson295189b2012-06-20 16:38:30 -07001141static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1142 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1143{
1144 unsigned int len = 0;
1145 u8 *pFTAssocRsp = NULL;
Agarwal Ashish51325b52014-06-16 16:50:49 +05301146 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001147 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001148 tANI_U32 rspRsnLength = 0;
1149 struct ieee80211_channel *chan;
1150
Agarwal Ashish51325b52014-06-16 16:50:49 +05301151 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001152 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001153 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001154 }
1155
Agarwal Ashish51325b52014-06-16 16:50:49 +05301156 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001157 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1158 goto done;
1159 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001160
Agarwal Ashish51325b52014-06-16 16:50:49 +05301161 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001162 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1163 goto done;
1164 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001165
1166 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1167 pCsrRoamInfo->nAssocReqLength);
1168 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001169 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001170
1171 //pFTAssocRsp needs to point to the IEs
1172 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001173 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001174 (unsigned int)pFTAssocRsp[0],
1175 (unsigned int)pFTAssocRsp[1]);
1176
Agarwal Ashish51325b52014-06-16 16:50:49 +05301177 /* Active session count is decremented upon disconnection, but during
1178 * roaming, there is no disconnect indication and hence active session
1179 * count is not decremented.
1180 * After roaming is completed, active session count is incremented
1181 * as a part of connect indication but effectively after roaming the
1182 * active session count should still be the same and hence upon
1183 * successful reassoc decrement the active session count here */
1184
1185 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
1186
Jeff Johnson295189b2012-06-20 16:38:30 -07001187 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001188 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001189 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001190 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001191 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001192
1193 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1194 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1195 reqRsnIe, reqRsnLength,
1196 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001197
1198done:
1199 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001200}
Jeff Johnson295189b2012-06-20 16:38:30 -07001201
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301202void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1203{
1204 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1205 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1206 tCsrRoamInfo roamInfo;
1207 roamInfo.fAuthRequired = FALSE;
1208 vos_mem_copy(roamInfo.bssid,
1209 pHddStaCtx->roam_info.bssid,
1210 WNI_CFG_BSSID_LEN);
1211 vos_mem_copy(roamInfo.peerMac,
1212 pHddStaCtx->roam_info.peerMac,
1213 WNI_CFG_BSSID_LEN);
1214
1215 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1216 &roamInfo,
1217 pHddStaCtx->roam_info.roamId,
1218 pHddStaCtx->roam_info.roamStatus,
1219 eCSR_ROAM_RESULT_AUTHENTICATED);
1220 if (halStatus != eHAL_STATUS_SUCCESS)
1221 {
1222 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1223 }
1224 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1225}
1226
Shailender Karmuchia734f332013-04-19 14:02:48 -07001227static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1228 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 eCsrRoamResult roamResult )
1230{
1231 struct net_device *dev = pAdapter->dev;
1232 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1233 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301234 hdd_adapter_t *pHostapdAdapter = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001236 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1237 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001238#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001239 int ft_carrier_on = FALSE;
1240#endif
1241 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301242 v_BOOL_t hddDisconInProgress = FALSE;
1243
1244 /* HDD has initiated disconnect, do not send connect result indication
1245 * to kernel as it will be handled by __cfg80211_disconnect.
1246 */
1247 if(( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) &&
1248 (( eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
1249 ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)) )
1250 {
1251 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1252 FL(" Disconnect from HDD in progress "));
1253 hddDisconInProgress = TRUE;
1254 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001255
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1257 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301258 if ( !hddDisconInProgress )
1259 {
1260 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05301261 "%s: Set HDD connState to eConnectionState_Associated",
1262 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301263 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1264 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001265
c_hpothu44ff4e02014-05-08 00:13:57 +05301266 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001267 // Save the connection info from CSR...
1268 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1269#ifdef FEATURE_WLAN_WAPI
1270 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1271 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1272 {
1273 pAdapter->wapi_info.fIsWapiSta = 1;
1274 }
1275 else
1276 {
1277 pAdapter->wapi_info.fIsWapiSta = 0;
1278 }
1279#endif /* FEATURE_WLAN_WAPI */
1280
1281 // indicate 'connect' status to userspace
1282 hdd_SendAssociationEvent(dev,pRoamInfo);
1283
1284
Shailender Karmuchia734f332013-04-19 14:02:48 -07001285 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001286 INIT_COMPLETION(pAdapter->linkup_event_var);
1287
1288 /*
1289 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1290 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 -07001291 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001292 know that the device is getting activated properly.
1293 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001294#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001295 if (pHddStaCtx->ft_carrier_on == FALSE)
1296 {
1297#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001298 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001299 pAdapter->isLinkUpSvcNeeded = TRUE;
1300
Shailender Karmuchia734f332013-04-19 14:02:48 -07001301 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001302 pAdapter->isLinkUpSvcNeeded = TRUE;
1303
1304 // Switch on the Carrier to activate the device
1305 netif_carrier_on(dev);
1306
1307 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1308 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1309 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001310 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001311 {
1312 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1313 }
1314
1315 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1316 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001317#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001318 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001319 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001320 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001321 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001322 }
1323#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05301324 /* Check for STAID */
1325 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
1326 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1327 else
1328 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001329
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001330#ifdef FEATURE_WLAN_TDLS
1331 wlan_hdd_tdls_connection_callback(pAdapter);
1332#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001333 //For reassoc, the station is already registered, all we need is to change the state
1334 //of the STA in TL.
1335 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
1336 if( !pRoamInfo->fReassocReq )
1337 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001338 struct cfg80211_bss *bss;
1339#ifdef WLAN_FEATURE_VOWIFI_11R
1340 u8 *pFTAssocRsp = NULL;
1341 unsigned int assocRsplen = 0;
1342 u8 *pFTAssocReq = NULL;
1343 unsigned int assocReqlen = 0;
1344 struct ieee80211_channel *chan;
1345#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001346 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001347 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001348
1349 /* add bss_id to cfg80211 data base */
1350 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1351 if (NULL == bss)
1352 {
1353 pr_err("wlan: Not able to create BSS entry\n");
1354 return eHAL_STATUS_FAILURE;
1355 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001356#ifdef WLAN_FEATURE_VOWIFI_11R
1357 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001358 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001360
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001361 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001362 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001363 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001364 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001365 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001366 // pFTAssocRsp needs to point to the IEs
1367 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1368 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1369 (unsigned int)pFTAssocRsp[0],
1370 (unsigned int)pFTAssocRsp[1]);
1371 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001372 }
1373 else
1374 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001375 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1376 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001377 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001378
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001379 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001380 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001381 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001382 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001383 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001384 if(!ft_carrier_on)
1385 {
1386 // pFTAssocReq needs to point to the IEs
1387 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1388 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1389 (unsigned int)pFTAssocReq[0],
1390 (unsigned int)pFTAssocReq[1]);
1391 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1392 }
1393 else
1394 {
1395 /* This should contain only the FTIEs */
1396 assocReqlen = pRoamInfo->nAssocReqLength;
1397 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001398 }
1399 else
1400 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001401 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1402 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001403 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001404
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001405 if(ft_carrier_on)
1406 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301407 if ( !hddDisconInProgress )
1408 {
1409 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001410 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301411 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001412 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301413 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001414 assocRsplen);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301415 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001416 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1417 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301418 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301419 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1420 {
1421 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1422 pRoamInfo->fAuthRequired = FALSE;
1423
1424 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1425 pRoamInfo->bssid,
1426 HDD_MAC_ADDR_LEN);
1427 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1428 pRoamInfo->peerMac,
1429 HDD_MAC_ADDR_LEN);
1430 pHddStaCtx->roam_info.roamId = roamId;
1431 pHddStaCtx->roam_info.roamStatus = roamStatus;
1432 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1433 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001434 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301435 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001436 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001437 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001438 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001439 cfg80211_connect_result(dev, pRoamInfo->bssid,
1440 pFTAssocReq, assocReqlen,
1441 pFTAssocRsp, assocRsplen,
1442 WLAN_STATUS_SUCCESS,
1443 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001444 }
1445 }
1446 else
1447#endif
1448 {
1449 /* wpa supplicant expecting WPA/RSN IE in connect result */
1450 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1451 pAdapter->sessionId,
1452 &reqRsnLength,
1453 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001454
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001455 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1456 pAdapter->sessionId,
1457 &rspRsnLength,
1458 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301459 if ( !hddDisconInProgress )
1460 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001461#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301462 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05301463 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301464 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Mukul Sharma84f27252014-07-14 18:11:42 +05301465#ifdef DEBUG_ROAM_DELAY
1466 //HACK we are using the buff len as Auth Type
1467 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1468#endif
1469 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301470 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001471#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001472
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301473 {
1474 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301475 "%s: sending connect indication to nl80211:"
1476 " for bssid " MAC_ADDRESS_STR
1477 " reason:%d and Status:%d\n",
1478 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1479 roamResult, roamStatus);
1480
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301481 /* inform connect result to nl80211 */
1482 cfg80211_connect_result(dev, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001483 reqRsnIe, reqRsnLength,
1484 rspRsnIe, rspRsnLength,
1485 WLAN_STATUS_SUCCESS,
1486 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301487 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001488 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001489 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301490 if ( !hddDisconInProgress )
1491 {
1492 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07001493#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301494 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07001495#endif
1496 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301497 // Register the Station with TL after associated...
1498 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001499 pRoamInfo,
1500 pHddStaCtx->conn_info.staId[ 0 ],
1501 NULL,
1502 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301503 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001504 }
1505 else
1506 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001507 /* wpa supplicant expecting WPA/RSN IE in connect result */
1508 /* in case of reassociation also need to indicate it to supplicant */
1509 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1510 pAdapter->sessionId,
1511 &reqRsnLength,
1512 reqRsnIe);
1513
1514 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001515 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301516 if( pRoamInfo->fAuthRequired )
1517 {
1518 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1519 pHddStaCtx->conn_info.staId[ 0 ],
1520 WLANTL_STA_CONNECTED );
1521 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1522 }
1523 else
1524 {
1525 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1526 "%s: staId: %d Changing TL state to AUTHENTICATED",
1527 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1528 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1529 pHddStaCtx->conn_info.staId[ 0 ],
1530 WLANTL_STA_AUTHENTICATED );
1531 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1532 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001533 }
1534
1535 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1536 {
1537 // perform any WMM-related association processing
1538 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1539 }
1540 else
1541 {
1542 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001543 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 vosStatus, vosStatus );
1545 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001546#ifdef WLAN_FEATURE_11W
1547 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1548 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1549#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001550 // Start the Queue
1551 netif_tx_wake_all_queues(dev);
Mukul Sharma84f27252014-07-14 18:11:42 +05301552#ifdef DEBUG_ROAM_DELAY
1553 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
1554#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001555 }
1556 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001557 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001558 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1559
1560 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001561 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001562 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1563 " reason:%d and Status:%d\n",
1564 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1565 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001566 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001567 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1568 " reason:%d and Status:%d\n",
1569 MAC_ADDR_ARRAY(pWextState->req_bssId),
1570 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001571
Abhishek Singhf4669da2014-05-26 15:07:49 +05301572 /* Set connection state to eConnectionState_NotConnected only when CSR
1573 * has completed operation - with a ASSOCIATION_FAILURE status
1574 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301575 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05301576 {
1577 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1578 "%s: Set HDD connState to eConnectionState_NotConnected",
1579 __func__);
1580 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1581 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05301582 if((pHddCtx->concurrency_mode <= 1) &&
1583 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07001584 {
1585 pHddCtx->isAmpAllowed = VOS_TRUE;
1586 }
1587
1588 //If the Device Mode is Station
1589 // and the P2P Client is Connected
1590 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001591
1592 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001593 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001594 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1595 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05301596 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07001597 {
1598 //Enable BMPS only of other Session is P2P Client
1599 hdd_context_t *pHddCtx = NULL;
1600 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1601
1602 if (NULL != pVosContext)
1603 {
1604 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1605
1606 if(NULL != pHddCtx)
1607 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301608 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301609 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1610 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301611 {
1612 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001613 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301614 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001615 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301616 hdd_enable_bmps_imps(pHddCtx);
1617 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 }
1619 }
1620 }
1621
James Zmudafbf5ffc2013-03-25 12:45:35 -07001622 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001623 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301624 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07001625 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301626 if (pRoamInfo)
1627 hddLog(VOS_TRACE_LEVEL_ERROR,
1628 "%s: send connect failure to nl80211:"
1629 " for bssid " MAC_ADDRESS_STR
1630 " reason:%d and Status:%d\n" ,
1631 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1632 roamResult, roamStatus);
1633 else
1634 hddLog(VOS_TRACE_LEVEL_ERROR,
1635 "%s: connect failed:"
1636 " for bssid " MAC_ADDRESS_STR
1637 " reason:%d and Status:%d\n" ,
1638 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
1639 roamResult, roamStatus);
1640
c_hpothudaa90e22014-06-24 17:23:43 +05301641 /*Clear the roam profile*/
1642 hdd_clearRoamProfileIe( pAdapter );
1643
James Zmudafbf5ffc2013-03-25 12:45:35 -07001644 /* inform association failure event to nl80211 */
1645 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1646 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001647 if (pRoamInfo)
1648 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1649 NULL, 0, NULL, 0,
1650 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1651 GFP_KERNEL );
1652 else
1653 cfg80211_connect_result ( dev, pWextState->req_bssId,
1654 NULL, 0, NULL, 0,
1655 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1656 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001657 }
1658 else
1659 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001660 if (pRoamInfo)
1661 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1662 NULL, 0, NULL, 0,
1663 WLAN_STATUS_UNSPECIFIED_FAILURE,
1664 GFP_KERNEL );
1665 else
1666 cfg80211_connect_result ( dev, pWextState->req_bssId,
1667 NULL, 0, NULL, 0,
1668 WLAN_STATUS_UNSPECIFIED_FAILURE,
1669 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001670 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001671 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001672
Kumar Anand82c009f2014-05-29 00:29:42 -07001673 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001674
c_hpothu24f40982014-04-18 18:00:36 +05301675 if (pRoamInfo)
1676 {
1677 WLANTL_AssocFailed(pRoamInfo->staId);
1678 }
Mihir Sheteb7337272014-04-11 15:53:08 +05301679
Jeff Johnson295189b2012-06-20 16:38:30 -07001680 netif_tx_disable(dev);
1681 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001682
Jeff Johnson295189b2012-06-20 16:38:30 -07001683 }
1684
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301685 if (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus ||
1686 eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
1687 {
1688 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
1689 if (pHostapdAdapter != NULL)
1690 {
1691 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap");
1692 hdd_restart_softap(pHddCtx, pHostapdAdapter);
1693 }
1694 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 return eHAL_STATUS_SUCCESS;
1696}
1697
1698/**============================================================================
1699 *
Jeff Johnson81c17882013-05-03 09:53:35 -07001700 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07001701 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07001702
Jeff Johnson295189b2012-06-20 16:38:30 -07001703 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07001704static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
1705 tCsrRoamInfo *pRoamInfo,
1706 tANI_U32 roamId,
1707 eRoamCmdStatus roamStatus,
1708 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07001709{
Jeff Johnson81c17882013-05-03 09:53:35 -07001710 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
1711 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
1712
Jeff Johnson295189b2012-06-20 16:38:30 -07001713 switch( roamResult )
1714 {
1715 // both IBSS Started and IBSS Join should come in here.
1716 case eCSR_ROAM_RESULT_IBSS_STARTED:
1717 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001718 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07001719 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001720 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1721 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001722
Jeff Johnson81c17882013-05-03 09:53:35 -07001723 if (NULL == pRoamInfo)
1724 {
1725 VOS_ASSERT(0);
1726 return;
1727 }
1728
1729 /* When IBSS Started comes from CSR, we need to move
1730 * connection state to IBSS Disconnected (meaning no peers
1731 * are in the IBSS).
1732 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05301733 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1734 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
1735 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07001736 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
1737 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05301738 /*notify wmm */
1739 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001740 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1741 hdd_roamRegisterSTA (pAdapter, pRoamInfo,
1742 IBSS_BROADCAST_STAID,
1743 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001744
Jeff Johnson81c17882013-05-03 09:53:35 -07001745 if (pRoamInfo->pBssDesc)
1746 {
1747 struct cfg80211_bss *bss;
1748
1749 /* we created the IBSS, notify supplicant */
1750 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
1751 MAC_ADDRESS_STR,
1752 __func__, pAdapter->dev->name,
1753 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
1754
1755 /* we must first give cfg80211 the BSS information */
1756 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1757 if (NULL == bss)
1758 {
1759 hddLog(VOS_TRACE_LEVEL_ERROR,
1760 "%s: %s: unable to create IBSS entry",
1761 __func__, pAdapter->dev->name);
1762 return;
1763 }
1764
1765 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07001766 cfg80211_put_bss(
1767#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1768 pHddCtx->wiphy,
1769#endif
1770 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07001771 }
1772
Jeff Johnson295189b2012-06-20 16:38:30 -07001773 break;
1774 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001775
Jeff Johnson295189b2012-06-20 16:38:30 -07001776 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
1777 {
Jeff Johnson81c17882013-05-03 09:53:35 -07001778 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
1779 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07001780 break;
1781 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001782
Jeff Johnson295189b2012-06-20 16:38:30 -07001783 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07001784 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
1785 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001786 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001787 }
1788
Jeff Johnson81c17882013-05-03 09:53:35 -07001789 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001790}
1791
1792/**============================================================================
1793 *
1794 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
1795 This information is passed to iwconfig later. The peer that joined
1796 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001797 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001798 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001799
Jeff Johnson295189b2012-06-20 16:38:30 -07001800 ===========================================================================*/
1801static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
1802{
1803 int fSuccess = FALSE;
1804 int idx = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001805
Jeff Johnson295189b2012-06-20 16:38:30 -07001806 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1807 {
1808 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
1809 {
1810 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001811
Jeff Johnson295189b2012-06-20 16:38:30 -07001812 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001813
Jeff Johnson295189b2012-06-20 16:38:30 -07001814 fSuccess = TRUE;
1815 break;
1816 }
1817 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001818
1819 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07001820}
1821/**============================================================================
1822 *
1823 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001824 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001825 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001826
Jeff Johnson295189b2012-06-20 16:38:30 -07001827 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07001828static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07001829{
1830 int fSuccess = FALSE;
1831 int idx = 0;
1832 v_U8_t valid_idx = 0;
1833 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07001834 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001835 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001836
Jeff Johnson295189b2012-06-20 16:38:30 -07001837 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1838 {
1839 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
1840 {
1841 pHddStaCtx->conn_info.staId[ idx ] = 0;
1842
1843 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
1844
1845 fSuccess = TRUE;
Ravi Joshi8a934352013-09-25 16:46:58 -07001846
Jeff Johnson295189b2012-06-20 16:38:30 -07001847 // Note the deleted Index, if its 0 we need special handling
1848 del_idx = idx;
Ravi Joshi8a934352013-09-25 16:46:58 -07001849
1850 empty_slots++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001851 }
1852 else
1853 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001854 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001855 {
1856 valid_idx = idx;
1857 }
Ravi Joshi8a934352013-09-25 16:46:58 -07001858 else
1859 {
1860 // Found an empty slot
1861 empty_slots++;
1862 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001863 }
1864 }
1865
Ravi Joshi8a934352013-09-25 16:46:58 -07001866 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
1867 {
1868 // Last peer departed, set the IBSS state appropriately
1869 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001870 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07001871 "Last IBSS Peer Departed!!!" );
1872 }
1873
Jeff Johnson295189b2012-06-20 16:38:30 -07001874 // Find next active staId, to have a valid sta trigger for TL.
1875 if (fSuccess == TRUE)
1876 {
1877 if (del_idx == 0)
1878 {
1879 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
1880 {
1881 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
1882 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
1883 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
1884
1885 pHddStaCtx->conn_info.staId[valid_idx] = 0;
1886 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
1887 }
1888 }
1889 }
1890 return( fSuccess );
1891}
1892
1893/**============================================================================
1894 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001895 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07001896 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001897
Jeff Johnson295189b2012-06-20 16:38:30 -07001898 ===========================================================================*/
1899static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
1900{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001901 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05301902 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1903 "%s: IBSS Connect Indication from SME!!! "
1904 "Set HDD connState to eConnectionState_IbssConnected",
1905 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
1907 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
1908
1909 // Save the connection info from CSR...
1910 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
1911
1912 // Send the bssid address to the wext.
1913 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001914 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001915 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1916 if (NULL == bss)
1917 {
1918 hddLog(VOS_TRACE_LEVEL_ERROR,
1919 "%s: %s: unable to create IBSS entry",
1920 __func__, pAdapter->dev->name);
1921 return eHAL_STATUS_FAILURE;
1922 }
Yue Maf49ba872013-08-19 12:04:25 -07001923 cfg80211_put_bss(
1924#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1925 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
1926#endif
1927 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001928
1929 return( eHAL_STATUS_SUCCESS );
1930}
1931/**============================================================================
1932 *
Mukul Sharmad2589a52014-04-23 21:06:25 +05301933 @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
1934 suspend related data which was cleared during roaming in FWR.
1935
1936 ===========================================================================*/
1937static void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
1938{
1939 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
1940 hdd_adapter_t *pAdapter;
1941 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
1942 ENTER();
1943
1944 spin_lock(&pHddCtx->filter_lock);
1945 if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
1946 {
1947 pHddCtx->sus_res_mcastbcast_filter =
1948 pHddCtx->configuredMcastBcastFilter;
1949 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
1950 hddLog(VOS_TRACE_LEVEL_INFO, FL("offload: callback to associated"));
1951 hddLog(VOS_TRACE_LEVEL_INFO,
1952 FL("saving configuredMcastBcastFilter = %d"),
1953 pHddCtx->configuredMcastBcastFilter);
1954 hddLog(VOS_TRACE_LEVEL_INFO,
1955 FL("offload: calling hdd_conf_mcastbcast_filter"));
1956 }
1957 spin_unlock(&pHddCtx->filter_lock);
1958
1959 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
1960 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
1961 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
1962
1963 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
1964 //No need to configure GTK Offload from here because it might possible
1965 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
1966 //be handled as part of cfg80211_set_rekey_data processing.
1967 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
1968 {
1969 pAdapter = pAdapterNode->pAdapter;
1970 if( pAdapter &&
1971 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1972 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
1973 {
1974 if (pHddCtx->cfg_ini->fhostArpOffload)
1975 {
1976 //Configure ARPOFFLOAD
1977 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
1978 if (!VOS_IS_STATUS_SUCCESS(vstatus))
1979 {
1980 hddLog(VOS_TRACE_LEVEL_ERROR,
1981 FL("Failed to disable ARPOffload Feature %d"), vstatus);
1982 }
1983 }
1984#ifdef WLAN_NS_OFFLOAD
1985 //Configure NSOFFLOAD
1986 if (pHddCtx->cfg_ini->fhostNSOffload)
1987 {
1988 hdd_conf_ns_offload(pAdapter, TRUE);
1989 }
1990#endif
Mukul Sharma25e70c32014-05-22 12:50:24 +05301991#ifdef WLAN_FEATURE_PACKET_FILTERING
1992 /* During suspend, configure MC Addr list filter to the firmware
1993 * function takes care of checking necessary conditions before
1994 * configuring.
1995 */
1996 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
1997#endif
Mukul Sharmad2589a52014-04-23 21:06:25 +05301998 }
1999 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2000 pAdapterNode = pNext;
2001 }
2002 EXIT();
2003}
2004
2005/**============================================================================
2006 *
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002008
Jeff Johnson295189b2012-06-20 16:38:30 -07002009 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002010static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2011 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002012 eCsrRoamResult roamResult )
2013{
2014 eCsrEncryptionType connectedCipherAlgo;
2015 v_BOOL_t fConnected = FALSE;
2016 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2017 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2018 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2019 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07002020
2021 if (NULL == pRoamInfo)
2022 {
2023 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
2024 return eHAL_STATUS_FAILURE;
2025 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002026 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002027 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07002028 // not require upper layer authentication) we can put TL directly into 'authenticated'
2029 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002030 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2031 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
2032 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002033
Jeff Johnson295189b2012-06-20 16:38:30 -07002034 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2035 if( fConnected )
2036 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002037 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
2038 {
2039 v_U8_t staId;
2040
2041 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2042
2043 if ( 0 == memcmp( pRoamInfo->peerMac,
2044 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
2045 {
2046 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2047 IBSS_BROADCAST_STAID);
2048 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2049 }
2050 else
2051 {
2052 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
2053 (v_MACADDR_t*)pRoamInfo->peerMac,
2054 &staId);
2055 if ( VOS_STATUS_SUCCESS == vosStatus )
2056 {
2057 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2058 "WLAN TL STA Ptk Installed for STAID=%d", staId);
2059 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2060 staId);
2061 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2062 }
2063 }
2064 }
2065 else
2066 {
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302067 // TODO: Considering getting a state machine in HDD later.
2068 // This routine is invoked twice. 1)set PTK 2)set GTK.
2069 // The folloing if statement will be TRUE when setting GTK.
2070 // At this time we don't handle the state in detail.
2071 // Related CR: 174048 - TL not in authenticated state
2072 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
2073 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
2074 {
2075 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
2076 "for StaId= %d. Changing TL state to AUTHENTICATED",
2077 pHddStaCtx->conn_info.staId[ 0 ] );
2078
2079 // Connections that do not need Upper layer authentication,
2080 // transition TL to 'Authenticated' state after the keys are set.
2081 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2082 pHddStaCtx->conn_info.staId[ 0 ],
2083 WLANTL_STA_AUTHENTICATED );
2084
2085 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Mukul Sharmad2589a52014-04-23 21:06:25 +05302086 //Need to call offload because when roaming happen at that time fwr
2087 //clean offload info as part of the DelBss
2088 // No need to configure offload if host was not suspended
2089 spin_lock(&pHddCtx->filter_lock);
2090 if(pHddCtx->hdd_wlan_suspended)
2091 {
2092 spin_unlock(&pHddCtx->filter_lock);
2093 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
2094 }
2095 else
2096 {
2097 spin_unlock(&pHddCtx->filter_lock);
2098 }
Mukul Sharma84f27252014-07-14 18:11:42 +05302099#ifdef DEBUG_ROAM_DELAY
2100 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
2101#endif
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302102 }
2103 else
2104 {
2105 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2106 pHddStaCtx->conn_info.staId[ 0 ]);
Mukul Sharma84f27252014-07-14 18:11:42 +05302107#ifdef DEBUG_ROAM_DELAY
2108 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
2109#endif
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302110 }
2111
2112 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002113 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002114 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302115 else
2116 {
2117 // possible disassoc after issuing set key and waiting set key complete
2118 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2119 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002120
Jeff Johnson295189b2012-06-20 16:38:30 -07002121 EXIT();
2122 return( eHAL_STATUS_SUCCESS );
2123}
2124/**============================================================================
2125 *
2126 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2127 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002128static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002129 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002130{
Jeff Johnson295189b2012-06-20 16:38:30 -07002131 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2132
2133 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2134 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2135 {
2136 struct iw_michaelmicfailure msg;
2137 union iwreq_data wreq;
2138 memset(&msg, '\0', sizeof(msg));
2139 msg.src_addr.sa_family = ARPHRD_ETHER;
2140 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002141 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2142 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002143
Jeff Johnson295189b2012-06-20 16:38:30 -07002144 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2145 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002146 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002147 msg.flags = IW_MICFAILURE_PAIRWISE;
2148 memset(&wreq, 0, sizeof(wreq));
2149 wreq.data.length = sizeof(msg);
2150 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002151 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002152 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002153 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2154 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2155 NL80211_KEYTYPE_GROUP :
2156 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002157 pRoamInfo->u.pMICFailureInfo->keyId,
2158 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002159 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002160
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002162
Jeff Johnson295189b2012-06-20 16:38:30 -07002163 return( eHAL_STATUS_SUCCESS );
2164}
2165
2166/**============================================================================
2167 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002168 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002169 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002170
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002172static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2173 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002174 eCsrRoamResult roamResult )
2175{
2176 VOS_STATUS vosStatus;
2177
2178 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2179 switch( roamResult )
2180 {
2181 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2182 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002183 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002184 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002185
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002186 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002187 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2188 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2189 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002190 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002191
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
2193 {
2194 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2195 "New IBSS peer but we already have the max we can handle. Can't register this one" );
2196 break;
2197 }
2198
2199 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2200
Shailender Karmuchia734f332013-04-19 14:02:48 -07002201 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2202 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2203 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2204
2205 // Register the Station with TL for the new peer.
Jeff Johnson295189b2012-06-20 16:38:30 -07002206 vosStatus = hdd_roamRegisterSTA( pAdapter,
2207 pRoamInfo,
2208 pRoamInfo->staId,
2209 (v_MACADDR_t *)pRoamInfo->peerMac,
2210 pRoamInfo->pBssDesc );
2211 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2212 {
2213 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002214 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002215 vosStatus, vosStatus );
2216 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002217 pHddStaCtx->ibss_sta_generation++;
2218 memset(&staInfo, 0, sizeof(staInfo));
2219 staInfo.filled = 0;
2220 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2221
2222 cfg80211_new_sta(pAdapter->dev,
2223 (const u8 *)pRoamInfo->peerMac,
2224 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002225
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002226 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2227 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2228 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2229 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2230 {
2231 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2232 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2233 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2234
2235 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002236 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002237 pHddStaCtx->ibss_enc_key.encType);
2238
2239 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2240 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2241
2242 if ( VOS_STATUS_SUCCESS != vosStatus )
2243 {
2244 hddLog(VOS_TRACE_LEVEL_ERROR,
2245 "%s: sme_RoamSetKey failed, returned %d",
2246 __func__, vosStatus);
2247 return VOS_STATUS_E_FAILURE;
2248 }
2249 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002250 netif_carrier_on(pAdapter->dev);
2251 netif_tx_start_all_queues(pAdapter->dev);
2252 break;
2253 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002254
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2256 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002257
Jeff Johnson295189b2012-06-20 16:38:30 -07002258 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002259
Jeff Johnson295189b2012-06-20 16:38:30 -07002260 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002261 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002262 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2263 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002264 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002265
Ravi Joshicc57ed42013-10-12 16:31:25 -07002266 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002267 {
2268 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2269 "IBSS peer departed by cannot find peer in our registration table with TL" );
2270 }
2271
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002272 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002273 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2274 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2275 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2276 pRoamInfo->staId );
2277
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
2279
2280 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002281 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002282
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002283 cfg80211_del_sta(pAdapter->dev,
2284 (const u8 *)&pRoamInfo->peerMac,
2285 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002286 break;
2287 }
2288 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2289 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002290 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2291 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002292 // Stop only when we are inactive
2293 netif_tx_disable(pAdapter->dev);
2294 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05302295 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2296 "%s: Set HDD connState to eConnectionState_NotConnected",
2297 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002299
Jeff Johnson295189b2012-06-20 16:38:30 -07002300 // Send the bssid address to the wext.
2301 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2302 // clean up data path
2303 hdd_disconnect_tx_rx(pAdapter);
2304 break;
2305 }
2306 default:
2307 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002308
Jeff Johnson295189b2012-06-20 16:38:30 -07002309 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002310
Jeff Johnson295189b2012-06-20 16:38:30 -07002311 return( eHAL_STATUS_SUCCESS );
2312}
2313
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002314#ifdef FEATURE_WLAN_TDLS
2315/**============================================================================
2316 *
2317 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2318 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2319 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002320
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002321 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002322VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
2323 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002324{
2325 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002326 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002327 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2328 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002329 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2330 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002331 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2332 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002333
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002334 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2335 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002336 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002337 "%s not connected. ignored", __func__);
2338 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002339 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002340
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002341 /*
2342 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2343 * be peer MAC, here we are wokrking on direct Link
2344 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002345 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002346
2347 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002348
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002349 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002350 sizeof(tSirMacAddr) );
2351
2352 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2353 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2354
2355 /* set the QoS field appropriately ..*/
2356 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2357 : (staDesc.ucQosEnabled = 0) ;
2358
2359 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002360 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002361
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002362 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002363
2364 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002365 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002366
Shailender Karmuchia734f332013-04-19 14:02:48 -07002367 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002368 * UMA is ready we inform TL to do frame translation.
2369 */
2370 staDesc.ucSwFrameTXXlation = 1;
2371 staDesc.ucSwFrameRXXlation = 1;
2372 staDesc.ucAddRmvLLC = 1;
2373
2374 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002375 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002376
2377 /* tdls Direct Link do not need bcastSig */
2378 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002379
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002380#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2381 if(staDesc.ucProtectedFrame)
2382 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2383 else
2384 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2385#endif
2386
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302387 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002388
Shailender Karmuchia734f332013-04-19 14:02:48 -07002389 /* Register the Station with TL... */
2390 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2391 hdd_rx_packet_cbk,
2392 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002393 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002394
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002395 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2396 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002397 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002398 "%s: WLANTL_RegisterSTAClient() failed to register. "
2399 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002400 return vosStatus;
2401 }
2402
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002403 if ( cfg_param->dynSplitscan &&
2404 ( VOS_TIMER_STATE_RUNNING !=
2405 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2406 {
2407 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2408 cfg_param->trafficMntrTmrForSplitScan);
2409 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002410 return( vosStatus );
2411}
2412
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002413static VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
2414{
2415 VOS_STATUS vosStatus;
2416 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2417 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2418 {
2419 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2420 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002421 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002422 __func__, staId, vosStatus, vosStatus );
2423 }
2424 return( vosStatus );
2425}
2426
2427
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002428/*
2429 * HDD interface between SME and TL to ensure TDLS client registration with
2430 * TL in case of new TDLS client is added and deregistration at the time
2431 * TDLS client is deleted.
2432 */
2433
Shailender Karmuchia734f332013-04-19 14:02:48 -07002434eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2435 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002436 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002437 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002438 eCsrRoamResult roamResult)
2439{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002440 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002441 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002442 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002443
2444#ifdef WLAN_FEATURE_TDLS_DEBUG
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302445 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002446 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2447 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2448 "ADD_TDLS_PEER" :
2449 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2450 "DEL_TDLS_PEER" :
2451 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2452 "DEL_TDLS_PEER_IND" :
2453 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2454 "DEL_ALL_TDLS_PEER_IND" :
2455 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2456 "UPDATE_TDLS_PEER" :
2457 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2458 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2459 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002460#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002461 switch( roamResult )
2462 {
2463 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2464 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002465 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2466 {
2467 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002468 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002469 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002470 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002471 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002472
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002473 /* check if there is available index for this new TDLS STA */
2474 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2475 {
2476 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2477 {
2478 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2479 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2480
2481 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002482 ("TDLS: STA IDX at %d is %d "
2483 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002484 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002485 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002486
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002487 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002488 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2489 status = eHAL_STATUS_SUCCESS ;
2490 break ;
2491 }
2492 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002493 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002494 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002495 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002496 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2497 "wlan_hdd_tdls_set_sta_id() failed");
2498 return VOS_FALSE;
2499 }
2500
2501 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302502 /* store the ucast signature , if required for further reference. */
2503
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002504 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302505 /* start TDLS client registration with TL */
2506 status = hdd_roamRegisterTDLSSTA( pAdapter,
2507 pRoamInfo->peerMac,
2508 pRoamInfo->staId,
2509 pRoamInfo->ucastSig);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002510 }
2511 else
2512 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002513 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002514 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002515 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002516 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002517 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002518 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002519 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002520 break ;
2521 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002522 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
2523 {
2524 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2525 {
2526 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2527 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
2528 }
2529 /* store the ucast signature which will be used later when
2530 * registering to TL
2531 */
2532 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
2533 complete(&pAdapter->tdls_add_station_comp);
2534 break;
2535 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302536 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
2537 {
2538 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2539 {
2540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2541 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
2542 }
2543 complete(&pAdapter->tdls_link_establish_req_comp);
2544 break;
2545 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002546 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002547 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002548 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002549 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002550 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002551 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2552 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002553 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002554 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002555 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2556
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302557 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002558 if (NULL != curr_peer && TDLS_IS_CONNECTED(curr_peer))
2559 {
2560 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2561 wlan_hdd_tdls_decrement_peer_count(pAdapter);
2562 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002563 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002564
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002565 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2566 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
2567 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002568 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002569 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002570 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002571 break ;
2572 }
2573 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002574 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002575 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002576 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002577 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
2578 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002579 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002580 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2581 "%s: Sending teardown to supplicant with reason code %u",
2582 __func__, pRoamInfo->reasonCode);
2583
2584#ifdef CONFIG_TDLS_IMPLICIT
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302585 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002586 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002587#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002588 status = eHAL_STATUS_SUCCESS ;
2589 break ;
2590 }
2591 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
2592 {
2593 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002594 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002595 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002596 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2597 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002598 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002599 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002600 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002601 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002602 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002603 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
2604 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
2605 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002606
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002607 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002608 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002609 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2610 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002611
2612 status = eHAL_STATUS_SUCCESS ;
2613 }
2614 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05302615 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002616 break ;
2617 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002618 default:
2619 {
2620 break ;
2621 }
2622 }
2623
2624 return status ;
2625}
2626#endif
2627
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002628static void iw_full_power_cbfn (void *pContext, eHalStatus status)
2629{
2630 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
2631 hdd_context_t *pHddCtx = NULL;
2632 int ret;
2633
2634 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
2635 {
2636 hddLog(VOS_TRACE_LEVEL_ERROR,
2637 "%s: Bad param, pAdapter [%p]",
2638 __func__, pAdapter);
2639 return;
2640 }
2641
2642 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2643 ret = wlan_hdd_validate_context(pHddCtx);
2644 if (0 != ret)
2645 {
2646 hddLog(VOS_TRACE_LEVEL_ERROR,
2647 "%s: HDD context is not valid (%d)", __func__, ret);
2648 return;
2649 }
2650
2651 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2652 {
2653 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
2654 }
2655}
2656
Shailender Karmuchia734f332013-04-19 14:02:48 -07002657eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002658 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
2659{
2660 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2661 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302662 hdd_wext_state_t *pWextState = NULL;
2663 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002664 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07002665 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002666
2667 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002668 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002669 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002670
2671 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302672 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002673 {
2674 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302675 "invalid adapter or adapter has invalid magic");
2676 return eHAL_STATUS_FAILURE;
2677 }
2678
2679 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2680 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2681
2682 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2683 {
2684 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2685 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002686 return eHAL_STATUS_FAILURE;
2687 }
2688
Jeff Johnson295189b2012-06-20 16:38:30 -07002689 switch( roamStatus )
2690 {
2691 case eCSR_ROAM_SESSION_OPENED:
2692 if(pAdapter != NULL)
2693 {
2694 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2695 complete(&pAdapter->session_open_comp_var);
2696 }
2697 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002698
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002699#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
2700 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002701 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07002702 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07002703 * interface down */
2704 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05302705 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
2706 roamStatus, roamResult, pAdapter->sessionId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002707 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2708 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2709 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002710 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2711 }
2712 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05302713 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002714 break;
2715
2716 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002717 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07002718 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07002719 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07002720 // eCSR_ROAM_SHOULD_ROAM will be received.
2721 // Where in we will not mark the link down
2722 // Also we want to stop tx at this point when we will be
2723 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002724 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002725 {
2726 struct net_device *dev = pAdapter->dev;
2727 netif_tx_disable(dev);
Mukul Sharma84f27252014-07-14 18:11:42 +05302728#ifdef DEBUG_ROAM_DELAY
2729 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
2730#endif
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002731 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002732 * Deregister for this STA with TL with the objective to flush
2733 * all the packets for this STA from wmm_tx_queue. If not done here,
2734 * we would run into a race condition (CR390567) wherein TX
2735 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2736 * been deleted. And, these packets get assigned with a STA idx of
2737 * self-sta (since the peer STA has been deleted) and get transmitted
2738 * on the new channel before the reassoc request. Since there will be
2739 * no ACK on the new channel, each packet gets retransmitted which
2740 * takes several seconds before the transmission of reassoc request.
2741 * This leads to reassoc-timeout and roam failure.
2742 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002743 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2744 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2745 {
2746 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2747 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2748 pHddStaCtx->conn_info.staId[0], status, status );
2749 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002750 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002751 }
2752 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002753 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 break;
2755#endif
2756
2757 case eCSR_ROAM_SHOULD_ROAM:
2758 // Dont need to do anything
2759 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002760 struct net_device *dev = pAdapter->dev;
2761 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2762 // notify apps that we can't pass traffic anymore
2763 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002764#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002765 if (pHddStaCtx->ft_carrier_on == FALSE)
2766 {
2767#endif
2768 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002769#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 }
2771#endif
2772
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002773#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 //We should clear all sta register with TL, for now, only one.
2775 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2776 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2777 {
2778 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2779 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2780 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002781 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002782 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002783#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002784 }
2785 break;
2786 case eCSR_ROAM_LOSTLINK:
2787 case eCSR_ROAM_DISASSOCIATED:
2788 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2790 "****eCSR_ROAM_DISASSOCIATED****");
2791 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2792 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07002793 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2794 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302795 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07002796 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08002797
2798 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
2799 pHddCtx->configuredMcastBcastFilter =
2800 pHddCtx->sus_res_mcastbcast_filter;
2801 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
2802 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302803
Amar Singhald53568e2013-09-26 11:03:45 -07002804 hddLog(VOS_TRACE_LEVEL_INFO,
2805 "offload: disassociation happening, restoring configuredMcastBcastFilter");
2806 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
2807 pHddCtx->configuredMcastBcastFilter);
2808 hddLog(VOS_TRACE_LEVEL_INFO,
2809 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2811 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002812#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302813 /* Call to clear any MC Addr List filter applied after
2814 * successful connection.
2815 */
2816 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002817#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002818 }
2819 break;
2820 case eCSR_ROAM_IBSS_LEAVE:
2821 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2822 "****eCSR_ROAM_IBSS_LEAVE****");
2823 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2824 break;
2825 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2826 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2827 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302828 // To Do - address probable memory leak with WEP encryption upon successful association
2829 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302831 //Clear saved connection information in HDD
2832 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002833 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302834 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002835
2836 break;
2837 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002838 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002839 pRoamInfo, roamId, roamStatus, roamResult );
2840 break;
2841 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07002842 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
2843 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002844 break;
2845
2846 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2847 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002848 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002849
2850 case eCSR_ROAM_MIC_ERROR_IND:
2851 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2852 break;
2853
2854 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002855 {
2856 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2857
2858 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002859 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
2860 (TRUE == pHddCtx->hdd_wlan_suspended) &&
2861 (eCSR_ROAM_RESULT_NONE == roamResult))
2862 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002863 /* Send DTIM period to the FW; only if the wlan is already
2864 in suspend. This is the case with roaming (reassoc),
2865 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
2866 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
2867 before the ENTER_BMPS_REQ ensures Listen Interval is
2868 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002869 hdd_set_pwrparams(pHddCtx);
2870 pHddStaCtx->hdd_ReassocScenario = VOS_FALSE;
2871
2872 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002873 if due to unexpected scenario, if we are in BMPS,
2874 then trigger Exit and Enter BMPS to take DTIM period
2875 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002876 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
2877 {
2878 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
2879
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002880 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2881 iw_full_power_cbfn, pAdapter,
2882 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002883 }
2884 }
2885 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05302886 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002887 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 break;
2889#ifdef WLAN_FEATURE_VOWIFI_11R
2890 case eCSR_ROAM_FT_RESPONSE:
2891 hdd_SendFTEvent(pAdapter);
2892 break;
2893#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002894#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002895 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002896 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07002897 {
2898 /* Notify the supplicant of a new candidate */
2899 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
2900 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002901 break;
2902#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002903
Yue Maef608272013-04-08 23:09:17 -07002904#ifdef FEATURE_WLAN_LFR_METRICS
2905 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
2906 /* This event is to notify pre-auth initiation */
2907 if (VOS_STATUS_SUCCESS !=
2908 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
2909 {
2910 halStatus = eHAL_STATUS_FAILURE;
2911 }
2912 break;
2913 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
2914 /* This event will notify pre-auth completion in case of success */
2915 if (VOS_STATUS_SUCCESS !=
2916 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2917 pRoamInfo, 1))
2918 {
2919 halStatus = eHAL_STATUS_FAILURE;
2920 }
2921 break;
2922 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
2923 /* This event will notify pre-auth completion in case of failure. */
2924 if (VOS_STATUS_SUCCESS !=
2925 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2926 pRoamInfo, 0))
2927 {
2928 halStatus = eHAL_STATUS_FAILURE;
2929 }
2930 break;
2931 case eCSR_ROAM_HANDOVER_SUCCESS:
2932 /* This event is to notify handover success.
2933 It will be only invoked on success */
2934 if (VOS_STATUS_SUCCESS !=
2935 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
2936 {
2937 halStatus = eHAL_STATUS_FAILURE;
2938 }
2939 break;
2940#endif
2941
Jeff Johnson295189b2012-06-20 16:38:30 -07002942 case eCSR_ROAM_INDICATE_MGMT_FRAME:
2943 hdd_indicateMgmtFrame( pAdapter,
2944 pRoamInfo->nFrameLength,
2945 pRoamInfo->pbFrames,
2946 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05302947 pRoamInfo->rxChan,
2948 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 break;
2950 case eCSR_ROAM_REMAIN_CHAN_READY:
2951 hdd_remainChanReadyHandler( pAdapter );
2952 break;
2953 case eCSR_ROAM_SEND_ACTION_CNF:
2954 hdd_sendActionCnf( pAdapter,
2955 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
2956 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002957#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08002958 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002959 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08002960 roamId, roamStatus, roamResult );
2961 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002962 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
2963 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
2964 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002965#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002966#ifdef WLAN_FEATURE_11W
2967 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
2968 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
2969 pRoamInfo->pbFrames,
2970 pRoamInfo->frameType);
2971 break;
2972#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002973#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002974 case eCSR_ROAM_TSM_IE_IND:
2975 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
2976 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
2977 break;
2978
2979 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
2980 {
2981 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
2982 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
2983 {
2984 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
2985 }
2986 break;
2987 }
2988
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002989 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002990 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002991 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002992 break;
2993 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002994
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002995 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002996 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002997 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002998 break;
2999 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003000#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07003001 default:
3002 break;
3003 }
3004 return( halStatus );
3005}
Shailender Karmuchia734f332013-04-19 14:02:48 -07003006eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003007{
3008 eCsrAuthType auth_type;
3009 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003010 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003011 {
3012 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003013 } else
3014 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003015 {
3016 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003017 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003018#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003019 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003020 {
3021 // Check for 11r FT Authentication with PSK
3022 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003023 } else
3024 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003025 {
3026 // Check for 11R FT Authentication with 802.1X
3027 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003028 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003029#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003030#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003031 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 {
3033 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
3034 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003035#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07003036#ifdef WLAN_FEATURE_11W
3037 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
3038 {
3039 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3040 } else
3041#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003042 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003043 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3044 }
3045 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003046}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003047
Shailender Karmuchia734f332013-04-19 14:02:48 -07003048eCsrAuthType
3049hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003050{
3051 eCsrAuthType auth_type;
3052 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003053 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 {
3055 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003056 } else
3057 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003058 {
3059 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003060 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003061#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003062 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003063 {
3064 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003065 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003066#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003067 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3069 }
3070 hddLog(LOG1, FL("auth_type: %d"), auth_type);
3071 return auth_type;
3072}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003073
Shailender Karmuchia734f332013-04-19 14:02:48 -07003074eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003075hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003076{
3077 eCsrEncryptionType cipher_type;
3078 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003079 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003080 {
3081 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003082 }
3083 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003084 {
3085 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003086 }
3087 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 {
3089 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003090 }
3091 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 {
3093 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003094 }
3095 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
3096 {
3097 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3098 }
3099 else
3100 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3102 }
3103 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3104 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003105}
Jeff Johnson295189b2012-06-20 16:38:30 -07003106/* To find if the MAC address is NULL */
3107static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3108{
3109 int i;
3110 for (i = 0; i < length; i++)
3111 {
3112 if (0x00 != (macAddr[i]))
3113 {
3114 return FALSE;
3115 }
3116 }
3117 return TRUE;
3118} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003119
Shailender Karmuchia734f332013-04-19 14:02:48 -07003120eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003121hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003122{
3123 eCsrEncryptionType cipher_type;
3124 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003125 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003126 {
3127 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003128 } else
3129 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003130 {
3131 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003132 } else
3133 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 {
3135 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003136 } else
3137 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003138 {
3139 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003140 } else
3141 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003143 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3144 } else
3145 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003146 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3147 }
3148 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3149 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003150}
Jeff Johnson295189b2012-06-20 16:38:30 -07003151
Shailender Karmuchia734f332013-04-19 14:02:48 -07003152static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3153 struct ether_addr *pBssid,
3154 eCsrEncryptionType *pEncryptType,
3155 eCsrEncryptionType *mcEncryptType,
3156 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003157#ifdef WLAN_FEATURE_11W
3158 u_int8_t *pMfpRequired,
3159 u_int8_t *pMfpCapable,
3160#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003161 u_int16_t gen_ie_len,
3162 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003163{
3164 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003165 eHalStatus result;
3166 tDot11fIERSN dot11RSNIE;
3167 tDot11fIEWPA dot11WPAIE;
3168 tANI_U32 i;
3169 tANI_U8 *pRsnIe;
3170 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003171 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003172 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003173
3174 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3175 flag to 0 */
3176 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3177 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3178
3179 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003180 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
3181 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303182 {
3183 hddLog(LOGE, "%s: Invalid DOT11F IE Length passed :%d",
3184 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003185 return -EINVAL;
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303186 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003188 if ( gen_ie[0] == DOT11F_EID_RSN)
3189 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003191 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003192 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3193 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303194 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3195 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003196 return -EINVAL;
3197 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003198 // Skip past the EID byte and length byte
3199 pRsnIe = gen_ie + 2;
3200 RSNIeLen = gen_ie_len - 2;
3201 // Unpack the RSN IE
3202 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3203 pRsnIe,
3204 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003206 // Copy out the encryption and authentication types
3207 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003208 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003209 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003210 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003211 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003212 but probably I suspect we can do something different*/
3213 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003214 // Just translate the FIRST one
3215 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3216 //dot11RSNIE.pwise_cipher_suite_count
3217 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3218 //dot11RSNIE.gp_cipher_suite_count
3219 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003220#ifdef WLAN_FEATURE_11W
3221 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3222 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3223#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003224 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003225 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003227 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003228 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303229 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003230 break;
3231 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003232 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003233 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303234 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003235 break;
3236 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003237 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 // For right now, I assume setASSOCIATE() has passed in the bssid.
3239 vos_mem_copy(PMKIDCache[i].BSSID,
3240 pBssid, ETHER_ADDR_LEN);
3241 vos_mem_copy(PMKIDCache[i].PMKID,
3242 dot11RSNIE.pmkid[i],
3243 CSR_RSN_PMKID_SIZE);
3244 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003245
3246 if (updatePMKCache)
3247 {
3248 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003249 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003250 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003251 // Finally set the PMKSA ID Cache in CSR
3252 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3253 PMKIDCache,
3254 dot11RSNIE.pmkid_count );
3255 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 }
3257 else if (gen_ie[0] == DOT11F_EID_WPA)
3258 {
3259 // Validity checks
3260 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3261 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3262 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303263 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3264 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003265 return -EINVAL;
3266 }
3267 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003268 pRsnIe = gen_ie + 2 + 4;
3269 RSNIeLen = gen_ie_len - (2 + 4);
3270 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003271 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3272 pRsnIe,
3273 RSNIeLen,
3274 &dot11WPAIE);
3275 // Copy out the encryption and authentication types
3276 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003277 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003279 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 //dot11WPAIE.auth_suite_count
3281 // Just translate the FIRST one
3282 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3283 //dot11WPAIE.unicast_cipher_count
3284 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3285 //dot11WPAIE.unicast_cipher_count
3286 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3287 }
3288 else
3289 {
3290 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003291 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003292 }
3293 return 0;
3294}
3295int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3296{
3297 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3298 v_U32_t status = 0;
3299 eCsrEncryptionType RSNEncryptType;
3300 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003301#ifdef WLAN_FEATURE_11W
3302 u_int8_t RSNMfpRequired;
3303 u_int8_t RSNMfpCapable;
3304#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 struct ether_addr bSsid; // MAC address of assoc peer
3306 // MAC address of assoc peer
3307 // But, this routine is only called when we are NOT associated.
3308 vos_mem_copy(bSsid.ether_addr_octet,
3309 pWextState->roamProfile.BSSIDs.bssid,
3310 sizeof(bSsid.ether_addr_octet));
3311 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3312 {
3313 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003314 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003315 else
3316 {
3317 return 0;
3318 }
3319 // The actual processing may eventually be more extensive than this.
3320 // Right now, just consume any PMKIDs that are sent in by the app.
3321 status = hdd_ProcessGENIE(pAdapter,
3322 &bSsid, // MAC address of assoc peer
3323 &RSNEncryptType,
3324 &mcRSNEncryptType,
3325 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003326#ifdef WLAN_FEATURE_11W
3327 &RSNMfpRequired,
3328 &RSNMfpCapable,
3329#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 pWextState->WPARSNIE[1]+2,
3331 pWextState->WPARSNIE);
3332 if (status == 0)
3333 {
3334 // Now copy over all the security attributes you have parsed out
3335 pWextState->roamProfile.EncryptionType.numEntries = 1;
3336 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003337
Jeff Johnson295189b2012-06-20 16:38:30 -07003338 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3339 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003340
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003341 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3342 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3343 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3344 {
3345 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3346 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3347 either AES/TKIP based on group cipher configuration
3348 mentioned in the wpa_supplicant.conf.*/
3349
3350 /*Set the unicast cipher same as multicast cipher*/
3351 pWextState->roamProfile.EncryptionType.encryptionType[0]
3352 = mcRSNEncryptType;
3353 }
3354
Chet Lanctot186b5732013-03-18 10:26:30 -07003355#ifdef WLAN_FEATURE_11W
3356 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3357 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3358#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003359 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 }
3361 return 0;
3362}
3363int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3364{
3365 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3366 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3367 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3368 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003369
Jeff Johnson295189b2012-06-20 16:38:30 -07003370 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003371 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003372
Jeff Johnson295189b2012-06-20 16:38:30 -07003373 switch( pHddStaCtx->conn_info.authType)
3374 {
3375 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003376#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003377 case eCSR_AUTH_TYPE_CCKM_WPA:
3378 case eCSR_AUTH_TYPE_CCKM_RSN:
3379#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003380 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3381
Jeff Johnson295189b2012-06-20 16:38:30 -07003382 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003383 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003384 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003385
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003386#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003387 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3388 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3389 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003390 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003391 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3392 } else
3393 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003394 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003395 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003396 } else
3397#endif
3398 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3399 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003400 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3401 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3403 == IW_AUTH_KEY_MGMT_PSK) {
3404 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003405 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003406 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003407 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003408 }
3409 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003410#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003411 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3412 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3413 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003414 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003415 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003416 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003417 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003418 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003419 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003420 } else
3421#endif
3422
3423#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003424 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3425 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003427 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003428 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003429 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003430 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3431 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003432 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 } else
3434#endif
3435
Chet Lanctot186b5732013-03-18 10:26:30 -07003436#ifdef WLAN_FEATURE_11W
3437 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3438 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3439 } else
3440#endif
3441
Shailender Karmuchia734f332013-04-19 14:02:48 -07003442 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003443 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003444 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3445 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003446 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3447 == IW_AUTH_KEY_MGMT_PSK) {
3448 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003449 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003450 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003451 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003452 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003453 break;
3454
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003456
3457 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003458 break;
3459 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003460
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003461#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08003462 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003463#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3465 break;
3466 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003467
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003469 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003470
Jeff Johnson295189b2012-06-20 16:38:30 -07003471 EXIT();
3472 return 0;
3473}
3474
3475/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003476
3477 \brief iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07003479 to the CSR roam profile.
3480
Jeff Johnson295189b2012-06-20 16:38:30 -07003481 \param - dev - Pointer to the net device.
3482 - info - Pointer to the iw_request_info.
3483 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003484 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003485 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003486
Jeff Johnson295189b2012-06-20 16:38:30 -07003487 --------------------------------------------------------------------------*/
3488
Shailender Karmuchia734f332013-04-19 14:02:48 -07003489int iw_set_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003490 struct iw_request_info *info,
3491 union iwreq_data *wrqu, char *extra)
3492{
3493 v_U32_t status = 0;
3494 hdd_wext_state_t *pWextState;
3495 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3496 v_U32_t roamId;
3497 tCsrRoamProfile *pRoamProfile;
3498 eMib_dot11DesiredBssType connectedBssType;
3499 eCsrAuthType RSNAuthType;
3500 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3501 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003502
3503 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3504
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 ENTER();
3506
3507 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3508 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303509 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003510 "%s:LOGP in Progress. Ignore!!!",__func__);
3511 return 0;
3512 }
3513
3514 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
3515 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
3516 return -EBUSY;
3517 }
3518 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
3519 return -EINVAL;
3520 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003521 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003522 {
3523 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
3524 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
3525 {
3526 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003527 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3529 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
3530
3531 if(VOS_STATUS_SUCCESS == vosStatus)
3532 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3533 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3534 }
3535 }
3536 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003537 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003538 {
3539 return -EINVAL;
3540 }
3541 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003542 /** when cfg80211 defined, wpa_supplicant wext driver uses
3543 zero-length, null-string ssid for force disconnection.
3544 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07003545 driver MUST return success */
3546 if ( 0 == wrqu->essid.length ) {
3547 return 0;
3548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003549
3550 status = hdd_wmm_get_uapsd_mask(pAdapter,
3551 &pWextState->roamProfile.uapsd_mask);
3552 if (VOS_STATUS_SUCCESS != status)
3553 {
3554 pWextState->roamProfile.uapsd_mask = 0;
3555 }
3556 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003557
Jeff Johnson295189b2012-06-20 16:38:30 -07003558 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003559
3560 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003561 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
3562 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
3563 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003564
Jeff Johnson295189b2012-06-20 16:38:30 -07003565 //set gen ie
3566 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
3567
3568 //set auth
3569 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
3570 }
3571#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003572 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003573 if (pAdapter->wapi_info.nWapiMode)
3574 {
3575 switch (pAdapter->wapi_info.wapiAuthMode)
3576 {
3577 case WAPI_AUTH_MODE_PSK:
3578 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003579 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003580 pRoamProfile->AuthType.numEntries = 1;
3581 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3582 break;
3583 }
3584 case WAPI_AUTH_MODE_CERT:
3585 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003586 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 pRoamProfile->AuthType.numEntries = 1;
3588 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3589 break;
3590 }
3591 } // End of switch
3592 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
3593 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
3594 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003595 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 pRoamProfile->EncryptionType.numEntries = 1;
3597 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3598 pRoamProfile->mcEncryptionType.numEntries = 1;
3599 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3600 }
3601 }
3602#endif /* FEATURE_WLAN_WAPI */
3603 /* if previous genIE is not NULL, update AssocIE */
3604 if (0 != pWextState->genIE.length)
3605 {
3606 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
3607 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
3608 pWextState->genIE.length);
3609 pWextState->assocAddIE.length = pWextState->genIE.length;
3610 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
3611 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
3612
3613 /* clear previous genIE after use it */
3614 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
3615 }
3616
3617 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
3618 pWextState->roamProfile.bWPSAssociation = FALSE;
3619
3620 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
3621 pWextState->roamProfile.nAddIEAssocLength))
3622 pWextState->roamProfile.bWPSAssociation = TRUE;
3623
3624
3625 // Disable auto BMPS entry by PMC until DHCP is done
3626 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
3627
Shailender Karmuchia734f332013-04-19 14:02:48 -07003628 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003629 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003630
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003631 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
3632 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003633 hdd_select_cbmode(pAdapter,
3634 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
3635 }
3636 status = sme_RoamConnect( hHal,pAdapter->sessionId,
3637 &(pWextState->roamProfile), &roamId);
3638 pRoamProfile->ChannelInfo.ChannelList = NULL;
3639 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003640
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003641 EXIT();
3642 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003643}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003644
Jeff Johnson295189b2012-06-20 16:38:30 -07003645/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003646
3647 \brief iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003648 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003649
Jeff Johnson295189b2012-06-20 16:38:30 -07003650 \param - dev - Pointer to the net device.
3651 - info - Pointer to the iw_request_info.
3652 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003653 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003654 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003655
Jeff Johnson295189b2012-06-20 16:38:30 -07003656 --------------------------------------------------------------------------*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003657int iw_get_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 struct iw_request_info *info,
3659 struct iw_point *dwrq, char *extra)
3660{
3661 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003662 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3664 ENTER();
3665
3666 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
3667 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
3668 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
3669 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
3670 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
3671 {
3672 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
3673 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
3674 dwrq->flags = 1;
3675 } else {
3676 memset(extra, 0, dwrq->length);
3677 dwrq->length = 0;
3678 dwrq->flags = 0;
3679 }
3680 EXIT();
3681 return 0;
3682}
3683/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003684
3685 \brief iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003687
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 \param - dev - Pointer to the net device.
3689 - info - Pointer to the iw_request_info.
3690 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003691 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003692 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003693
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 --------------------------------------------------------------------------*/
3695int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
3696 union iwreq_data *wrqu,char *extra)
3697{
3698 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003699 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003700 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3701 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003702 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07003703 eCsrEncryptionType ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003704
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003706
3707 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3708 {
3709 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3710 "%s:LOGP in Progress. Ignore!!!", __func__);
3711 return -EBUSY;
3712 }
3713
Jeff Johnson295189b2012-06-20 16:38:30 -07003714 switch(wrqu->param.flags & IW_AUTH_INDEX)
3715 {
3716 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003717
Jeff Johnson295189b2012-06-20 16:38:30 -07003718 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003719
Jeff Johnson295189b2012-06-20 16:38:30 -07003720 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003721
Jeff Johnson295189b2012-06-20 16:38:30 -07003722 case IW_AUTH_CIPHER_PAIRWISE:
3723 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003724 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003725 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003726 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3728 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003729 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
3731 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003732 }
3733
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003735
3736 if( (IW_AUTH_KEY_MGMT_802_1X
3737 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003738 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
3739 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003740 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07003741 else
3742 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003743 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3744 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003746
3747 if( ( IW_AUTH_KEY_MGMT_802_1X
3748 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3750 /*Dynamic WEP key*/
3751 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3752 else
3753 /*Static WEP key*/
3754 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003755
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 }
3757 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003758
Jeff Johnson295189b2012-06-20 16:38:30 -07003759 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003760 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003761 return -EINVAL;
3762 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003763
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 pRoamProfile->EncryptionType.numEntries = 1;
3765 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003766 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003767 break;
3768 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003769 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
3771 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3772 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003773
Jeff Johnson295189b2012-06-20 16:38:30 -07003774 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3775 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
3776 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003777
3778 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003779 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
3780 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003781
Jeff Johnson295189b2012-06-20 16:38:30 -07003782 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003783
3784 if( ( IW_AUTH_KEY_MGMT_802_1X
3785 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
3786 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3787
Jeff Johnson295189b2012-06-20 16:38:30 -07003788 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003789
3790 else
3791 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003792 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003793
3794 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
3795 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003797 if( ( IW_AUTH_KEY_MGMT_802_1X
3798 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3800 {
3801 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3802 }
3803 else
3804 {
3805 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3806 }
3807 }
3808 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003809
Jeff Johnson295189b2012-06-20 16:38:30 -07003810 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003811 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003812 return -EINVAL;
3813 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003814
Jeff Johnson295189b2012-06-20 16:38:30 -07003815 pRoamProfile->mcEncryptionType.numEntries = 1;
3816 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
3817 }
3818 break;
3819
3820 case IW_AUTH_80211_AUTH_ALG:
3821 {
3822 /*Save the auth algo here and set auth type to SME Roam profile
3823 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003824 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07003825 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003826
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
3828 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
3829
3830 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
3831 /*Not supported*/
3832 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3833 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
3834 }
3835 break;
3836
3837 case IW_AUTH_KEY_MGMT:
3838 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003839#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003840#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
3841 /*Check for CCKM AKM type */
3842 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003843 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
3844 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003845 /* Set the CCKM bit in authKeyMgmt */
3846 /* Right now, this breaks all ref to authKeyMgmt because our
3847 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07003848 */
3849 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
3850 /*Set the key management to 802.1X*/
3851 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003852 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003853 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3854 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3855 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
3856 /*Save the key management*/
3857 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
3858 //pWextState->authKeyMgmt = wrqu->param.value;
3859 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3860 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3861 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
3862 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
3863 /*Save the key management anyway*/
3864 pWextState->authKeyMgmt = wrqu->param.value;
3865 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
3866 /*Save the key management*/
3867 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
3868 //pWextState->authKeyMgmt = wrqu->param.value;
3869 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3870 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3871 }
3872#else
3873 /*Save the key management*/
3874 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003875#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003876 }
3877 break;
3878
3879 case IW_AUTH_TKIP_COUNTERMEASURES:
3880 {
3881 if(wrqu->param.value) {
3882 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3883 "Counter Measure started %d", wrqu->param.value);
3884 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
3885 }
3886 else {
3887 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3888 "Counter Measure stopped=%d", wrqu->param.value);
3889 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3890 }
3891 }
3892 break;
3893 case IW_AUTH_DROP_UNENCRYPTED:
3894 case IW_AUTH_WPA_ENABLED:
3895 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3896 case IW_AUTH_ROAMING_CONTROL:
3897 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003898
Jeff Johnson295189b2012-06-20 16:38:30 -07003899 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003900
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003901 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003902 wrqu->param.flags & IW_AUTH_INDEX);
3903 break;
3904 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003905
Jeff Johnson295189b2012-06-20 16:38:30 -07003906 EXIT();
3907 return 0;
3908}
3909/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003910
3911 \brief iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003912 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003913
Jeff Johnson295189b2012-06-20 16:38:30 -07003914 \param - dev - Pointer to the net device.
3915 - info - Pointer to the iw_request_info.
3916 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003917 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003918 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003919
Jeff Johnson295189b2012-06-20 16:38:30 -07003920 --------------------------------------------------------------------------*/
3921int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
3922 union iwreq_data *wrqu,char *extra)
3923{
3924 hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003925 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3927 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003928
3929 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3930 {
3931 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3932 "%s:LOGP in Progress. Ignore!!!", __func__);
3933 return -EBUSY;
3934 }
3935
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 switch(pRoamProfile->negotiatedAuthType)
3937 {
3938 case eCSR_AUTH_TYPE_WPA_NONE:
3939 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3940 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
3941 break;
3942 case eCSR_AUTH_TYPE_WPA:
3943 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3944 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
3945 break;
3946#ifdef WLAN_FEATURE_VOWIFI_11R
3947 case eCSR_AUTH_TYPE_FT_RSN:
3948#endif
3949 case eCSR_AUTH_TYPE_RSN:
3950 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3951 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
3952 break;
3953 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3954 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3955 break;
3956 case eCSR_AUTH_TYPE_SHARED_KEY:
3957 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
3958 break;
3959 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003960 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003961 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3962 break;
3963 case eCSR_AUTH_TYPE_AUTOSWITCH:
3964 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3965 break;
3966 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303967 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003968 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3969 return -EIO;
3970#ifdef WLAN_FEATURE_VOWIFI_11R
3971 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3972#endif
3973 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07003974#ifdef WLAN_FEATURE_11W
3975 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3976#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05303977 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3979 return -EIO;
3980 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303981 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003982 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3983 return -EIO;
3984 }
3985 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
3986 {
3987 switch(pRoamProfile->negotiatedUCEncryptionType)
3988 {
3989 case eCSR_ENCRYPT_TYPE_NONE:
3990 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3991 break;
3992 case eCSR_ENCRYPT_TYPE_WEP40:
3993 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3994 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3995 break;
3996 case eCSR_ENCRYPT_TYPE_TKIP:
3997 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3998 break;
3999 case eCSR_ENCRYPT_TYPE_WEP104:
4000 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4001 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4002 break;
4003 case eCSR_ENCRYPT_TYPE_AES:
4004 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4005 break;
4006 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304007 hddLog(LOG1, "%s called with unknown auth type %d ",
4008 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004009 return -EIO;
4010 }
4011 }
4012
Shailender Karmuchia734f332013-04-19 14:02:48 -07004013 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 {
4015 switch(pRoamProfile->negotiatedMCEncryptionType)
4016 {
4017 case eCSR_ENCRYPT_TYPE_NONE:
4018 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4019 break;
4020 case eCSR_ENCRYPT_TYPE_WEP40:
4021 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4022 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4023 break;
4024 case eCSR_ENCRYPT_TYPE_TKIP:
4025 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4026 break;
4027 case eCSR_ENCRYPT_TYPE_WEP104:
4028 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4029 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4030 break;
4031 case eCSR_ENCRYPT_TYPE_AES:
4032 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4033 break;
4034 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304035 hddLog(LOG1, "%s called with unknown auth type %d ",
4036 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004037 return -EIO;
4038 }
4039 }
4040
4041 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004042 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004043 EXIT();
4044 return 0;
4045}
4046/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004047
4048 \brief iw_set_ap_address() -
4049 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004051
Jeff Johnson295189b2012-06-20 16:38:30 -07004052 \param - dev - Pointer to the net device.
4053 - info - Pointer to the iw_request_info.
4054 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004055 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004056 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004057
Jeff Johnson295189b2012-06-20 16:38:30 -07004058 --------------------------------------------------------------------------*/
4059int iw_set_ap_address(struct net_device *dev,
4060 struct iw_request_info *info,
4061 union iwreq_data *wrqu, char *extra)
4062{
4063 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
4064 v_U8_t *pMacAddress=NULL;
4065 ENTER();
4066 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08004067 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
4068 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
4070 EXIT();
Shailender Karmuchia734f332013-04-19 14:02:48 -07004071
Jeff Johnson295189b2012-06-20 16:38:30 -07004072 return 0;
4073}
4074/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004075
4076 \brief iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 This function returns the BSSID to the wpa_supplicant
4078 \param - dev - Pointer to the net device.
4079 - info - Pointer to the iw_request_info.
4080 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004081 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004083
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 --------------------------------------------------------------------------*/
4085int iw_get_ap_address(struct net_device *dev,
4086 struct iw_request_info *info,
4087 union iwreq_data *wrqu, char *extra)
4088{
4089 //hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4090 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
4091
4092 ENTER();
4093
4094 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
4095 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
4096 {
Jeff Johnson4416a782013-03-25 14:17:50 -07004097 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07004098 }
4099 else
4100 {
4101 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4102 }
4103 EXIT();
4104 return 0;
4105}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004106
Chet Lanctot186b5732013-03-18 10:26:30 -07004107#ifdef WLAN_FEATURE_11W
4108/**---------------------------------------------------------------------------
4109
4110 \brief hdd_indicateUnprotMgmtFrame -
4111 This function forwards the unprotected management frame to the supplicant
4112 \param - pAdapter - Pointer to HDD adapter
4113 - nFrameLength - Length of the unprotected frame being passed
4114 - pbFrames - Pointer to the frame buffer
4115 - frameType - 802.11 frame type
4116 \return - nothing
4117
4118 --------------------------------------------------------------------------*/
4119void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
4120 tANI_U32 nFrameLength,
4121 tANI_U8* pbFrames,
4122 tANI_U8 frameType )
4123{
4124 tANI_U8 type = 0;
4125 tANI_U8 subType = 0;
4126
4127 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
4128 __func__, frameType, nFrameLength);
4129
4130 /* Sanity Checks */
4131 if (NULL == pAdapter)
4132 {
4133 hddLog( LOGE, FL("pAdapter is NULL"));
4134 return;
4135 }
4136
4137 if (NULL == pAdapter->dev)
4138 {
4139 hddLog( LOGE, FL("pAdapter->dev is NULL"));
4140 return;
4141 }
4142
4143 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
4144 {
4145 hddLog( LOGE, FL("pAdapter has invalid magic"));
4146 return;
4147 }
4148
4149 if( !nFrameLength )
4150 {
4151 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
4152 return;
4153 }
4154
4155 if (NULL == pbFrames) {
4156 hddLog( LOGE, FL("pbFrames is NULL"));
4157 return;
4158 }
4159
4160 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4161 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4162
4163 /* Get pAdapter from Destination mac address of the frame */
4164 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
4165 {
4166 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
4167 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4168 }
4169 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
4170 {
4171 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
4172 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4173 }
4174 else
4175 {
4176 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
4177 return;
4178 }
4179}
4180#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004181
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004182#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004183void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
4184 tANI_U8 state,
4185 tANI_U16 measInterval )
4186{
4187 union iwreq_data wrqu;
4188 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004189 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004190
4191 if (NULL == pAdapter)
4192 return;
4193
4194 // create the event
4195 memset(&wrqu, '\0', sizeof(wrqu));
4196 memset(buf, '\0', sizeof(buf));
4197
4198 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
4199 tid, state, measInterval);
4200
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004201 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004202
4203 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004204 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004205 // send the event
4206 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4207}
4208
4209void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4210{
4211 union iwreq_data wrqu;
4212 char buf[IW_CUSTOM_MAX + 1];
4213 char *pos = buf;
4214 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4215
4216 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4217 return;
4218
4219 // create the event
4220 memset(&wrqu, '\0', sizeof(wrqu));
4221 memset(buf, '\0', sizeof(buf));
4222
4223 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304224 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
4225 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
4226 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
4227 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004228
4229 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4230 pos += nBytes;
4231 freeBytes -= nBytes;
4232
4233 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
4234 pos += WNI_CFG_BSSID_LEN;
4235 freeBytes -= WNI_CFG_BSSID_LEN;
4236
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004237 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4238 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004239
4240 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004241 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004242
4243 // send the event
4244 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4245}
4246
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004247void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004248{
4249 union iwreq_data wrqu;
4250 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004251 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004252
4253 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4254 return;
4255
4256 // create the event
4257 memset(&wrqu, '\0', sizeof(wrqu));
4258 memset(buf, '\0', sizeof(buf));
4259
4260 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
4261
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004262 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004263
4264 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004265 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004266
4267 // send the event
4268 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4269}
4270
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004271void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
4272 const tANI_U16 measurementToken,
4273 const tANI_BOOLEAN flag,
4274 const tANI_U8 numBss)
4275{
4276 union iwreq_data wrqu;
4277 char buf[IW_CUSTOM_MAX];
4278 char *pos = buf;
4279 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4280
4281 memset(&wrqu, '\0', sizeof(wrqu));
4282 memset(buf, '\0', sizeof(buf));
4283
4284 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
4285 numBss);
4286
4287 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4288 flag, numBss);
4289
4290 wrqu.data.pointer = buf;
4291 wrqu.data.length = nBytes;
4292 // send the event
4293 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4294}
4295
4296
4297static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004298 const tCsrRoamInfo *pRoamInfo)
4299{
4300 union iwreq_data wrqu;
4301 char buf[IW_CUSTOM_MAX + 1];
4302 char *pos = buf;
4303 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4304 tANI_U8 i = 0, len = 0;
4305 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
4306 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004307 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
4308 tANI_U8 ieLenByte = 1;
4309 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
4310#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004311
4312 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4313 return;
4314
4315 /* Custom event can pass maximum of 256 bytes of data,
4316 based on the IE len we need to identify how many BSS info can
4317 be filled in to custom event data */
4318 /*
4319 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4320 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4321 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4322 */
4323
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004324 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004325 {
4326 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
4327 /* If the measurement is none and no scan results found,
4328 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004329 hdd_indicateEseBcnReportNoResults(pAdapter,
4330 pRoamInfo->pEseBcnReportRsp->measurementToken,
4331 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004332 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004333 }
4334 else
4335 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004336 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004337 {
4338 memset(&wrqu, '\0', sizeof(wrqu));
4339 memset(buf, '\0', sizeof(buf));
4340 tot_bcn_ieLen = 0;
4341 sendBss = 0;
4342 pos = buf;
4343 freeBytes = IW_CUSTOM_MAX;
4344
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004345 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004346 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004347 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
4348 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004349 {
4350 break;
4351 }
4352 tot_bcn_ieLen += len;
4353 sendBss++;
4354 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
4355 "IeLength(%d) Length of Ie(%d) totLen(%d)",
4356 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004357 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004358 tot_bcn_ieLen);
4359 }
4360
4361 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
4362 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004363 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4364 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004365
4366 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004367 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4368 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004369 pos += nBytes;
4370 freeBytes -= nBytes;
4371
4372 /* Copy total Beacon report data length */
4373 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
4374 pos += sizeof(tot_bcn_ieLen);
4375 freeBytes -= sizeof(tot_bcn_ieLen);
4376
4377 for (i = 0; i < sendBss; i++)
4378 {
4379 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304380 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4381 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004382 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004383 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
4384 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
4385 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
4386 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
4387 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
4388 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
4389 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
4390 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
4391 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
4392 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
4393 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
4394 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
4395 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
4396 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
4397 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
4398 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004399
4400 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004401 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
4402 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004403 pos += len;
4404 freeBytes -= len;
4405
4406 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004407 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004408 vos_mem_copy(pos, (char*)&len, sizeof(len));
4409 pos += sizeof(len);
4410 freeBytes -= sizeof(len);
4411
4412 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004413 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004414 pos += len;
4415 freeBytes -= len;
4416 }
4417
4418 wrqu.data.pointer = buf;
4419 wrqu.data.length = strlen(buf);
4420
4421 // send the event
4422 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4423 lastSent += sendBss;
4424 }
4425 }
4426}
4427
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004428#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004429