blob: 156ede059dd17c950916538e78ca9f0418ccb14d [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
Abhishek Singhae408032014-09-25 17:22:04 +0530100/* RSN-8021X-SHA256 */
101v_U8_t ccpRSNOui08[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 };
Chet Lanctot186b5732013-03-18 10:26:30 -0700102#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700103
Shailender Karmuchia734f332013-04-19 14:02:48 -0700104#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700105// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700106#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
107#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700108#endif
109
110#define BEACON_FRAME_IES_OFFSET 12
111
Chet Lanctot186b5732013-03-18 10:26:30 -0700112#ifdef WLAN_FEATURE_11W
113void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
114 tANI_U32 nFrameLength,
115 tANI_U8* pbFrames,
116 tANI_U8 frameType );
117#endif
118
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800119#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700120static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
121 tANI_U8 state,
122 tANI_U16 measInterval );
123static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800124static void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
125static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700126
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800127#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700128
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530129static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
130 tCsrRoamInfo *pRoamInfo,
131 tANI_U32 roamId,
132 eRoamCmdStatus roamStatus,
133 eCsrRoamResult roamResult );
134
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530135v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
136 eConnectionState connState )
137{
138 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530139 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
140 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700141 pHddStaCtx->conn_info.connState = connState;
142}
143
144// returns FALSE if not connected.
145// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
146// returns the connection state. Can specify NULL if you dont' want to get the actual state.
147
Shailender Karmuchia734f332013-04-19 14:02:48 -0700148static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
149 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700150{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700151 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700152 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700153
Jeff Johnson295189b2012-06-20 16:38:30 -0700154 // get the connection state.
155 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700156 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700157 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700158 eConnectionState_IbssConnected == connState ||
159 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700160 {
161 fConnected = VOS_TRUE;
162 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700163 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700164 {
165 fConnected = VOS_FALSE;
166 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700167
Jeff Johnson295189b2012-06-20 16:38:30 -0700168 if ( pConnState )
169 {
170 *pConnState = connState;
171 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700172
Jeff Johnson295189b2012-06-20 16:38:30 -0700173 return( fConnected );
174}
175
176v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
177{
178 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700179}
Jeff Johnson295189b2012-06-20 16:38:30 -0700180
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530181eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx )
182{
183 v_U8_t staChannel = 0;
184
185 if ( eConnectionState_Associated == pHddStaCtx->conn_info.connState )
186 {
187 staChannel = pHddStaCtx->conn_info.operationChannel;
188 }
189
190 if ( staChannel > 0 && staChannel < 14 )
191 return eCSR_BAND_24;
192 else if (staChannel >= 36 && staChannel <= 165 )
193 return eCSR_BAND_5G;
194 else /* If station is not connected return as eCSR_BAND_ALL */
195 return eCSR_BAND_ALL;
196}
197
198
Jeff Johnson295189b2012-06-20 16:38:30 -0700199//TODO - Not used anyhwere. Can be removed.
200#if 0
201//
202v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
203{
204 v_BOOL_t fConnectedInfra = FALSE;
205 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700206
Jeff Johnson295189b2012-06-20 16:38:30 -0700207 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700208 {
209 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700210 {
211 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700212 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700213 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700214
Jeff Johnson295189b2012-06-20 16:38:30 -0700215 return( fConnectedInfra );
216}
217#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700218
Jeff Johnson295189b2012-06-20 16:38:30 -0700219static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
220{
221 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700222
Jeff Johnson295189b2012-06-20 16:38:30 -0700223 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700224
225 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700226 {
227 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
228 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700229
Jeff Johnson295189b2012-06-20 16:38:30 -0700230 return( fConnected );
231}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700232
Jeff Johnson295189b2012-06-20 16:38:30 -0700233inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
234{
235 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700236
Jeff Johnson295189b2012-06-20 16:38:30 -0700237 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700238
239 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700240 {
241 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
242 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700243
Jeff Johnson295189b2012-06-20 16:38:30 -0700244 return( fConnected );
245}
246
247static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
248{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700249 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700250 {
251 case eCSR_BSS_TYPE_INFRASTRUCTURE:
252 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
253 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700254
Jeff Johnson295189b2012-06-20 16:38:30 -0700255 case eCSR_BSS_TYPE_IBSS:
256 case eCSR_BSS_TYPE_START_IBSS:
257 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
258 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700259
260 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700261 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700262 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700263 default:
264 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700265 break;
266 }
267
Jeff Johnson295189b2012-06-20 16:38:30 -0700268}
269
270void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
271{
272 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
273 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700274
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700276
277 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700278 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700279 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700280 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
281 {
282 VOS_ASSERT( pRoamInfo->pBssDesc );
283 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
284
285 // Save the Station ID for this station from the 'Roam Info'.
286 //For IBSS mode, staId is assigned in NEW_PEER_IND
287 //For reassoc, the staID doesn't change and it may be invalid in this structure
288 //so no change here.
289 if( !pRoamInfo->fReassocReq )
290 {
291 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
292 }
293 }
294 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700295 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700296 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700297 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700298 else
299 {
300 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
301 // or we can't function.
302 VOS_ASSERT( 0 );
303 }
304
305 // notify WMM
306 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
307
308 if( !pRoamInfo->u.pConnectedProfile )
309 {
310 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
311 }
312 else
313 {
314 // Get Multicast Encryption Type
315 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
316 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
317 // Get Unicast Encrytion Type
318 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
319 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
320
321 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
322
323 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
324
325 // Save the ssid for the connection
326 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530327
328 // Save dot11mode in which STA associated to AP
329 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700330 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700331 }
332
Jeff Johnson295189b2012-06-20 16:38:30 -0700333 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700334 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
335
Jeff Johnson295189b2012-06-20 16:38:30 -0700336}
337
338#if defined(WLAN_FEATURE_VOWIFI_11R)
339/*
340 * Send the 11R key information to the supplicant.
341 * Only then can the supplicant generate the PMK-R1.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800342 * (BTW, the ESE supplicant also needs the Assoc Resp IEs
Jeff Johnson295189b2012-06-20 16:38:30 -0700343 * for the same purpose.)
344 *
345 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
346 * this contains the R1KHID, R0KHID and the MDID.
347 * For FT, this consists of the Reassoc Rsp FTIEs.
348 * This is the Assoc Response.
349 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700350static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700351 tCsrRoamInfo *pCsrRoamInfo)
352{
353 union iwreq_data wrqu;
354 char *buff;
355 unsigned int len = 0;
356 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700357
358 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700359 {
360 hddLog(LOGE,
361 "%s: pCsrRoamInfo->nAssocRspLength=%d",
362 __func__, (int)pCsrRoamInfo->nAssocRspLength);
363 return;
364 }
365
Shailender Karmuchia734f332013-04-19 14:02:48 -0700366 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700367 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700368 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700369 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700370 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700371 return;
372 }
373
374 // pFTAssocRsp needs to point to the IEs
375 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
376 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
377 (unsigned int)pFTAssocRsp[0],
378 (unsigned int)pFTAssocRsp[1]);
379
380 // We need to send the IEs to the supplicant.
381 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700382 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700383 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700384 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700385 return;
386 }
387
388 // Send the Assoc Resp, the supplicant needs this for initial Auth.
389 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700390 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700391 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700392 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700393 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
394
395 kfree(buff);
396}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700397#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700398
399#ifdef WLAN_FEATURE_VOWIFI_11R
400
401/*---------------------------------------------------
402 *
403 * Send the FTIEs, RIC IEs during FT. This is eventually
404 * used to send the FT events to the supplicant
405 *
406 * At the reception of Auth2 we send the RIC followed
407 * by the auth response IEs to the supplicant.
408 * Once both are received in the supplicant, an FT
409 * event is generated to the supplicant.
410 *
411 *---------------------------------------------------
412 */
413void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
414{
Jeff Johnson295189b2012-06-20 16:38:30 -0700415 tANI_U16 auth_resp_len = 0;
416 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700417 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
418
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530419#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700420 struct cfg80211_ft_event_params ftEvent;
421 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
422 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
423 struct net_device *dev = pAdapter->dev;
424#else
425 char *buff;
426 union iwreq_data wrqu;
427 tANI_U16 str_len;
428#endif
429
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530430#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530431 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
432 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700433
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530434 sme_GetRICIEs( pHddCtx->hHal, (u8 *)ricIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800435 DOT11F_IE_FTINFO_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530436 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700437 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530438 hddLog(LOGW,
439 "%s: RIC IEs is of length 0 not sending RIC Information for now",
440 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700441 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700442
443 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530444 ftEvent.ric_ies_len = ric_ies_length;
445 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700446
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530447 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800448 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700449
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530450 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700451 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530452 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700453 return;
454 }
455
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530456 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530457
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530458 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700459
460 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
461 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
462
Jeff Johnson59a121e2013-11-30 09:46:08 -0800463 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
464 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
465 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530466 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800467 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
468 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
469 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700470
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530471 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700472
473#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530474 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -0700475 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530476 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530478 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700479 return;
480 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530481 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700482
Shailender Karmuchia734f332013-04-19 14:02:48 -0700483 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -0700484 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530485 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800486 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530487 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700488 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530489 hddLog(LOGW,
490 "%s: RIC IEs is of length 0 not sending RIC Information for now",
491 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700492 }
493 else
494 {
495 wrqu.data.length = str_len + ric_ies_length;
496 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
497 }
498
499 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530500 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700501 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530502 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
503 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700504
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530505 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700506 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530507 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700508 return;
509 }
510
511 wrqu.data.length = str_len + auth_resp_len;
512 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
513
514 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700515#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700516}
517
518#endif /* WLAN_FEATURE_VOWIFI_11R */
519
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800520#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700521
522/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800523 * Send the ESE required "new AP Channel info" to the supplicant.
Jeff Johnson295189b2012-06-20 16:38:30 -0700524 * (This keeps the supplicant "up to date" on the current channel.)
525 *
526 * The current (new AP) channel information is passed in.
527 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700528static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700529 tCsrRoamInfo *pCsrRoamInfo)
530{
531 union iwreq_data wrqu;
532 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700533
Shailender Karmuchia734f332013-04-19 14:02:48 -0700534
535 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700536 {
537 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800538 "%s: pCsrRoamInfo->pBssDesc=%p",
Jeff Johnson295189b2012-06-20 16:38:30 -0700539 __func__, descriptor);
540 return;
541 }
542
543 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -0800544 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700545 memset(&wrqu, '\0', sizeof(wrqu));
546 wrqu.freq.m = descriptor->channelId;
547 wrqu.freq.e = 0;
548 wrqu.freq.i = 0;
549 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
550}
551
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800552#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700553
554void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
555{
556 union iwreq_data wrqu;
557 u8 *pBeaconIes;
558 u8 currentLen = 0;
559 char *buff;
560 int totalIeLen = 0, currentOffset = 0, strLen;
561
562 memset(&wrqu, '\0', sizeof(wrqu));
563
564 if (0 == pCsrRoamInfo->nBeaconLength)
565 {
566 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
567 return;
568 }
569 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700570 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700572 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700573 return;
574 }
575
576 // pBeaconIes needs to point to the IEs
577 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
578 (unsigned int)pBeaconIes[0],
579 (unsigned int)pBeaconIes[1]);
580 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700581
Jeff Johnson295189b2012-06-20 16:38:30 -0700582 // We need to send the IEs to the supplicant.
583 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700584 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700586 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 return;
588 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700589 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700590
591 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
592 currentLen = strLen + 1;
593
594 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
595 do
596 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700597 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -0700598 * max size and send it to supplicant. Changes are done in supplicant to handle this */
599 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
600 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
601 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
602 currentOffset += currentLen;
603 totalIeLen -= currentLen;
604 wrqu.data.length = strLen + 1 + currentLen;
605 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700606 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -0700607 else
608 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
609
610 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
611 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
612 } while (totalIeLen > 0);
613
614 kfree(buff);
615}
616
617static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
618{
619 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
620 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
621 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
622 union iwreq_data wrqu;
623 int we_event;
624 char *msg;
625 int type = -1;
626
Shailender Karmuchia734f332013-04-19 14:02:48 -0700627#if defined (WLAN_FEATURE_VOWIFI_11R)
628 // Added to find the auth type on the fly at run time
629 // rather than with cfg to see if FT is enabled
630 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700631 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
632#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700633
Jeff Johnson295189b2012-06-20 16:38:30 -0700634 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -0700635 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700636 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700637
Jeff Johnson295189b2012-06-20 16:38:30 -0700638 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
639 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530640 /* In case of roaming ; We are not doing disconnect.
641 * If disconnect is not being done for roam; We will not
642 * decrease count for Active sessions. We should not increase active
643 * active session in case of roaming.
644 */
645 if(pHddStaCtx->ft_carrier_on == FALSE)
646 {
647 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
648 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700649 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
650 type = WLAN_STA_ASSOC_DONE_IND;
651
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700652#ifdef WLAN_FEATURE_P2P_DEBUG
653 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
654 {
655 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
656 {
657 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
658 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
659 "Connecting state to Connected State for 8-way "
660 "Handshake");
661 }
662 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
663 {
664 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
665 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
666 "Connecting state to P2P Client Connection Completed");
667 }
668 }
669#endif
Arif Hussain77d044f2014-01-03 19:56:04 -0800670 pr_info("wlan: " MAC_ADDRESS_STR " connected to " MAC_ADDRESS_STR "\n",
671 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
Kiet Lam34947452014-01-21 23:23:40 -0800672 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700673 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
674
675 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
676 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
677 * and fFTEnable is TRUE */
678#ifdef WLAN_FEATURE_VOWIFI_11R
679 // Send FT Keys to the supplicant when FT is enabled
680 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700681 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800682#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700683 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
684 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
685#endif
686 )
687 {
688 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
689 }
690#endif
691 }
692 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
693 {
Agarwal Ashish51325b52014-06-16 16:50:49 +0530694 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -0700695 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 type = WLAN_STA_ASSOC_DONE_IND;
Arif Hussain24bafea2013-11-15 15:10:03 -0800697 pr_info("wlan: new IBSS connection to " MAC_ADDRESS_STR"\n",
698 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700699 }
700 else /* Not Associated */
701 {
702 pr_info("wlan: disconnected\n");
703 type = WLAN_STA_DISASSOC_DONE_IND;
704 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
705 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700706 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700707
708 msg = NULL;
709 /*During the WLAN uninitialization,supplicant is stopped before the
710 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530711 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700712 {
713 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800714#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700715 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700716 {
717 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
718 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700719 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
720 }
721#endif
722 }
723 send_btc_nlink_msg(type, 0);
724}
725
726void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
727{
728 // Remove staId, bssId and peerMacAddress
729 pHddStaCtx->conn_info.staId [ 0 ] = 0;
730 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
731 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
732
733 // Clear all security settings
734 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
735 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
736 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
737
738 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700739 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700740
741 // Set not-connected state
742 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -0700743
744 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
745}
746/* TODO Revist this function. and data path */
747static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
748{
749 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700750 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
751
752 if (WLAN_HDD_IBSS != pAdapter->device_mode)
753 {
754 hdd_disconnect_tx_rx(pAdapter);
755 }
756 else
757 {
758 // Need to cleanup all queues only if the last peer leaves
759 if (eConnectionState_IbssDisconnected == pHddStaCtx->conn_info.connState)
760 {
761 netif_tx_disable(pAdapter->dev);
762 netif_carrier_off(pAdapter->dev);
763 hdd_disconnect_tx_rx(pAdapter);
764 }
765 else
766 {
767 // There is atleast one more peer, do not cleanup all queues
768 hdd_flush_ibss_tx_queues(pAdapter, staId);
769 }
770 }
771
Jeff Johnson295189b2012-06-20 16:38:30 -0700772 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
773 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
774 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530775 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700776 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700777 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700778 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700779 }
780 return( vosStatus );
781}
782
783
784static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
785 tANI_U32 roamId, eRoamCmdStatus roamStatus,
786 eCsrRoamResult roamResult )
787{
788 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700789 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700790 struct net_device *dev = pAdapter->dev;
791 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
792 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700793 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530794 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700795
796 // Sanity check
797 if(dev == NULL)
798 {
Agarwal Ashish971c2882013-10-30 20:11:12 +0530799 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700800 "%s: net_dev is released return", __func__);
801 return eHAL_STATUS_FAILURE;
802 }
803
Jeff Johnson295189b2012-06-20 16:38:30 -0700804 // notify apps that we can't pass traffic anymore
805 netif_tx_disable(dev);
806 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700807
Jeff Johnsone7245742012-09-05 17:12:55 -0700808 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530809 /* HDD has initiated disconnect, do not send disconnect indication
810 * to kernel as it will be handled by __cfg80211_disconnect.
811 */
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530812 /* If only STA mode is on */
813 if((pHddCtx->concurrency_mode <= 1) &&
814 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
815 {
816 pHddCtx->isAmpAllowed = VOS_TRUE;
817 }
818
Agarwal Ashish47d18112014-08-04 19:55:07 +0530819 /* Need to apply spin lock before decreasing active sessions
820 * as there can be chance for double decrement if context switch
821 * Calls wlan_hdd_disconnect.
822 */
823
824 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530825 if ( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState )
826 {
827 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
828 FL(" HDD has initiated a disconnect, no need to send"
829 " disconnect indication to kernel"));
830 sendDisconInd = FALSE;
831 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530832 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700833 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530834 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +0530835 FL(" Set HDD connState to eConnectionState_Disconnecting from %d "),
836 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530837 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
838 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 }
Agarwal Ashish47d18112014-08-04 19:55:07 +0530840 spin_unlock_bh(&pAdapter->lock_for_active_session);
841
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -0700843
844 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -0700845
846 // indicate 'disconnect' status to wpa_supplicant...
847 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700848 /* indicate disconnected event to nl80211 */
849 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
850 {
851 /*During the WLAN uninitialization,supplicant is stopped before the
852 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530853 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700854 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700855 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
856 "%s: sent disconnected event to nl80211",
Jeff Johnson295189b2012-06-20 16:38:30 -0700857 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700858#ifdef WLAN_FEATURE_P2P_DEBUG
859 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
860 {
861 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
862 {
863 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
864 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
865 "and moved to disconnected state");
866 }
867 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
868 {
869 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
870 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
871 "and moved to inactive state");
872 }
873 }
874#endif
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530875 /*Only send indication to kernel if not initiated by kernel*/
876 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -0700877 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530878 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
879 if ( eCSR_ROAM_LOSTLINK == roamStatus )
880 {
881 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
882 }
883 else
884 {
885 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
886 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700887 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700888 //If the Device Mode is Station
889 // and the P2P Client is Connected
890 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -0700891
892 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -0700893 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -0700894 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -0700895 {
896 //Enable BMPS only of other Session is P2P Client
897 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700898 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -0700899
900 if (NULL != pVosContext)
901 {
902 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
903
904 if(NULL != pHddCtx)
905 {
906 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +0530907 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
908 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700909 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530910 if (pHddCtx->hdd_wlan_suspended)
911 {
912 hdd_set_pwrparams(pHddCtx);
913 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700914 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530915 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 }
917 }
918 }
919 }
920 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700921
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +0530922 hdd_wmm_adapter_clear(pAdapter);
Mukul Sharmac159c432014-01-15 15:42:46 +0530923#if defined(WLAN_FEATURE_VOWIFI_11R)
924 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
925#endif
Katya Nigam63ce1772014-09-26 15:53:49 +0530926
927 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
928 {
929 sta_id = IBSS_BROADCAST_STAID;
930 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
931 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
932 {
933 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
934 "hdd_roamDeregisterSTA() failed to for staID %d. "
935 "Status= %d [0x%x]",
936 sta_id, status, status );
937
938 status = eHAL_STATUS_FAILURE;
939 }
940
941 pHddCtx->sta_to_adapter[sta_id] = NULL;
942
943 }
944
945
946 sta_id = pHddStaCtx->conn_info.staId[0];
947
Jeff Johnson295189b2012-06-20 16:38:30 -0700948 //We should clear all sta register with TL, for now, only one.
krunal soni3fc26642013-10-08 22:41:42 -0700949 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
Jeff Johnson43971f52012-07-17 12:26:56 -0700950 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700951 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530952 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700953 "hdd_roamDeregisterSTA() failed to for staID %d. "
954 "Status= %d [0x%x]",
krunal soni3fc26642013-10-08 22:41:42 -0700955 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700956
957 status = eHAL_STATUS_FAILURE;
958 }
959
krunal soni3fc26642013-10-08 22:41:42 -0700960 pHddCtx->sta_to_adapter[sta_id] = NULL;
Katya Nigam63ce1772014-09-26 15:53:49 +0530961
Jeff Johnson295189b2012-06-20 16:38:30 -0700962 // Clear saved connection information in HDD
963 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhf4669da2014-05-26 15:07:49 +0530964 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
965 "%s: Set HDD connState to eConnectionState_NotConnected",
966 __func__);
967 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530968#ifdef WLAN_FEATURE_GTK_OFFLOAD
969 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
970 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
971 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +0530972 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
973 sizeof (tSirGtkOffloadParams));
974 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530975 }
976#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700977
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800978#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -0700979 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
980 {
981 wlan_hdd_tdls_disconnection_callback(pAdapter);
982 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800983#endif
984
Jeff Johnson295189b2012-06-20 16:38:30 -0700985 //Unblock anyone waiting for disconnect to complete
986 complete(&pAdapter->disconnect_comp_var);
987 return( status );
988}
989static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
990 tCsrRoamInfo *pRoamInfo,
991 v_U8_t staId,
992 v_MACADDR_t *pPeerMacAddress,
993 tSirBssDescription *pBssDesc )
994{
995 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
996 WLAN_STADescType staDesc = {0};
997 eCsrEncryptionType connectedCipherAlgo;
998 v_BOOL_t fConnected;
999 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1000 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001001 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001002
1003 if ( NULL == pBssDesc)
1004 {
1005 return VOS_STATUS_E_FAILURE;
1006 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 // Get the Station ID from the one saved during the assocation.
1008 staDesc.ucSTAId = staId;
1009
1010 if ( pHddStaCtx->conn_info.connDot11DesiredBssType == eMib_dot11DesiredBssType_infrastructure)
Jeff Johnson295189b2012-06-20 16:38:30 -07001011 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001012 staDesc.wSTAType = WLAN_STA_INFRA;
1013
1014 // grab the bssid from the connection info in the adapter structure and hand that
1015 // over to TL when registering.
1016 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) );
1017 }
1018 else
1019 {
1020 // for an IBSS 'connect', setup the Station Descriptor for TL.
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 staDesc.wSTAType = WLAN_STA_IBSS;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001022
Jeff Johnson295189b2012-06-20 16:38:30 -07001023 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
1024 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
1025 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
1026 // pass when making an Infrastructure connection.
1027 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) );
1028 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
1029 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001030
Jeff Johnson295189b2012-06-20 16:38:30 -07001031 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1032
1033 // set the QoS field appropriately
1034 if (hdd_wmm_is_active(pAdapter))
1035 {
1036 staDesc.ucQosEnabled = 1;
1037 }
1038 else
1039 {
1040 staDesc.ucQosEnabled = 0;
1041 }
1042
1043 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1044 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1045 {
1046 staDesc.ucProtectedFrame = 1;
1047 }
1048 else
1049 {
1050 staDesc.ucProtectedFrame = 0;
1051
1052 }
1053
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001054#ifdef FEATURE_WLAN_ESE
1055 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
1056#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001057
1058#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1059 /* check whether replay check is valid for the station or not */
1060 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
1061 {
1062 /* Encryption mode is either TKIP or AES
1063 and replay check is valid for only these
1064 two encryption modes */
1065 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1066 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1067 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1068 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001069
Jeff Johnson295189b2012-06-20 16:38:30 -07001070 else
1071 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001072 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001073 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001074 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001075 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1076 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1077 }
1078#endif
1079
1080#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001081 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001082 if (pAdapter->wapi_info.fIsWapiSta)
1083 {
1084 staDesc.ucIsWapiSta = 1;
1085 }
1086 else
1087 {
1088 staDesc.ucIsWapiSta = 0;
1089 }
1090#endif /* FEATURE_WLAN_WAPI */
1091
1092 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1093 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1094
Jeff Johnson295189b2012-06-20 16:38:30 -07001095 // UMA is Not ready yet, Xlation will be done by TL
1096 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 staDesc.ucSwFrameRXXlation = 1;
1098 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001099 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001100 staDesc.ucQosEnabled );
1101 // Initialize signatures and state
1102 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1103 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1104 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1105 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001106 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001107 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 -07001108 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1109 hdd_rx_packet_cbk,
1110 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001111 hdd_tx_fetch_packet_cbk, &staDesc,
1112 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001113
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1115 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001116 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001117 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001118 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001119 return vosStatus;
1120 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001121
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001122 if ( cfg_param->dynSplitscan &&
1123 ( VOS_TIMER_STATE_RUNNING !=
1124 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1125 {
1126 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1127 cfg_param->trafficMntrTmrForSplitScan);
1128 }
1129
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301130 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1131 // then go to 'authenticated'. For all other authentication types
1132 // (those that donot require upper layer authentication) we can put
1133 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001134 if (staDesc.wSTAType != WLAN_STA_IBSS)
1135 VOS_ASSERT( fConnected );
1136
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301137 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001138 {
1139 // Connections that do not need Upper layer auth, transition TL directly
1140 // to 'Authenticated' state.
1141 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1142 WLANTL_STA_AUTHENTICATED );
1143
1144 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1145 }
1146 else
1147 {
1148 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301149 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1150 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001151 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301152 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001153 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1154 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001155 return( vosStatus );
1156}
1157
Jeff Johnson295189b2012-06-20 16:38:30 -07001158static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1159 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1160{
1161 unsigned int len = 0;
1162 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001163 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001164 tANI_U32 rspRsnLength = 0;
1165 struct ieee80211_channel *chan;
1166
Agarwal Ashish51325b52014-06-16 16:50:49 +05301167 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001168 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001169 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001170 }
1171
Agarwal Ashish51325b52014-06-16 16:50:49 +05301172 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001173 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1174 goto done;
1175 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001176
Agarwal Ashish51325b52014-06-16 16:50:49 +05301177 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001178 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1179 goto done;
1180 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001181
1182 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1183 pCsrRoamInfo->nAssocReqLength);
1184 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001185 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001186
1187 //pFTAssocRsp needs to point to the IEs
1188 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001189 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001190 (unsigned int)pFTAssocRsp[0],
1191 (unsigned int)pFTAssocRsp[1]);
1192
1193 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001194 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001195 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001196 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001197 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001198
1199 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1200 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1201 reqRsnIe, reqRsnLength,
1202 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001203
1204done:
1205 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001206}
Jeff Johnson295189b2012-06-20 16:38:30 -07001207
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301208void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1209{
1210 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1211 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1212 tCsrRoamInfo roamInfo;
1213 roamInfo.fAuthRequired = FALSE;
1214 vos_mem_copy(roamInfo.bssid,
1215 pHddStaCtx->roam_info.bssid,
1216 WNI_CFG_BSSID_LEN);
1217 vos_mem_copy(roamInfo.peerMac,
1218 pHddStaCtx->roam_info.peerMac,
1219 WNI_CFG_BSSID_LEN);
1220
1221 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1222 &roamInfo,
1223 pHddStaCtx->roam_info.roamId,
1224 pHddStaCtx->roam_info.roamStatus,
1225 eCSR_ROAM_RESULT_AUTHENTICATED);
1226 if (halStatus != eHAL_STATUS_SUCCESS)
1227 {
1228 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1229 }
1230 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1231}
1232
Shailender Karmuchia734f332013-04-19 14:02:48 -07001233static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1234 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 eCsrRoamResult roamResult )
1236{
1237 struct net_device *dev = pAdapter->dev;
1238 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1239 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301240 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05301241 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001242 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1243 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001244#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001245 int ft_carrier_on = FALSE;
1246#endif
1247 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301248 v_BOOL_t hddDisconInProgress = FALSE;
1249
1250 /* HDD has initiated disconnect, do not send connect result indication
1251 * to kernel as it will be handled by __cfg80211_disconnect.
1252 */
1253 if(( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) &&
1254 (( eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
1255 ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)) )
1256 {
1257 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1258 FL(" Disconnect from HDD in progress "));
1259 hddDisconInProgress = TRUE;
1260 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001261
Jeff Johnson295189b2012-06-20 16:38:30 -07001262 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1263 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301264 if ( !hddDisconInProgress )
1265 {
1266 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05301267 "%s: Set HDD connState to eConnectionState_Associated",
1268 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301269 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1270 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001271
c_hpothu44ff4e02014-05-08 00:13:57 +05301272 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001273 // Save the connection info from CSR...
1274 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1275#ifdef FEATURE_WLAN_WAPI
1276 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1277 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1278 {
1279 pAdapter->wapi_info.fIsWapiSta = 1;
1280 }
1281 else
1282 {
1283 pAdapter->wapi_info.fIsWapiSta = 0;
1284 }
1285#endif /* FEATURE_WLAN_WAPI */
1286
1287 // indicate 'connect' status to userspace
1288 hdd_SendAssociationEvent(dev,pRoamInfo);
1289
1290
Shailender Karmuchia734f332013-04-19 14:02:48 -07001291 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001292 INIT_COMPLETION(pAdapter->linkup_event_var);
1293
1294 /*
1295 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1296 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 -07001297 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001298 know that the device is getting activated properly.
1299 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001300#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001301 if (pHddStaCtx->ft_carrier_on == FALSE)
1302 {
1303#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001304 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001305 pAdapter->isLinkUpSvcNeeded = TRUE;
1306
Shailender Karmuchia734f332013-04-19 14:02:48 -07001307 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001308 pAdapter->isLinkUpSvcNeeded = TRUE;
1309
1310 // Switch on the Carrier to activate the device
1311 netif_carrier_on(dev);
1312
1313 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1314 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1315 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001316 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001317 {
1318 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1319 }
1320
1321 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1322 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001323#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001324 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001325 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001326 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001327 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001328 }
1329#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05301330 /* Check for STAID */
1331 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
1332 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1333 else
1334 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001335
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001336#ifdef FEATURE_WLAN_TDLS
1337 wlan_hdd_tdls_connection_callback(pAdapter);
1338#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001339 //For reassoc, the station is already registered, all we need is to change the state
1340 //of the STA in TL.
1341 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05301342 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07001343 if( !pRoamInfo->fReassocReq )
1344 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001345 struct cfg80211_bss *bss;
1346#ifdef WLAN_FEATURE_VOWIFI_11R
1347 u8 *pFTAssocRsp = NULL;
1348 unsigned int assocRsplen = 0;
1349 u8 *pFTAssocReq = NULL;
1350 unsigned int assocReqlen = 0;
1351 struct ieee80211_channel *chan;
1352#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001353 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001354 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001355
1356 /* add bss_id to cfg80211 data base */
1357 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1358 if (NULL == bss)
1359 {
1360 pr_err("wlan: Not able to create BSS entry\n");
Katya Nigam346d4e92014-09-02 16:16:12 +05301361 netif_carrier_off(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001362 return eHAL_STATUS_FAILURE;
1363 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001364#ifdef WLAN_FEATURE_VOWIFI_11R
1365 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001366 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001367 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001368
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001369 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001370 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001371 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001372 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001373 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001374 // pFTAssocRsp needs to point to the IEs
1375 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1376 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1377 (unsigned int)pFTAssocRsp[0],
1378 (unsigned int)pFTAssocRsp[1]);
1379 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001380 }
1381 else
1382 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001383 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1384 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001385 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001386
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001387 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001388 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001389 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001390 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001391 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001392 if(!ft_carrier_on)
1393 {
1394 // pFTAssocReq needs to point to the IEs
1395 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1396 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1397 (unsigned int)pFTAssocReq[0],
1398 (unsigned int)pFTAssocReq[1]);
1399 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1400 }
1401 else
1402 {
1403 /* This should contain only the FTIEs */
1404 assocReqlen = pRoamInfo->nAssocReqLength;
1405 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001406 }
1407 else
1408 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001409 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1410 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001411 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001412
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001413 if(ft_carrier_on)
1414 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301415 if ( !hddDisconInProgress )
1416 {
1417 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001418 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301419 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001420 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301421 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001422 assocRsplen);
Girish Gowlidf0ed732014-08-11 12:39:39 +05301423#ifdef DEBUG_ROAM_DELAY
1424 //HACK we are using the buff len as Auth Type
1425 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1426#endif
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301427 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001428 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1429 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301430 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301431 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1432 {
1433 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1434 pRoamInfo->fAuthRequired = FALSE;
1435
1436 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1437 pRoamInfo->bssid,
1438 HDD_MAC_ADDR_LEN);
1439 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1440 pRoamInfo->peerMac,
1441 HDD_MAC_ADDR_LEN);
1442 pHddStaCtx->roam_info.roamId = roamId;
1443 pHddStaCtx->roam_info.roamStatus = roamStatus;
1444 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1445 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001446 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301447 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001448 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001449 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001450 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001451 cfg80211_connect_result(dev, pRoamInfo->bssid,
1452 pFTAssocReq, assocReqlen,
1453 pFTAssocRsp, assocRsplen,
1454 WLAN_STATUS_SUCCESS,
1455 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001456 }
1457 }
1458 else
1459#endif
1460 {
1461 /* wpa supplicant expecting WPA/RSN IE in connect result */
1462 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1463 pAdapter->sessionId,
1464 &reqRsnLength,
1465 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001466
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001467 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1468 pAdapter->sessionId,
1469 &rspRsnLength,
1470 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301471 if ( !hddDisconInProgress )
1472 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001473#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301474 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05301475 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301476 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Mukul Sharma84f27252014-07-14 18:11:42 +05301477#ifdef DEBUG_ROAM_DELAY
1478 //HACK we are using the buff len as Auth Type
1479 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1480#endif
1481 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301482 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001483#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001484
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301485 {
1486 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301487 "%s: sending connect indication to nl80211:"
1488 " for bssid " MAC_ADDRESS_STR
1489 " reason:%d and Status:%d\n",
1490 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1491 roamResult, roamStatus);
1492
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301493 /* inform connect result to nl80211 */
1494 cfg80211_connect_result(dev, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001495 reqRsnIe, reqRsnLength,
1496 rspRsnIe, rspRsnLength,
1497 WLAN_STATUS_SUCCESS,
1498 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301499 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001500 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001501 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301502 if ( !hddDisconInProgress )
1503 {
1504 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07001505#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301506 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07001507#endif
1508 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301509 // Register the Station with TL after associated...
1510 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001511 pRoamInfo,
1512 pHddStaCtx->conn_info.staId[ 0 ],
1513 NULL,
1514 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301515 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001516 }
1517 else
1518 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001519 /* wpa supplicant expecting WPA/RSN IE in connect result */
1520 /* in case of reassociation also need to indicate it to supplicant */
1521 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1522 pAdapter->sessionId,
1523 &reqRsnLength,
1524 reqRsnIe);
1525
1526 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001527 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301528 if( pRoamInfo->fAuthRequired )
1529 {
1530 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1531 pHddStaCtx->conn_info.staId[ 0 ],
1532 WLANTL_STA_CONNECTED );
1533 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1534 }
1535 else
1536 {
1537 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1538 "%s: staId: %d Changing TL state to AUTHENTICATED",
1539 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1540 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1541 pHddStaCtx->conn_info.staId[ 0 ],
1542 WLANTL_STA_AUTHENTICATED );
1543 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1544 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001545 }
1546
1547 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1548 {
1549 // perform any WMM-related association processing
1550 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1551 }
1552 else
1553 {
1554 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001555 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001556 vosStatus, vosStatus );
1557 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001558#ifdef WLAN_FEATURE_11W
1559 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1560 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1561#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001562 // Start the Queue
1563 netif_tx_wake_all_queues(dev);
Mukul Sharma84f27252014-07-14 18:11:42 +05301564#ifdef DEBUG_ROAM_DELAY
1565 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
1566#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001567 }
1568 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001569 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001570 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1571
1572 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001573 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001574 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1575 " reason:%d and Status:%d\n",
1576 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1577 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001578 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001579 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1580 " reason:%d and Status:%d\n",
1581 MAC_ADDR_ARRAY(pWextState->req_bssId),
1582 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001583
Abhishek Singhf4669da2014-05-26 15:07:49 +05301584 /* Set connection state to eConnectionState_NotConnected only when CSR
1585 * has completed operation - with a ASSOCIATION_FAILURE status
1586 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301587 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05301588 {
1589 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1590 "%s: Set HDD connState to eConnectionState_NotConnected",
1591 __func__);
1592 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1593 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05301594 if((pHddCtx->concurrency_mode <= 1) &&
1595 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07001596 {
1597 pHddCtx->isAmpAllowed = VOS_TRUE;
1598 }
1599
1600 //If the Device Mode is Station
1601 // and the P2P Client is Connected
1602 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001603
1604 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001605 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001606 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1607 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05301608 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 {
1610 //Enable BMPS only of other Session is P2P Client
1611 hdd_context_t *pHddCtx = NULL;
1612 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1613
1614 if (NULL != pVosContext)
1615 {
1616 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1617
1618 if(NULL != pHddCtx)
1619 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301620 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301621 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1622 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301623 {
1624 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001625 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301626 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001627 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301628 hdd_enable_bmps_imps(pHddCtx);
1629 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 }
1631 }
1632 }
1633
James Zmudafbf5ffc2013-03-25 12:45:35 -07001634 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001635 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301636 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07001637 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301638 if (pRoamInfo)
1639 hddLog(VOS_TRACE_LEVEL_ERROR,
1640 "%s: send connect failure to nl80211:"
1641 " for bssid " MAC_ADDRESS_STR
1642 " reason:%d and Status:%d\n" ,
1643 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1644 roamResult, roamStatus);
1645 else
1646 hddLog(VOS_TRACE_LEVEL_ERROR,
1647 "%s: connect failed:"
1648 " for bssid " MAC_ADDRESS_STR
1649 " reason:%d and Status:%d\n" ,
1650 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
1651 roamResult, roamStatus);
1652
c_hpothudaa90e22014-06-24 17:23:43 +05301653 /*Clear the roam profile*/
1654 hdd_clearRoamProfileIe( pAdapter );
1655
James Zmudafbf5ffc2013-03-25 12:45:35 -07001656 /* inform association failure event to nl80211 */
1657 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1658 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001659 if (pRoamInfo)
1660 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1661 NULL, 0, NULL, 0,
1662 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1663 GFP_KERNEL );
1664 else
1665 cfg80211_connect_result ( dev, pWextState->req_bssId,
1666 NULL, 0, NULL, 0,
1667 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1668 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001669 }
1670 else
1671 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001672 if (pRoamInfo)
1673 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1674 NULL, 0, NULL, 0,
1675 WLAN_STATUS_UNSPECIFIED_FAILURE,
1676 GFP_KERNEL );
1677 else
1678 cfg80211_connect_result ( dev, pWextState->req_bssId,
1679 NULL, 0, NULL, 0,
1680 WLAN_STATUS_UNSPECIFIED_FAILURE,
1681 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001682 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001683 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001684
Kumar Anand82c009f2014-05-29 00:29:42 -07001685 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001686
c_hpothu24f40982014-04-18 18:00:36 +05301687 if (pRoamInfo)
1688 {
1689 WLANTL_AssocFailed(pRoamInfo->staId);
1690 }
Mihir Sheteb7337272014-04-11 15:53:08 +05301691
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 netif_tx_disable(dev);
1693 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001694
Jeff Johnson295189b2012-06-20 16:38:30 -07001695 }
1696
Sushant Kaushikbf584e92014-08-06 17:59:20 +05301697 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301698 {
1699 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
1700 if (pHostapdAdapter != NULL)
1701 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05301702 /* Restart SAP if its operating channel is different
1703 * from AP channel.
1704 */
1705 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
1706 (int)pRoamInfo->pBssDesc->channelId)
1707 {
1708 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
1709 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
1710 (int)pRoamInfo->pBssDesc->channelId);
1711 hdd_restart_softap(pHddCtx, pHostapdAdapter);
1712 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301713 }
1714 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 return eHAL_STATUS_SUCCESS;
1716}
1717
1718/**============================================================================
1719 *
Jeff Johnson81c17882013-05-03 09:53:35 -07001720 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07001721 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07001722
Jeff Johnson295189b2012-06-20 16:38:30 -07001723 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07001724static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
1725 tCsrRoamInfo *pRoamInfo,
1726 tANI_U32 roamId,
1727 eRoamCmdStatus roamStatus,
1728 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07001729{
Jeff Johnson81c17882013-05-03 09:53:35 -07001730 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
1731 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
1732
Jeff Johnson295189b2012-06-20 16:38:30 -07001733 switch( roamResult )
1734 {
1735 // both IBSS Started and IBSS Join should come in here.
1736 case eCSR_ROAM_RESULT_IBSS_STARTED:
1737 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001738 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001740 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1741 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001742
Jeff Johnson81c17882013-05-03 09:53:35 -07001743 if (NULL == pRoamInfo)
1744 {
1745 VOS_ASSERT(0);
1746 return;
1747 }
1748
1749 /* When IBSS Started comes from CSR, we need to move
1750 * connection state to IBSS Disconnected (meaning no peers
1751 * are in the IBSS).
1752 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05301753 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1754 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
1755 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07001756 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
1757 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05301758 /*notify wmm */
1759 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001760 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1761 hdd_roamRegisterSTA (pAdapter, pRoamInfo,
1762 IBSS_BROADCAST_STAID,
1763 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001764
Jeff Johnson81c17882013-05-03 09:53:35 -07001765 if (pRoamInfo->pBssDesc)
1766 {
1767 struct cfg80211_bss *bss;
1768
1769 /* we created the IBSS, notify supplicant */
1770 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
1771 MAC_ADDRESS_STR,
1772 __func__, pAdapter->dev->name,
1773 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
1774
1775 /* we must first give cfg80211 the BSS information */
1776 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1777 if (NULL == bss)
1778 {
1779 hddLog(VOS_TRACE_LEVEL_ERROR,
1780 "%s: %s: unable to create IBSS entry",
1781 __func__, pAdapter->dev->name);
1782 return;
1783 }
1784
1785 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07001786 cfg80211_put_bss(
1787#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1788 pHddCtx->wiphy,
1789#endif
1790 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07001791 }
1792
Jeff Johnson295189b2012-06-20 16:38:30 -07001793 break;
1794 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001795
Jeff Johnson295189b2012-06-20 16:38:30 -07001796 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
1797 {
Jeff Johnson81c17882013-05-03 09:53:35 -07001798 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
1799 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07001800 break;
1801 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001802
Jeff Johnson295189b2012-06-20 16:38:30 -07001803 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07001804 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
1805 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001806 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001807 }
1808
Jeff Johnson81c17882013-05-03 09:53:35 -07001809 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001810}
1811
1812/**============================================================================
1813 *
1814 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
1815 This information is passed to iwconfig later. The peer that joined
1816 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001817 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001818 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001819
Jeff Johnson295189b2012-06-20 16:38:30 -07001820 ===========================================================================*/
1821static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
1822{
1823 int fSuccess = FALSE;
1824 int idx = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001825
Jeff Johnson295189b2012-06-20 16:38:30 -07001826 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1827 {
1828 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
1829 {
1830 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001831
Jeff Johnson295189b2012-06-20 16:38:30 -07001832 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001833
Jeff Johnson295189b2012-06-20 16:38:30 -07001834 fSuccess = TRUE;
1835 break;
1836 }
1837 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001838
1839 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07001840}
1841/**============================================================================
1842 *
1843 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001844 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001846
Jeff Johnson295189b2012-06-20 16:38:30 -07001847 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07001848static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07001849{
1850 int fSuccess = FALSE;
1851 int idx = 0;
1852 v_U8_t valid_idx = 0;
1853 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07001854 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001855 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001856
Jeff Johnson295189b2012-06-20 16:38:30 -07001857 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1858 {
1859 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
1860 {
1861 pHddStaCtx->conn_info.staId[ idx ] = 0;
1862
1863 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
1864
1865 fSuccess = TRUE;
Ravi Joshi8a934352013-09-25 16:46:58 -07001866
Jeff Johnson295189b2012-06-20 16:38:30 -07001867 // Note the deleted Index, if its 0 we need special handling
1868 del_idx = idx;
Ravi Joshi8a934352013-09-25 16:46:58 -07001869
1870 empty_slots++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 }
1872 else
1873 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001874 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 {
1876 valid_idx = idx;
1877 }
Ravi Joshi8a934352013-09-25 16:46:58 -07001878 else
1879 {
1880 // Found an empty slot
1881 empty_slots++;
1882 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001883 }
1884 }
1885
Ravi Joshi8a934352013-09-25 16:46:58 -07001886 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
1887 {
1888 // Last peer departed, set the IBSS state appropriately
1889 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001890 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07001891 "Last IBSS Peer Departed!!!" );
1892 }
1893
Jeff Johnson295189b2012-06-20 16:38:30 -07001894 // Find next active staId, to have a valid sta trigger for TL.
1895 if (fSuccess == TRUE)
1896 {
1897 if (del_idx == 0)
1898 {
1899 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
1900 {
1901 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
1902 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
1903 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
1904
1905 pHddStaCtx->conn_info.staId[valid_idx] = 0;
1906 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
1907 }
1908 }
1909 }
1910 return( fSuccess );
1911}
1912
1913/**============================================================================
1914 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001915 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001917
Jeff Johnson295189b2012-06-20 16:38:30 -07001918 ===========================================================================*/
1919static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
1920{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001921 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05301922 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1923 "%s: IBSS Connect Indication from SME!!! "
1924 "Set HDD connState to eConnectionState_IbssConnected",
1925 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001926 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
1927 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
1928
1929 // Save the connection info from CSR...
1930 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
1931
1932 // Send the bssid address to the wext.
1933 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001934 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001935 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1936 if (NULL == bss)
1937 {
1938 hddLog(VOS_TRACE_LEVEL_ERROR,
1939 "%s: %s: unable to create IBSS entry",
1940 __func__, pAdapter->dev->name);
1941 return eHAL_STATUS_FAILURE;
1942 }
Yue Maf49ba872013-08-19 12:04:25 -07001943 cfg80211_put_bss(
1944#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1945 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
1946#endif
1947 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001948
1949 return( eHAL_STATUS_SUCCESS );
1950}
1951/**============================================================================
1952 *
Mukul Sharmad2589a52014-04-23 21:06:25 +05301953 @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
1954 suspend related data which was cleared during roaming in FWR.
1955
1956 ===========================================================================*/
1957static void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
1958{
1959 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
1960 hdd_adapter_t *pAdapter;
1961 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
1962 ENTER();
1963
1964 spin_lock(&pHddCtx->filter_lock);
1965 if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
1966 {
1967 pHddCtx->sus_res_mcastbcast_filter =
1968 pHddCtx->configuredMcastBcastFilter;
1969 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
1970 hddLog(VOS_TRACE_LEVEL_INFO, FL("offload: callback to associated"));
1971 hddLog(VOS_TRACE_LEVEL_INFO,
1972 FL("saving configuredMcastBcastFilter = %d"),
1973 pHddCtx->configuredMcastBcastFilter);
1974 hddLog(VOS_TRACE_LEVEL_INFO,
1975 FL("offload: calling hdd_conf_mcastbcast_filter"));
1976 }
1977 spin_unlock(&pHddCtx->filter_lock);
1978
1979 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
1980 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
1981 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
1982
1983 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
1984 //No need to configure GTK Offload from here because it might possible
1985 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
1986 //be handled as part of cfg80211_set_rekey_data processing.
1987 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
1988 {
1989 pAdapter = pAdapterNode->pAdapter;
1990 if( pAdapter &&
1991 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1992 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
1993 {
1994 if (pHddCtx->cfg_ini->fhostArpOffload)
1995 {
1996 //Configure ARPOFFLOAD
1997 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
1998 if (!VOS_IS_STATUS_SUCCESS(vstatus))
1999 {
2000 hddLog(VOS_TRACE_LEVEL_ERROR,
2001 FL("Failed to disable ARPOffload Feature %d"), vstatus);
2002 }
2003 }
2004#ifdef WLAN_NS_OFFLOAD
2005 //Configure NSOFFLOAD
2006 if (pHddCtx->cfg_ini->fhostNSOffload)
2007 {
2008 hdd_conf_ns_offload(pAdapter, TRUE);
2009 }
2010#endif
Mukul Sharma25e70c32014-05-22 12:50:24 +05302011#ifdef WLAN_FEATURE_PACKET_FILTERING
2012 /* During suspend, configure MC Addr list filter to the firmware
2013 * function takes care of checking necessary conditions before
2014 * configuring.
2015 */
2016 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
2017#endif
Mukul Sharmad2589a52014-04-23 21:06:25 +05302018 }
2019 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2020 pAdapterNode = pNext;
2021 }
2022 EXIT();
2023}
2024
2025/**============================================================================
2026 *
Jeff Johnson295189b2012-06-20 16:38:30 -07002027 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002028
Jeff Johnson295189b2012-06-20 16:38:30 -07002029 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002030static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2031 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002032 eCsrRoamResult roamResult )
2033{
2034 eCsrEncryptionType connectedCipherAlgo;
2035 v_BOOL_t fConnected = FALSE;
2036 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2037 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2038 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2039 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07002040
2041 if (NULL == pRoamInfo)
2042 {
2043 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
2044 return eHAL_STATUS_FAILURE;
2045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002047 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07002048 // not require upper layer authentication) we can put TL directly into 'authenticated'
2049 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002050 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2051 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
2052 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002053
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2055 if( fConnected )
2056 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002057 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
2058 {
2059 v_U8_t staId;
2060
2061 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2062
2063 if ( 0 == memcmp( pRoamInfo->peerMac,
2064 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
2065 {
2066 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2067 IBSS_BROADCAST_STAID);
2068 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2069 }
2070 else
2071 {
2072 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
2073 (v_MACADDR_t*)pRoamInfo->peerMac,
2074 &staId);
2075 if ( VOS_STATUS_SUCCESS == vosStatus )
2076 {
2077 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2078 "WLAN TL STA Ptk Installed for STAID=%d", staId);
2079 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2080 staId);
2081 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2082 }
2083 }
2084 }
2085 else
2086 {
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302087 // TODO: Considering getting a state machine in HDD later.
2088 // This routine is invoked twice. 1)set PTK 2)set GTK.
2089 // The folloing if statement will be TRUE when setting GTK.
2090 // At this time we don't handle the state in detail.
2091 // Related CR: 174048 - TL not in authenticated state
2092 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
2093 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
2094 {
2095 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
2096 "for StaId= %d. Changing TL state to AUTHENTICATED",
2097 pHddStaCtx->conn_info.staId[ 0 ] );
2098
2099 // Connections that do not need Upper layer authentication,
2100 // transition TL to 'Authenticated' state after the keys are set.
2101 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2102 pHddStaCtx->conn_info.staId[ 0 ],
2103 WLANTL_STA_AUTHENTICATED );
2104
2105 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Mukul Sharmad2589a52014-04-23 21:06:25 +05302106 //Need to call offload because when roaming happen at that time fwr
2107 //clean offload info as part of the DelBss
2108 // No need to configure offload if host was not suspended
2109 spin_lock(&pHddCtx->filter_lock);
2110 if(pHddCtx->hdd_wlan_suspended)
2111 {
2112 spin_unlock(&pHddCtx->filter_lock);
2113 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
2114 }
2115 else
2116 {
2117 spin_unlock(&pHddCtx->filter_lock);
2118 }
Mukul Sharma84f27252014-07-14 18:11:42 +05302119#ifdef DEBUG_ROAM_DELAY
2120 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
2121#endif
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302122 }
2123 else
2124 {
2125 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2126 pHddStaCtx->conn_info.staId[ 0 ]);
Mukul Sharma84f27252014-07-14 18:11:42 +05302127#ifdef DEBUG_ROAM_DELAY
2128 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
2129#endif
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302130 }
2131
2132 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002133 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002134 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302135 else
2136 {
2137 // possible disassoc after issuing set key and waiting set key complete
2138 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2139 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002140
Jeff Johnson295189b2012-06-20 16:38:30 -07002141 EXIT();
2142 return( eHAL_STATUS_SUCCESS );
2143}
2144/**============================================================================
2145 *
2146 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2147 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002148static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002149 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002150{
Jeff Johnson295189b2012-06-20 16:38:30 -07002151 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2152
2153 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2154 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2155 {
2156 struct iw_michaelmicfailure msg;
2157 union iwreq_data wreq;
2158 memset(&msg, '\0', sizeof(msg));
2159 msg.src_addr.sa_family = ARPHRD_ETHER;
2160 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002161 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2162 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002163
Jeff Johnson295189b2012-06-20 16:38:30 -07002164 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2165 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002166 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002167 msg.flags = IW_MICFAILURE_PAIRWISE;
2168 memset(&wreq, 0, sizeof(wreq));
2169 wreq.data.length = sizeof(msg);
2170 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002172 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002173 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2174 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2175 NL80211_KEYTYPE_GROUP :
2176 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002177 pRoamInfo->u.pMICFailureInfo->keyId,
2178 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002179 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002180
Jeff Johnson295189b2012-06-20 16:38:30 -07002181 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002182
Jeff Johnson295189b2012-06-20 16:38:30 -07002183 return( eHAL_STATUS_SUCCESS );
2184}
2185
2186/**============================================================================
2187 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002188 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002189 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002190
Jeff Johnson295189b2012-06-20 16:38:30 -07002191 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002192static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2193 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002194 eCsrRoamResult roamResult )
2195{
2196 VOS_STATUS vosStatus;
2197
2198 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2199 switch( roamResult )
2200 {
2201 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2202 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002203 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002204 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002205
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002206 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002207 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2208 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2209 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002211
Jeff Johnson295189b2012-06-20 16:38:30 -07002212 if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
2213 {
2214 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2215 "New IBSS peer but we already have the max we can handle. Can't register this one" );
2216 break;
2217 }
2218
2219 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2220
Shailender Karmuchia734f332013-04-19 14:02:48 -07002221 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2222 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2223 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2224
2225 // Register the Station with TL for the new peer.
Jeff Johnson295189b2012-06-20 16:38:30 -07002226 vosStatus = hdd_roamRegisterSTA( pAdapter,
2227 pRoamInfo,
2228 pRoamInfo->staId,
2229 (v_MACADDR_t *)pRoamInfo->peerMac,
2230 pRoamInfo->pBssDesc );
2231 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2232 {
2233 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002234 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002235 vosStatus, vosStatus );
2236 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002237 pHddStaCtx->ibss_sta_generation++;
2238 memset(&staInfo, 0, sizeof(staInfo));
2239 staInfo.filled = 0;
2240 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2241
2242 cfg80211_new_sta(pAdapter->dev,
2243 (const u8 *)pRoamInfo->peerMac,
2244 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002245
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002246 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2247 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2248 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2249 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2250 {
2251 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2252 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2253 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2254
2255 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002256 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002257 pHddStaCtx->ibss_enc_key.encType);
2258
2259 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2260 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2261
2262 if ( VOS_STATUS_SUCCESS != vosStatus )
2263 {
2264 hddLog(VOS_TRACE_LEVEL_ERROR,
2265 "%s: sme_RoamSetKey failed, returned %d",
2266 __func__, vosStatus);
2267 return VOS_STATUS_E_FAILURE;
2268 }
2269 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002270 netif_carrier_on(pAdapter->dev);
2271 netif_tx_start_all_queues(pAdapter->dev);
2272 break;
2273 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002274
Jeff Johnson295189b2012-06-20 16:38:30 -07002275 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2276 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002277
Jeff Johnson295189b2012-06-20 16:38:30 -07002278 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002279
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002281 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002282 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2283 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002284 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002285
Ravi Joshicc57ed42013-10-12 16:31:25 -07002286 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002287 {
2288 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2289 "IBSS peer departed by cannot find peer in our registration table with TL" );
2290 }
2291
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002292 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002293 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2294 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2295 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2296 pRoamInfo->staId );
2297
Jeff Johnson295189b2012-06-20 16:38:30 -07002298 hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
2299
2300 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002301 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002302
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002303 cfg80211_del_sta(pAdapter->dev,
2304 (const u8 *)&pRoamInfo->peerMac,
2305 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 break;
2307 }
2308 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2309 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002310 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2311 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 // Stop only when we are inactive
2313 netif_tx_disable(pAdapter->dev);
2314 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05302315 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2316 "%s: Set HDD connState to eConnectionState_NotConnected",
2317 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002318 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002319
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 // Send the bssid address to the wext.
2321 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2322 // clean up data path
2323 hdd_disconnect_tx_rx(pAdapter);
2324 break;
2325 }
2326 default:
2327 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002328
Jeff Johnson295189b2012-06-20 16:38:30 -07002329 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002330
Jeff Johnson295189b2012-06-20 16:38:30 -07002331 return( eHAL_STATUS_SUCCESS );
2332}
2333
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002334#ifdef FEATURE_WLAN_TDLS
2335/**============================================================================
2336 *
2337 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2338 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2339 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002340
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002341 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002342VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
2343 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002344{
2345 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002346 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002347 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2348 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002349 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2350 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002351 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2352 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002353
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002354 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2355 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002356 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002357 "%s not connected. ignored", __func__);
2358 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002359 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002360
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002361 /*
2362 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2363 * be peer MAC, here we are wokrking on direct Link
2364 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002365 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002366
2367 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002368
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002369 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002370 sizeof(tSirMacAddr) );
2371
2372 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2373 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2374
2375 /* set the QoS field appropriately ..*/
2376 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2377 : (staDesc.ucQosEnabled = 0) ;
2378
2379 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002380 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002381
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002382 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002383
2384 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002385 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002386
Shailender Karmuchia734f332013-04-19 14:02:48 -07002387 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002388 * UMA is ready we inform TL to do frame translation.
2389 */
2390 staDesc.ucSwFrameTXXlation = 1;
2391 staDesc.ucSwFrameRXXlation = 1;
2392 staDesc.ucAddRmvLLC = 1;
2393
2394 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002395 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002396
2397 /* tdls Direct Link do not need bcastSig */
2398 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002399
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002400#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2401 if(staDesc.ucProtectedFrame)
2402 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2403 else
2404 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2405#endif
2406
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302407 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002408
Shailender Karmuchia734f332013-04-19 14:02:48 -07002409 /* Register the Station with TL... */
2410 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2411 hdd_rx_packet_cbk,
2412 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002413 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002414
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002415 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2416 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002417 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002418 "%s: WLANTL_RegisterSTAClient() failed to register. "
2419 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002420 return vosStatus;
2421 }
2422
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002423 if ( cfg_param->dynSplitscan &&
2424 ( VOS_TIMER_STATE_RUNNING !=
2425 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2426 {
2427 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2428 cfg_param->trafficMntrTmrForSplitScan);
2429 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002430 return( vosStatus );
2431}
2432
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002433static VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
2434{
2435 VOS_STATUS vosStatus;
2436 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2437 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2438 {
2439 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2440 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002441 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002442 __func__, staId, vosStatus, vosStatus );
2443 }
2444 return( vosStatus );
2445}
2446
2447
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002448/*
2449 * HDD interface between SME and TL to ensure TDLS client registration with
2450 * TL in case of new TDLS client is added and deregistration at the time
2451 * TDLS client is deleted.
2452 */
2453
Shailender Karmuchia734f332013-04-19 14:02:48 -07002454eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2455 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002456 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002457 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002458 eCsrRoamResult roamResult)
2459{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002460 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002461 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002462 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002463
2464#ifdef WLAN_FEATURE_TDLS_DEBUG
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302465 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002466 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2467 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2468 "ADD_TDLS_PEER" :
2469 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2470 "DEL_TDLS_PEER" :
2471 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2472 "DEL_TDLS_PEER_IND" :
2473 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2474 "DEL_ALL_TDLS_PEER_IND" :
2475 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2476 "UPDATE_TDLS_PEER" :
2477 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2478 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2479 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002480#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002481 switch( roamResult )
2482 {
2483 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2484 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002485 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2486 {
2487 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002488 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002489 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002490 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002491 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002492
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002493 /* check if there is available index for this new TDLS STA */
2494 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2495 {
2496 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2497 {
2498 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2499 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2500
2501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002502 ("TDLS: STA IDX at %d is %d "
2503 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002504 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002505 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002506
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002507 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002508 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2509 status = eHAL_STATUS_SUCCESS ;
2510 break ;
2511 }
2512 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002513 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002514 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002515 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002516 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2517 "wlan_hdd_tdls_set_sta_id() failed");
2518 return VOS_FALSE;
2519 }
2520
2521 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302522 /* store the ucast signature , if required for further reference. */
2523
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002524 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302525 /* start TDLS client registration with TL */
2526 status = hdd_roamRegisterTDLSSTA( pAdapter,
2527 pRoamInfo->peerMac,
2528 pRoamInfo->staId,
2529 pRoamInfo->ucastSig);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002530 }
2531 else
2532 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002533 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002534 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002535 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002536 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002537 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002538 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002539 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002540 break ;
2541 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002542 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
2543 {
2544 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2545 {
2546 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2547 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
2548 }
2549 /* store the ucast signature which will be used later when
2550 * registering to TL
2551 */
2552 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
2553 complete(&pAdapter->tdls_add_station_comp);
2554 break;
2555 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302556 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
2557 {
2558 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2559 {
2560 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2561 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
2562 }
2563 complete(&pAdapter->tdls_link_establish_req_comp);
2564 break;
2565 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002566 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002567 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002568 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002569 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002570 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002571 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2572 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002573 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002575 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2576
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302577 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002578 if (NULL != curr_peer && TDLS_IS_CONNECTED(curr_peer))
2579 {
2580 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2581 wlan_hdd_tdls_decrement_peer_count(pAdapter);
2582 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002583 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002584
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002585 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2586 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
2587 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002588 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002589 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002590 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002591 break ;
2592 }
2593 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002594 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002595 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002596 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002597 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
2598 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002599 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002600 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2601 "%s: Sending teardown to supplicant with reason code %u",
2602 __func__, pRoamInfo->reasonCode);
2603
2604#ifdef CONFIG_TDLS_IMPLICIT
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302605 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002606 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002607#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002608 status = eHAL_STATUS_SUCCESS ;
2609 break ;
2610 }
2611 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
2612 {
2613 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002614 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002615 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002616 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2617 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002618 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002620 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002621 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002622 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002623 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
2624 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
2625 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002626
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002627 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002628 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002629 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2630 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002631
2632 status = eHAL_STATUS_SUCCESS ;
2633 }
2634 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05302635 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002636 break ;
2637 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002638 default:
2639 {
2640 break ;
2641 }
2642 }
2643
2644 return status ;
2645}
2646#endif
2647
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002648static void iw_full_power_cbfn (void *pContext, eHalStatus status)
2649{
2650 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
2651 hdd_context_t *pHddCtx = NULL;
2652 int ret;
2653
2654 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
2655 {
2656 hddLog(VOS_TRACE_LEVEL_ERROR,
2657 "%s: Bad param, pAdapter [%p]",
2658 __func__, pAdapter);
2659 return;
2660 }
2661
2662 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2663 ret = wlan_hdd_validate_context(pHddCtx);
2664 if (0 != ret)
2665 {
2666 hddLog(VOS_TRACE_LEVEL_ERROR,
2667 "%s: HDD context is not valid (%d)", __func__, ret);
2668 return;
2669 }
2670
2671 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2672 {
2673 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
2674 }
2675}
2676
Shailender Karmuchia734f332013-04-19 14:02:48 -07002677eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002678 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
2679{
2680 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2681 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302682 hdd_wext_state_t *pWextState = NULL;
2683 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002684 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07002685 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002686
2687 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002688 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002689 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002690
2691 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302692 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002693 {
2694 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302695 "invalid adapter or adapter has invalid magic");
2696 return eHAL_STATUS_FAILURE;
2697 }
2698
2699 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2700 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2701
2702 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2703 {
2704 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2705 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002706 return eHAL_STATUS_FAILURE;
2707 }
2708
Jeff Johnson295189b2012-06-20 16:38:30 -07002709 switch( roamStatus )
2710 {
2711 case eCSR_ROAM_SESSION_OPENED:
2712 if(pAdapter != NULL)
2713 {
2714 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2715 complete(&pAdapter->session_open_comp_var);
2716 }
2717 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002718
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002719#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
2720 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002721 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07002722 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 * interface down */
2724 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05302725 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
2726 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05302727 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07002728 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2729 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2730 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002731 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2732 }
2733 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05302734 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 break;
2736
2737 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002738 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07002739 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07002740 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07002741 // eCSR_ROAM_SHOULD_ROAM will be received.
2742 // Where in we will not mark the link down
2743 // Also we want to stop tx at this point when we will be
2744 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002745 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002746 {
2747 struct net_device *dev = pAdapter->dev;
2748 netif_tx_disable(dev);
Mukul Sharma84f27252014-07-14 18:11:42 +05302749#ifdef DEBUG_ROAM_DELAY
2750 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
2751#endif
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002752 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002753 * Deregister for this STA with TL with the objective to flush
2754 * all the packets for this STA from wmm_tx_queue. If not done here,
2755 * we would run into a race condition (CR390567) wherein TX
2756 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2757 * been deleted. And, these packets get assigned with a STA idx of
2758 * self-sta (since the peer STA has been deleted) and get transmitted
2759 * on the new channel before the reassoc request. Since there will be
2760 * no ACK on the new channel, each packet gets retransmitted which
2761 * takes several seconds before the transmission of reassoc request.
2762 * This leads to reassoc-timeout and roam failure.
2763 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002764 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2765 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2766 {
2767 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2768 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2769 pHddStaCtx->conn_info.staId[0], status, status );
2770 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002771 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002772 }
2773 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002774 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002775 break;
2776#endif
2777
2778 case eCSR_ROAM_SHOULD_ROAM:
2779 // Dont need to do anything
2780 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002781 struct net_device *dev = pAdapter->dev;
2782 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2783 // notify apps that we can't pass traffic anymore
2784 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002785#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 if (pHddStaCtx->ft_carrier_on == FALSE)
2787 {
2788#endif
2789 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002790#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 }
2792#endif
2793
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002794#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002795 //We should clear all sta register with TL, for now, only one.
2796 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2797 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2798 {
2799 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2800 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2801 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002802 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002803 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002804#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002805 }
2806 break;
2807 case eCSR_ROAM_LOSTLINK:
2808 case eCSR_ROAM_DISASSOCIATED:
2809 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002810 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2811 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05302812 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07002813 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2814 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07002815 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2816 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302817 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07002818 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08002819
2820 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
2821 pHddCtx->configuredMcastBcastFilter =
2822 pHddCtx->sus_res_mcastbcast_filter;
2823 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
2824 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302825
Amar Singhald53568e2013-09-26 11:03:45 -07002826 hddLog(VOS_TRACE_LEVEL_INFO,
2827 "offload: disassociation happening, restoring configuredMcastBcastFilter");
2828 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
2829 pHddCtx->configuredMcastBcastFilter);
2830 hddLog(VOS_TRACE_LEVEL_INFO,
2831 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07002832 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2833 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002834#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302835 /* Call to clear any MC Addr List filter applied after
2836 * successful connection.
2837 */
2838 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002839#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 }
2841 break;
2842 case eCSR_ROAM_IBSS_LEAVE:
2843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2844 "****eCSR_ROAM_IBSS_LEAVE****");
2845 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2846 break;
2847 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2848 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2849 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302850 // To Do - address probable memory leak with WEP encryption upon successful association
2851 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302853 //Clear saved connection information in HDD
2854 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302856 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002857
2858 break;
2859 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002860 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002861 pRoamInfo, roamId, roamStatus, roamResult );
2862 break;
2863 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07002864 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
2865 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 break;
2867
2868 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2869 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002870 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002871
2872 case eCSR_ROAM_MIC_ERROR_IND:
2873 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2874 break;
2875
2876 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002877 {
2878 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2879
2880 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002881 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
2882 (TRUE == pHddCtx->hdd_wlan_suspended) &&
2883 (eCSR_ROAM_RESULT_NONE == roamResult))
2884 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002885 /* Send DTIM period to the FW; only if the wlan is already
2886 in suspend. This is the case with roaming (reassoc),
2887 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
2888 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
2889 before the ENTER_BMPS_REQ ensures Listen Interval is
2890 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002891 hdd_set_pwrparams(pHddCtx);
2892 pHddStaCtx->hdd_ReassocScenario = VOS_FALSE;
2893
2894 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002895 if due to unexpected scenario, if we are in BMPS,
2896 then trigger Exit and Enter BMPS to take DTIM period
2897 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002898 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
2899 {
2900 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
2901
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002902 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2903 iw_full_power_cbfn, pAdapter,
2904 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002905 }
2906 }
2907 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05302908 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 break;
2911#ifdef WLAN_FEATURE_VOWIFI_11R
2912 case eCSR_ROAM_FT_RESPONSE:
2913 hdd_SendFTEvent(pAdapter);
2914 break;
2915#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002916#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002917 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002918 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07002919 {
2920 /* Notify the supplicant of a new candidate */
2921 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
2922 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002923 break;
2924#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002925
Yue Maef608272013-04-08 23:09:17 -07002926#ifdef FEATURE_WLAN_LFR_METRICS
2927 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
2928 /* This event is to notify pre-auth initiation */
2929 if (VOS_STATUS_SUCCESS !=
2930 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
2931 {
2932 halStatus = eHAL_STATUS_FAILURE;
2933 }
2934 break;
2935 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
2936 /* This event will notify pre-auth completion in case of success */
2937 if (VOS_STATUS_SUCCESS !=
2938 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2939 pRoamInfo, 1))
2940 {
2941 halStatus = eHAL_STATUS_FAILURE;
2942 }
2943 break;
2944 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
2945 /* This event will notify pre-auth completion in case of failure. */
2946 if (VOS_STATUS_SUCCESS !=
2947 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2948 pRoamInfo, 0))
2949 {
2950 halStatus = eHAL_STATUS_FAILURE;
2951 }
2952 break;
2953 case eCSR_ROAM_HANDOVER_SUCCESS:
2954 /* This event is to notify handover success.
2955 It will be only invoked on success */
2956 if (VOS_STATUS_SUCCESS !=
2957 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
2958 {
2959 halStatus = eHAL_STATUS_FAILURE;
2960 }
2961 break;
2962#endif
2963
Jeff Johnson295189b2012-06-20 16:38:30 -07002964 case eCSR_ROAM_INDICATE_MGMT_FRAME:
2965 hdd_indicateMgmtFrame( pAdapter,
2966 pRoamInfo->nFrameLength,
2967 pRoamInfo->pbFrames,
2968 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05302969 pRoamInfo->rxChan,
2970 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07002971 break;
2972 case eCSR_ROAM_REMAIN_CHAN_READY:
2973 hdd_remainChanReadyHandler( pAdapter );
2974 break;
2975 case eCSR_ROAM_SEND_ACTION_CNF:
2976 hdd_sendActionCnf( pAdapter,
2977 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
2978 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002979#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08002980 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002981 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08002982 roamId, roamStatus, roamResult );
2983 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002984 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
2985 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
2986 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002987#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002988#ifdef WLAN_FEATURE_11W
2989 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
2990 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
2991 pRoamInfo->pbFrames,
2992 pRoamInfo->frameType);
2993 break;
2994#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002995#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002996 case eCSR_ROAM_TSM_IE_IND:
2997 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
2998 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
2999 break;
3000
3001 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
3002 {
3003 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
3004 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
3005 {
3006 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
3007 }
3008 break;
3009 }
3010
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003011 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003012 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003013 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003014 break;
3015 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003016
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003017 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003018 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003019 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003020 break;
3021 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003022#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07003023 default:
3024 break;
3025 }
3026 return( halStatus );
3027}
Shailender Karmuchia734f332013-04-19 14:02:48 -07003028eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003029{
3030 eCsrAuthType auth_type;
3031 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003032 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003033 {
3034 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003035 } else
3036 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003037 {
3038 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003039 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003040#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003041 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003042 {
3043 // Check for 11r FT Authentication with PSK
3044 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003045 } else
3046 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003047 {
3048 // Check for 11R FT Authentication with 802.1X
3049 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003050 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003051#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003052#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003053 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 {
3055 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
3056 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003057#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07003058#ifdef WLAN_FEATURE_11W
3059 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
3060 {
3061 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3062 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303063 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
3064 {
3065 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3066 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003067#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003068 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003069 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3070 }
3071 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003072}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003073
Shailender Karmuchia734f332013-04-19 14:02:48 -07003074eCsrAuthType
3075hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003076{
3077 eCsrAuthType auth_type;
3078 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003079 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003080 {
3081 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003082 } else
3083 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003084 {
3085 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003086 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003087#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003088 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003089 {
3090 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003091 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003092#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003093 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003094 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3095 }
3096 hddLog(LOG1, FL("auth_type: %d"), auth_type);
3097 return auth_type;
3098}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003099
Shailender Karmuchia734f332013-04-19 14:02:48 -07003100eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003101hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003102{
3103 eCsrEncryptionType cipher_type;
3104 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003105 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003106 {
3107 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003108 }
3109 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003110 {
3111 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003112 }
3113 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 {
3115 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003116 }
3117 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003118 {
3119 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003120 }
3121 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
3122 {
3123 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3124 }
3125 else
3126 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003127 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3128 }
3129 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3130 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003131}
Jeff Johnson295189b2012-06-20 16:38:30 -07003132/* To find if the MAC address is NULL */
3133static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3134{
3135 int i;
3136 for (i = 0; i < length; i++)
3137 {
3138 if (0x00 != (macAddr[i]))
3139 {
3140 return FALSE;
3141 }
3142 }
3143 return TRUE;
3144} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003145
Shailender Karmuchia734f332013-04-19 14:02:48 -07003146eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003147hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003148{
3149 eCsrEncryptionType cipher_type;
3150 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003151 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 {
3153 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003154 } else
3155 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003156 {
3157 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003158 } else
3159 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003160 {
3161 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003162 } else
3163 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003164 {
3165 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003166 } else
3167 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003169 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3170 } else
3171 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003172 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3173 }
3174 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3175 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003176}
Jeff Johnson295189b2012-06-20 16:38:30 -07003177
Shailender Karmuchia734f332013-04-19 14:02:48 -07003178static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3179 struct ether_addr *pBssid,
3180 eCsrEncryptionType *pEncryptType,
3181 eCsrEncryptionType *mcEncryptType,
3182 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003183#ifdef WLAN_FEATURE_11W
3184 u_int8_t *pMfpRequired,
3185 u_int8_t *pMfpCapable,
3186#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003187 u_int16_t gen_ie_len,
3188 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003189{
3190 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003191 eHalStatus result;
3192 tDot11fIERSN dot11RSNIE;
3193 tDot11fIEWPA dot11WPAIE;
3194 tANI_U32 i;
3195 tANI_U8 *pRsnIe;
3196 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003197 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003198 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003199
3200 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3201 flag to 0 */
3202 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3203 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3204
3205 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003206 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
3207 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303208 {
3209 hddLog(LOGE, "%s: Invalid DOT11F IE Length passed :%d",
3210 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 return -EINVAL;
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303212 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003214 if ( gen_ie[0] == DOT11F_EID_RSN)
3215 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003216 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003217 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003218 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3219 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303220 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3221 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003222 return -EINVAL;
3223 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003224 // Skip past the EID byte and length byte
3225 pRsnIe = gen_ie + 2;
3226 RSNIeLen = gen_ie_len - 2;
3227 // Unpack the RSN IE
3228 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3229 pRsnIe,
3230 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003231 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003232 // Copy out the encryption and authentication types
3233 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003234 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003235 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003236 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003237 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003238 but probably I suspect we can do something different*/
3239 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003240 // Just translate the FIRST one
3241 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3242 //dot11RSNIE.pwise_cipher_suite_count
3243 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3244 //dot11RSNIE.gp_cipher_suite_count
3245 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003246#ifdef WLAN_FEATURE_11W
3247 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3248 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3249#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003250 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003251 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003252 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003253 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003254 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303255 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 break;
3257 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003258 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303260 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 break;
3262 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003263 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003264 // For right now, I assume setASSOCIATE() has passed in the bssid.
3265 vos_mem_copy(PMKIDCache[i].BSSID,
3266 pBssid, ETHER_ADDR_LEN);
3267 vos_mem_copy(PMKIDCache[i].PMKID,
3268 dot11RSNIE.pmkid[i],
3269 CSR_RSN_PMKID_SIZE);
3270 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003271
3272 if (updatePMKCache)
3273 {
3274 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003275 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003276 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003277 // Finally set the PMKSA ID Cache in CSR
3278 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3279 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05303280 dot11RSNIE.pmkid_count,
3281 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07003282 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003283 }
3284 else if (gen_ie[0] == DOT11F_EID_WPA)
3285 {
3286 // Validity checks
3287 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3288 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3289 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303290 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3291 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003292 return -EINVAL;
3293 }
3294 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003295 pRsnIe = gen_ie + 2 + 4;
3296 RSNIeLen = gen_ie_len - (2 + 4);
3297 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003298 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3299 pRsnIe,
3300 RSNIeLen,
3301 &dot11WPAIE);
3302 // Copy out the encryption and authentication types
3303 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003304 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003305 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003306 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003307 //dot11WPAIE.auth_suite_count
3308 // Just translate the FIRST one
3309 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3310 //dot11WPAIE.unicast_cipher_count
3311 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3312 //dot11WPAIE.unicast_cipher_count
3313 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3314 }
3315 else
3316 {
3317 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003318 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003319 }
3320 return 0;
3321}
3322int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3323{
3324 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3325 v_U32_t status = 0;
3326 eCsrEncryptionType RSNEncryptType;
3327 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003328#ifdef WLAN_FEATURE_11W
3329 u_int8_t RSNMfpRequired;
3330 u_int8_t RSNMfpCapable;
3331#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003332 struct ether_addr bSsid; // MAC address of assoc peer
3333 // MAC address of assoc peer
3334 // But, this routine is only called when we are NOT associated.
3335 vos_mem_copy(bSsid.ether_addr_octet,
3336 pWextState->roamProfile.BSSIDs.bssid,
3337 sizeof(bSsid.ether_addr_octet));
3338 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3339 {
3340 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003341 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003342 else
3343 {
3344 return 0;
3345 }
3346 // The actual processing may eventually be more extensive than this.
3347 // Right now, just consume any PMKIDs that are sent in by the app.
3348 status = hdd_ProcessGENIE(pAdapter,
3349 &bSsid, // MAC address of assoc peer
3350 &RSNEncryptType,
3351 &mcRSNEncryptType,
3352 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003353#ifdef WLAN_FEATURE_11W
3354 &RSNMfpRequired,
3355 &RSNMfpCapable,
3356#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 pWextState->WPARSNIE[1]+2,
3358 pWextState->WPARSNIE);
3359 if (status == 0)
3360 {
3361 // Now copy over all the security attributes you have parsed out
3362 pWextState->roamProfile.EncryptionType.numEntries = 1;
3363 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003364
Jeff Johnson295189b2012-06-20 16:38:30 -07003365 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3366 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003367
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003368 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3369 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3370 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3371 {
3372 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3373 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3374 either AES/TKIP based on group cipher configuration
3375 mentioned in the wpa_supplicant.conf.*/
3376
3377 /*Set the unicast cipher same as multicast cipher*/
3378 pWextState->roamProfile.EncryptionType.encryptionType[0]
3379 = mcRSNEncryptType;
3380 }
3381
Chet Lanctot186b5732013-03-18 10:26:30 -07003382#ifdef WLAN_FEATURE_11W
3383 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3384 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3385#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003386 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 }
3388 return 0;
3389}
3390int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3391{
3392 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3393 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3394 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3395 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003396
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003398 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003399
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 switch( pHddStaCtx->conn_info.authType)
3401 {
3402 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003403#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 case eCSR_AUTH_TYPE_CCKM_WPA:
3405 case eCSR_AUTH_TYPE_CCKM_RSN:
3406#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003407 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3408
Jeff Johnson295189b2012-06-20 16:38:30 -07003409 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003410 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003412
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003413#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003414 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3415 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3416 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003417 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003418 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3419 } else
3420 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003421 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003422 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003423 } else
3424#endif
3425 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3426 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003427 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3428 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003429 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3430 == IW_AUTH_KEY_MGMT_PSK) {
3431 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003432 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003434 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003435 }
3436 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003437#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003438 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3439 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3440 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003441 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003442 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003443 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003444 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003445 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003446 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003447 } else
3448#endif
3449
3450#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003451 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3452 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003453 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003454 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003455 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003456 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3458 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003459 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 } else
3461#endif
3462
Chet Lanctot186b5732013-03-18 10:26:30 -07003463#ifdef WLAN_FEATURE_11W
3464 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3465 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3466 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303467 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
3468 pRoamProfile->AuthType.authType[0] =
3469 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3470 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003471#endif
3472
Shailender Karmuchia734f332013-04-19 14:02:48 -07003473 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003475 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3476 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003477 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3478 == IW_AUTH_KEY_MGMT_PSK) {
3479 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003480 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003481 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003483 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003484 break;
3485
Jeff Johnson295189b2012-06-20 16:38:30 -07003486 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003487
3488 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 break;
3490 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003491
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003492#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08003493 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003494#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003495 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3496 break;
3497 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003498
Jeff Johnson295189b2012-06-20 16:38:30 -07003499 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003500 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003501
Jeff Johnson295189b2012-06-20 16:38:30 -07003502 EXIT();
3503 return 0;
3504}
3505
3506/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003507
3508 \brief iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003509 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07003510 to the CSR roam profile.
3511
Jeff Johnson295189b2012-06-20 16:38:30 -07003512 \param - dev - Pointer to the net device.
3513 - info - Pointer to the iw_request_info.
3514 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003515 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003516 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003517
Jeff Johnson295189b2012-06-20 16:38:30 -07003518 --------------------------------------------------------------------------*/
3519
Shailender Karmuchia734f332013-04-19 14:02:48 -07003520int iw_set_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003521 struct iw_request_info *info,
3522 union iwreq_data *wrqu, char *extra)
3523{
3524 v_U32_t status = 0;
3525 hdd_wext_state_t *pWextState;
3526 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3527 v_U32_t roamId;
3528 tCsrRoamProfile *pRoamProfile;
3529 eMib_dot11DesiredBssType connectedBssType;
3530 eCsrAuthType RSNAuthType;
3531 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3532 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003533
3534 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3535
Jeff Johnson295189b2012-06-20 16:38:30 -07003536 ENTER();
3537
3538 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3539 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303540 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 "%s:LOGP in Progress. Ignore!!!",__func__);
3542 return 0;
3543 }
3544
3545 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
3546 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
3547 return -EBUSY;
3548 }
3549 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
3550 return -EINVAL;
3551 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003552 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 {
3554 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
3555 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
3556 {
3557 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003558 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07003559 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3560 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
3561
3562 if(VOS_STATUS_SUCCESS == vosStatus)
3563 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3564 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3565 }
3566 }
3567 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003568 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003569 {
3570 return -EINVAL;
3571 }
3572 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003573 /** when cfg80211 defined, wpa_supplicant wext driver uses
3574 zero-length, null-string ssid for force disconnection.
3575 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07003576 driver MUST return success */
3577 if ( 0 == wrqu->essid.length ) {
3578 return 0;
3579 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003580
3581 status = hdd_wmm_get_uapsd_mask(pAdapter,
3582 &pWextState->roamProfile.uapsd_mask);
3583 if (VOS_STATUS_SUCCESS != status)
3584 {
3585 pWextState->roamProfile.uapsd_mask = 0;
3586 }
3587 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003588
Jeff Johnson295189b2012-06-20 16:38:30 -07003589 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003590
3591 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003592 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
3593 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
3594 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003595
Jeff Johnson295189b2012-06-20 16:38:30 -07003596 //set gen ie
3597 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
3598
3599 //set auth
3600 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
3601 }
3602#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003603 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 if (pAdapter->wapi_info.nWapiMode)
3605 {
3606 switch (pAdapter->wapi_info.wapiAuthMode)
3607 {
3608 case WAPI_AUTH_MODE_PSK:
3609 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003610 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003611 pRoamProfile->AuthType.numEntries = 1;
3612 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3613 break;
3614 }
3615 case WAPI_AUTH_MODE_CERT:
3616 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003617 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 pRoamProfile->AuthType.numEntries = 1;
3619 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3620 break;
3621 }
3622 } // End of switch
3623 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
3624 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
3625 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003626 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003627 pRoamProfile->EncryptionType.numEntries = 1;
3628 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3629 pRoamProfile->mcEncryptionType.numEntries = 1;
3630 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3631 }
3632 }
3633#endif /* FEATURE_WLAN_WAPI */
3634 /* if previous genIE is not NULL, update AssocIE */
3635 if (0 != pWextState->genIE.length)
3636 {
3637 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
3638 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
3639 pWextState->genIE.length);
3640 pWextState->assocAddIE.length = pWextState->genIE.length;
3641 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
3642 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
3643
3644 /* clear previous genIE after use it */
3645 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
3646 }
3647
3648 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
3649 pWextState->roamProfile.bWPSAssociation = FALSE;
3650
3651 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
3652 pWextState->roamProfile.nAddIEAssocLength))
3653 pWextState->roamProfile.bWPSAssociation = TRUE;
3654
3655
3656 // Disable auto BMPS entry by PMC until DHCP is done
3657 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
3658
Shailender Karmuchia734f332013-04-19 14:02:48 -07003659 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003660 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003661
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003662 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
3663 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003664 hdd_select_cbmode(pAdapter,
3665 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
3666 }
3667 status = sme_RoamConnect( hHal,pAdapter->sessionId,
3668 &(pWextState->roamProfile), &roamId);
3669 pRoamProfile->ChannelInfo.ChannelList = NULL;
3670 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003671
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003672 EXIT();
3673 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003674}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003675
Jeff Johnson295189b2012-06-20 16:38:30 -07003676/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003677
3678 \brief iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003679 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003680
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 \param - dev - Pointer to the net device.
3682 - info - Pointer to the iw_request_info.
3683 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003684 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003685 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003686
Jeff Johnson295189b2012-06-20 16:38:30 -07003687 --------------------------------------------------------------------------*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003688int iw_get_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003689 struct iw_request_info *info,
3690 struct iw_point *dwrq, char *extra)
3691{
3692 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003693 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003694 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3695 ENTER();
3696
3697 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
3698 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
3699 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
3700 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
3701 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
3702 {
3703 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
3704 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
3705 dwrq->flags = 1;
3706 } else {
3707 memset(extra, 0, dwrq->length);
3708 dwrq->length = 0;
3709 dwrq->flags = 0;
3710 }
3711 EXIT();
3712 return 0;
3713}
3714/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003715
3716 \brief iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003717 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003718
Jeff Johnson295189b2012-06-20 16:38:30 -07003719 \param - dev - Pointer to the net device.
3720 - info - Pointer to the iw_request_info.
3721 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003722 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003723 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003724
Jeff Johnson295189b2012-06-20 16:38:30 -07003725 --------------------------------------------------------------------------*/
3726int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
3727 union iwreq_data *wrqu,char *extra)
3728{
3729 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003730 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003731 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3732 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003733 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 eCsrEncryptionType ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003735
Jeff Johnson295189b2012-06-20 16:38:30 -07003736 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003737
3738 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3739 {
3740 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3741 "%s:LOGP in Progress. Ignore!!!", __func__);
3742 return -EBUSY;
3743 }
3744
Jeff Johnson295189b2012-06-20 16:38:30 -07003745 switch(wrqu->param.flags & IW_AUTH_INDEX)
3746 {
3747 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003748
Jeff Johnson295189b2012-06-20 16:38:30 -07003749 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003750
Jeff Johnson295189b2012-06-20 16:38:30 -07003751 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003752
Jeff Johnson295189b2012-06-20 16:38:30 -07003753 case IW_AUTH_CIPHER_PAIRWISE:
3754 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003755 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003756 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003758 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3759 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003760 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003761 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
3762 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003763 }
3764
Jeff Johnson295189b2012-06-20 16:38:30 -07003765 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003766
3767 if( (IW_AUTH_KEY_MGMT_802_1X
3768 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
3770 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003771 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07003772 else
3773 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003774 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3775 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003776 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003777
3778 if( ( IW_AUTH_KEY_MGMT_802_1X
3779 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003780 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3781 /*Dynamic WEP key*/
3782 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3783 else
3784 /*Static WEP key*/
3785 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003786
Jeff Johnson295189b2012-06-20 16:38:30 -07003787 }
3788 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003789
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003791 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003792 return -EINVAL;
3793 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003794
Jeff Johnson295189b2012-06-20 16:38:30 -07003795 pRoamProfile->EncryptionType.numEntries = 1;
3796 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003797 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 break;
3799 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003800 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003801 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
3802 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3803 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003804
Jeff Johnson295189b2012-06-20 16:38:30 -07003805 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3806 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
3807 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003808
3809 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003810 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
3811 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003812
Jeff Johnson295189b2012-06-20 16:38:30 -07003813 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003814
3815 if( ( IW_AUTH_KEY_MGMT_802_1X
3816 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
3817 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3818
Jeff Johnson295189b2012-06-20 16:38:30 -07003819 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003820
3821 else
3822 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003823 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003824
3825 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
3826 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003828 if( ( IW_AUTH_KEY_MGMT_802_1X
3829 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003830 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3831 {
3832 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3833 }
3834 else
3835 {
3836 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3837 }
3838 }
3839 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003840
Jeff Johnson295189b2012-06-20 16:38:30 -07003841 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003842 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 return -EINVAL;
3844 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003845
Jeff Johnson295189b2012-06-20 16:38:30 -07003846 pRoamProfile->mcEncryptionType.numEntries = 1;
3847 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
3848 }
3849 break;
3850
3851 case IW_AUTH_80211_AUTH_ALG:
3852 {
3853 /*Save the auth algo here and set auth type to SME Roam profile
3854 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003855 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003857
Jeff Johnson295189b2012-06-20 16:38:30 -07003858 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
3859 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
3860
3861 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
3862 /*Not supported*/
3863 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3864 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
3865 }
3866 break;
3867
3868 case IW_AUTH_KEY_MGMT:
3869 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003870#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003871#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
3872 /*Check for CCKM AKM type */
3873 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003874 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
3875 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003876 /* Set the CCKM bit in authKeyMgmt */
3877 /* Right now, this breaks all ref to authKeyMgmt because our
3878 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07003879 */
3880 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
3881 /*Set the key management to 802.1X*/
3882 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003883 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003884 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3885 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3886 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
3887 /*Save the key management*/
3888 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
3889 //pWextState->authKeyMgmt = wrqu->param.value;
3890 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3891 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3892 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
3893 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
3894 /*Save the key management anyway*/
3895 pWextState->authKeyMgmt = wrqu->param.value;
3896 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
3897 /*Save the key management*/
3898 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
3899 //pWextState->authKeyMgmt = wrqu->param.value;
3900 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3901 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3902 }
3903#else
3904 /*Save the key management*/
3905 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003906#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003907 }
3908 break;
3909
3910 case IW_AUTH_TKIP_COUNTERMEASURES:
3911 {
3912 if(wrqu->param.value) {
3913 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3914 "Counter Measure started %d", wrqu->param.value);
3915 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
3916 }
3917 else {
3918 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3919 "Counter Measure stopped=%d", wrqu->param.value);
3920 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3921 }
3922 }
3923 break;
3924 case IW_AUTH_DROP_UNENCRYPTED:
3925 case IW_AUTH_WPA_ENABLED:
3926 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3927 case IW_AUTH_ROAMING_CONTROL:
3928 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003929
Jeff Johnson295189b2012-06-20 16:38:30 -07003930 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003931
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003932 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003933 wrqu->param.flags & IW_AUTH_INDEX);
3934 break;
3935 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003936
Jeff Johnson295189b2012-06-20 16:38:30 -07003937 EXIT();
3938 return 0;
3939}
3940/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003941
3942 \brief iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003943 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003944
Jeff Johnson295189b2012-06-20 16:38:30 -07003945 \param - dev - Pointer to the net device.
3946 - info - Pointer to the iw_request_info.
3947 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003948 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003949 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003950
Jeff Johnson295189b2012-06-20 16:38:30 -07003951 --------------------------------------------------------------------------*/
3952int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
3953 union iwreq_data *wrqu,char *extra)
3954{
3955 hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003956 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003957 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3958 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003959
3960 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3961 {
3962 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3963 "%s:LOGP in Progress. Ignore!!!", __func__);
3964 return -EBUSY;
3965 }
3966
Jeff Johnson295189b2012-06-20 16:38:30 -07003967 switch(pRoamProfile->negotiatedAuthType)
3968 {
3969 case eCSR_AUTH_TYPE_WPA_NONE:
3970 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3971 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
3972 break;
3973 case eCSR_AUTH_TYPE_WPA:
3974 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3975 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
3976 break;
3977#ifdef WLAN_FEATURE_VOWIFI_11R
3978 case eCSR_AUTH_TYPE_FT_RSN:
3979#endif
3980 case eCSR_AUTH_TYPE_RSN:
3981 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3982 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
3983 break;
3984 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3985 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3986 break;
3987 case eCSR_AUTH_TYPE_SHARED_KEY:
3988 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
3989 break;
3990 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003991 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003992 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3993 break;
3994 case eCSR_AUTH_TYPE_AUTOSWITCH:
3995 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3996 break;
3997 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303998 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003999 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4000 return -EIO;
4001#ifdef WLAN_FEATURE_VOWIFI_11R
4002 case eCSR_AUTH_TYPE_FT_RSN_PSK:
4003#endif
4004 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07004005#ifdef WLAN_FEATURE_11W
4006 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05304007 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07004008#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05304009 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004010 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4011 return -EIO;
4012 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304013 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4015 return -EIO;
4016 }
4017 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
4018 {
4019 switch(pRoamProfile->negotiatedUCEncryptionType)
4020 {
4021 case eCSR_ENCRYPT_TYPE_NONE:
4022 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4023 break;
4024 case eCSR_ENCRYPT_TYPE_WEP40:
4025 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4026 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4027 break;
4028 case eCSR_ENCRYPT_TYPE_TKIP:
4029 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4030 break;
4031 case eCSR_ENCRYPT_TYPE_WEP104:
4032 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4033 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4034 break;
4035 case eCSR_ENCRYPT_TYPE_AES:
4036 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4037 break;
4038 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304039 hddLog(LOG1, "%s called with unknown auth type %d ",
4040 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004041 return -EIO;
4042 }
4043 }
4044
Shailender Karmuchia734f332013-04-19 14:02:48 -07004045 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07004046 {
4047 switch(pRoamProfile->negotiatedMCEncryptionType)
4048 {
4049 case eCSR_ENCRYPT_TYPE_NONE:
4050 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4051 break;
4052 case eCSR_ENCRYPT_TYPE_WEP40:
4053 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4054 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4055 break;
4056 case eCSR_ENCRYPT_TYPE_TKIP:
4057 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4058 break;
4059 case eCSR_ENCRYPT_TYPE_WEP104:
4060 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4061 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4062 break;
4063 case eCSR_ENCRYPT_TYPE_AES:
4064 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4065 break;
4066 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304067 hddLog(LOG1, "%s called with unknown auth type %d ",
4068 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 return -EIO;
4070 }
4071 }
4072
4073 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004074 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004075 EXIT();
4076 return 0;
4077}
4078/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004079
4080 \brief iw_set_ap_address() -
4081 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004083
Jeff Johnson295189b2012-06-20 16:38:30 -07004084 \param - dev - Pointer to the net device.
4085 - info - Pointer to the iw_request_info.
4086 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004087 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004088 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004089
Jeff Johnson295189b2012-06-20 16:38:30 -07004090 --------------------------------------------------------------------------*/
4091int iw_set_ap_address(struct net_device *dev,
4092 struct iw_request_info *info,
4093 union iwreq_data *wrqu, char *extra)
4094{
4095 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
4096 v_U8_t *pMacAddress=NULL;
4097 ENTER();
4098 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08004099 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
4100 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07004101 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
4102 EXIT();
Shailender Karmuchia734f332013-04-19 14:02:48 -07004103
Jeff Johnson295189b2012-06-20 16:38:30 -07004104 return 0;
4105}
4106/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004107
4108 \brief iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004109 This function returns the BSSID to the wpa_supplicant
4110 \param - dev - Pointer to the net device.
4111 - info - Pointer to the iw_request_info.
4112 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004113 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004115
Jeff Johnson295189b2012-06-20 16:38:30 -07004116 --------------------------------------------------------------------------*/
4117int iw_get_ap_address(struct net_device *dev,
4118 struct iw_request_info *info,
4119 union iwreq_data *wrqu, char *extra)
4120{
4121 //hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4122 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
4123
4124 ENTER();
4125
4126 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
4127 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
4128 {
Jeff Johnson4416a782013-03-25 14:17:50 -07004129 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07004130 }
4131 else
4132 {
4133 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4134 }
4135 EXIT();
4136 return 0;
4137}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004138
Chet Lanctot186b5732013-03-18 10:26:30 -07004139#ifdef WLAN_FEATURE_11W
4140/**---------------------------------------------------------------------------
4141
4142 \brief hdd_indicateUnprotMgmtFrame -
4143 This function forwards the unprotected management frame to the supplicant
4144 \param - pAdapter - Pointer to HDD adapter
4145 - nFrameLength - Length of the unprotected frame being passed
4146 - pbFrames - Pointer to the frame buffer
4147 - frameType - 802.11 frame type
4148 \return - nothing
4149
4150 --------------------------------------------------------------------------*/
4151void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
4152 tANI_U32 nFrameLength,
4153 tANI_U8* pbFrames,
4154 tANI_U8 frameType )
4155{
4156 tANI_U8 type = 0;
4157 tANI_U8 subType = 0;
4158
4159 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
4160 __func__, frameType, nFrameLength);
4161
4162 /* Sanity Checks */
4163 if (NULL == pAdapter)
4164 {
4165 hddLog( LOGE, FL("pAdapter is NULL"));
4166 return;
4167 }
4168
4169 if (NULL == pAdapter->dev)
4170 {
4171 hddLog( LOGE, FL("pAdapter->dev is NULL"));
4172 return;
4173 }
4174
4175 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
4176 {
4177 hddLog( LOGE, FL("pAdapter has invalid magic"));
4178 return;
4179 }
4180
4181 if( !nFrameLength )
4182 {
4183 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
4184 return;
4185 }
4186
4187 if (NULL == pbFrames) {
4188 hddLog( LOGE, FL("pbFrames is NULL"));
4189 return;
4190 }
4191
4192 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4193 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4194
4195 /* Get pAdapter from Destination mac address of the frame */
4196 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
4197 {
4198 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
4199 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4200 }
4201 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
4202 {
4203 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
4204 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4205 }
4206 else
4207 {
4208 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
4209 return;
4210 }
4211}
4212#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004213
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004214#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004215void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
4216 tANI_U8 state,
4217 tANI_U16 measInterval )
4218{
4219 union iwreq_data wrqu;
4220 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004221 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004222
4223 if (NULL == pAdapter)
4224 return;
4225
4226 // create the event
4227 memset(&wrqu, '\0', sizeof(wrqu));
4228 memset(buf, '\0', sizeof(buf));
4229
4230 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
4231 tid, state, measInterval);
4232
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004233 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004234
4235 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004236 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004237 // send the event
4238 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4239}
4240
4241void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4242{
4243 union iwreq_data wrqu;
4244 char buf[IW_CUSTOM_MAX + 1];
4245 char *pos = buf;
4246 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4247
4248 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4249 return;
4250
4251 // create the event
4252 memset(&wrqu, '\0', sizeof(wrqu));
4253 memset(buf, '\0', sizeof(buf));
4254
4255 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304256 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
4257 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
4258 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
4259 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004260
4261 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4262 pos += nBytes;
4263 freeBytes -= nBytes;
4264
4265 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
4266 pos += WNI_CFG_BSSID_LEN;
4267 freeBytes -= WNI_CFG_BSSID_LEN;
4268
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004269 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4270 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004271
4272 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004273 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004274
4275 // send the event
4276 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4277}
4278
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004279void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004280{
4281 union iwreq_data wrqu;
4282 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004283 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004284
4285 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4286 return;
4287
4288 // create the event
4289 memset(&wrqu, '\0', sizeof(wrqu));
4290 memset(buf, '\0', sizeof(buf));
4291
4292 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
4293
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004294 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004295
4296 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004297 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004298
4299 // send the event
4300 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4301}
4302
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004303void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
4304 const tANI_U16 measurementToken,
4305 const tANI_BOOLEAN flag,
4306 const tANI_U8 numBss)
4307{
4308 union iwreq_data wrqu;
4309 char buf[IW_CUSTOM_MAX];
4310 char *pos = buf;
4311 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4312
4313 memset(&wrqu, '\0', sizeof(wrqu));
4314 memset(buf, '\0', sizeof(buf));
4315
4316 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
4317 numBss);
4318
4319 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4320 flag, numBss);
4321
4322 wrqu.data.pointer = buf;
4323 wrqu.data.length = nBytes;
4324 // send the event
4325 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4326}
4327
4328
4329static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004330 const tCsrRoamInfo *pRoamInfo)
4331{
4332 union iwreq_data wrqu;
4333 char buf[IW_CUSTOM_MAX + 1];
4334 char *pos = buf;
4335 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4336 tANI_U8 i = 0, len = 0;
4337 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
4338 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004339 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
4340 tANI_U8 ieLenByte = 1;
4341 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
4342#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004343
4344 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4345 return;
4346
4347 /* Custom event can pass maximum of 256 bytes of data,
4348 based on the IE len we need to identify how many BSS info can
4349 be filled in to custom event data */
4350 /*
4351 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4352 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4353 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4354 */
4355
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004356 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004357 {
4358 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
4359 /* If the measurement is none and no scan results found,
4360 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004361 hdd_indicateEseBcnReportNoResults(pAdapter,
4362 pRoamInfo->pEseBcnReportRsp->measurementToken,
4363 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004364 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004365 }
4366 else
4367 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004368 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004369 {
4370 memset(&wrqu, '\0', sizeof(wrqu));
4371 memset(buf, '\0', sizeof(buf));
4372 tot_bcn_ieLen = 0;
4373 sendBss = 0;
4374 pos = buf;
4375 freeBytes = IW_CUSTOM_MAX;
4376
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004377 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004378 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004379 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
4380 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004381 {
4382 break;
4383 }
4384 tot_bcn_ieLen += len;
4385 sendBss++;
4386 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
4387 "IeLength(%d) Length of Ie(%d) totLen(%d)",
4388 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004389 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004390 tot_bcn_ieLen);
4391 }
4392
4393 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
4394 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004395 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4396 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004397
4398 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004399 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4400 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004401 pos += nBytes;
4402 freeBytes -= nBytes;
4403
4404 /* Copy total Beacon report data length */
4405 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
4406 pos += sizeof(tot_bcn_ieLen);
4407 freeBytes -= sizeof(tot_bcn_ieLen);
4408
4409 for (i = 0; i < sendBss; i++)
4410 {
4411 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304412 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4413 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004414 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004415 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
4416 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
4417 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
4418 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
4419 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
4420 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
4421 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
4422 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
4423 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
4424 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
4425 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
4426 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
4427 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
4428 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
4429 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
4430 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004431
4432 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004433 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
4434 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004435 pos += len;
4436 freeBytes -= len;
4437
4438 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004439 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004440 vos_mem_copy(pos, (char*)&len, sizeof(len));
4441 pos += sizeof(len);
4442 freeBytes -= sizeof(len);
4443
4444 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004445 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004446 pos += len;
4447 freeBytes -= len;
4448 }
4449
4450 wrqu.data.pointer = buf;
4451 wrqu.data.length = strlen(buf);
4452
4453 // send the event
4454 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4455 lastSent += sendBss;
4456 }
4457 }
4458}
4459
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004460#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004461