blob: 277f1631bb52accfbb9e2e00a9c45bd0b72ea4dc [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 */
Padma, Santhosh Kumar87ba40f2014-11-26 19:40:15 +0530645 if((pHddStaCtx->ft_carrier_on == FALSE) && !pCsrRoamInfo->fReassocReq)
Agarwal Ashish51325b52014-06-16 16:50:49 +0530646 {
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);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +0530807 //TxTimeoutCount need to reset in case of disconnect handler
808 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700809
Jeff Johnsone7245742012-09-05 17:12:55 -0700810 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530811 /* HDD has initiated disconnect, do not send disconnect indication
812 * to kernel as it will be handled by __cfg80211_disconnect.
813 */
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530814 /* If only STA mode is on */
815 if((pHddCtx->concurrency_mode <= 1) &&
816 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
817 {
818 pHddCtx->isAmpAllowed = VOS_TRUE;
819 }
820
Agarwal Ashish47d18112014-08-04 19:55:07 +0530821 /* Need to apply spin lock before decreasing active sessions
822 * as there can be chance for double decrement if context switch
823 * Calls wlan_hdd_disconnect.
824 */
825
826 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530827 if ( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState )
828 {
829 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
830 FL(" HDD has initiated a disconnect, no need to send"
831 " disconnect indication to kernel"));
832 sendDisconInd = FALSE;
833 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530834 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530836 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +0530837 FL(" Set HDD connState to eConnectionState_Disconnecting from %d "),
838 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +0530839 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
840 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -0700841 }
Agarwal Ashish47d18112014-08-04 19:55:07 +0530842 spin_unlock_bh(&pAdapter->lock_for_active_session);
843
Jeff Johnson295189b2012-06-20 16:38:30 -0700844 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -0700845
846 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -0700847
848 // indicate 'disconnect' status to wpa_supplicant...
849 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700850 /* indicate disconnected event to nl80211 */
851 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
852 {
853 /*During the WLAN uninitialization,supplicant is stopped before the
854 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +0530855 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -0700856 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700857 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
858 "%s: sent disconnected event to nl80211",
Jeff Johnson295189b2012-06-20 16:38:30 -0700859 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700860#ifdef WLAN_FEATURE_P2P_DEBUG
861 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
862 {
863 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
864 {
865 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
866 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
867 "and moved to disconnected state");
868 }
869 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
870 {
871 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
872 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
873 "and moved to inactive state");
874 }
875 }
876#endif
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530877 /*Only send indication to kernel if not initiated by kernel*/
878 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -0700879 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530880 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
881 if ( eCSR_ROAM_LOSTLINK == roamStatus )
882 {
883 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
884 }
885 else
886 {
887 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
888 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700889 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700890 //If the Device Mode is Station
891 // and the P2P Client is Connected
892 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -0700893
894 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -0700895 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -0700896 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -0700897 {
898 //Enable BMPS only of other Session is P2P Client
899 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700900 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -0700901
902 if (NULL != pVosContext)
903 {
904 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
905
906 if(NULL != pHddCtx)
907 {
908 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +0530909 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
910 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530912 if (pHddCtx->hdd_wlan_suspended)
913 {
914 hdd_set_pwrparams(pHddCtx);
915 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700916 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530917 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700918 }
919 }
920 }
921 }
922 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700923
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +0530924 hdd_wmm_adapter_clear(pAdapter);
Mukul Sharmac159c432014-01-15 15:42:46 +0530925#if defined(WLAN_FEATURE_VOWIFI_11R)
926 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
927#endif
Katya Nigam63ce1772014-09-26 15:53:49 +0530928
929 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
930 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530931 v_U8_t i;
932
Katya Nigam63ce1772014-09-26 15:53:49 +0530933 sta_id = IBSS_BROADCAST_STAID;
934 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
935 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
936 {
937 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530938 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
939 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +0530940 sta_id, status, status );
941
942 status = eHAL_STATUS_FAILURE;
943 }
Katya Nigam63ce1772014-09-26 15:53:49 +0530944 pHddCtx->sta_to_adapter[sta_id] = NULL;
945
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530946 /*Clear all the peer sta register with TL.*/
947 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
948 {
949 if (0 != pHddStaCtx->conn_info.staId[i])
950 {
951 sta_id = pHddStaCtx->conn_info.staId[i];
952
953 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
954 FL("Deregister StaID %d"),sta_id);
955 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
956 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
957 {
958 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
959 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
960 "Status= %d [0x%x]"),
961 sta_id, status, status );
962 status = eHAL_STATUS_FAILURE;
963 }
964
965 /*set the staid and peer mac as 0, all other reset are
966 * done in hdd_connRemoveConnectInfo.
967 */
968 pHddStaCtx->conn_info.staId[i]= 0;
969 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
970
971 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
972 pHddCtx->sta_to_adapter[sta_id] = NULL;
973 }
974 }
975
Katya Nigam63ce1772014-09-26 15:53:49 +0530976 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530977 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700978 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530979 sta_id = pHddStaCtx->conn_info.staId[0];
980
981 //We should clear all sta register with TL, for now, only one.
982 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
983 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
984 {
985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
986 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
987 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -0700988 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700989
Abhishek Singh06e67ba2014-12-08 17:16:33 +0530990 status = eHAL_STATUS_FAILURE;
991 }
992
993 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700994 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700995 // Clear saved connection information in HDD
996 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhf4669da2014-05-26 15:07:49 +0530997 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
998 "%s: Set HDD connState to eConnectionState_NotConnected",
999 __func__);
1000 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301001#ifdef WLAN_FEATURE_GTK_OFFLOAD
1002 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1003 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1004 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301005 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1006 sizeof (tSirGtkOffloadParams));
1007 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301008 }
1009#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001010
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001011#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001012 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1013 {
1014 wlan_hdd_tdls_disconnection_callback(pAdapter);
1015 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001016#endif
1017
Jeff Johnson295189b2012-06-20 16:38:30 -07001018 //Unblock anyone waiting for disconnect to complete
1019 complete(&pAdapter->disconnect_comp_var);
1020 return( status );
1021}
1022static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
1023 tCsrRoamInfo *pRoamInfo,
1024 v_U8_t staId,
1025 v_MACADDR_t *pPeerMacAddress,
1026 tSirBssDescription *pBssDesc )
1027{
1028 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1029 WLAN_STADescType staDesc = {0};
1030 eCsrEncryptionType connectedCipherAlgo;
1031 v_BOOL_t fConnected;
1032 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1033 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001034 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001035
1036 if ( NULL == pBssDesc)
1037 {
1038 return VOS_STATUS_E_FAILURE;
1039 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001040 // Get the Station ID from the one saved during the assocation.
1041 staDesc.ucSTAId = staId;
1042
1043 if ( pHddStaCtx->conn_info.connDot11DesiredBssType == eMib_dot11DesiredBssType_infrastructure)
Jeff Johnson295189b2012-06-20 16:38:30 -07001044 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001045 staDesc.wSTAType = WLAN_STA_INFRA;
1046
1047 // grab the bssid from the connection info in the adapter structure and hand that
1048 // over to TL when registering.
1049 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) );
1050 }
1051 else
1052 {
1053 // for an IBSS 'connect', setup the Station Descriptor for TL.
Jeff Johnson295189b2012-06-20 16:38:30 -07001054 staDesc.wSTAType = WLAN_STA_IBSS;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001055
Jeff Johnson295189b2012-06-20 16:38:30 -07001056 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
1057 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
1058 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
1059 // pass when making an Infrastructure connection.
1060 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) );
1061 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
1062 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001063
Jeff Johnson295189b2012-06-20 16:38:30 -07001064 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1065
1066 // set the QoS field appropriately
1067 if (hdd_wmm_is_active(pAdapter))
1068 {
1069 staDesc.ucQosEnabled = 1;
1070 }
1071 else
1072 {
1073 staDesc.ucQosEnabled = 0;
1074 }
1075
1076 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1077 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1078 {
1079 staDesc.ucProtectedFrame = 1;
1080 }
1081 else
1082 {
1083 staDesc.ucProtectedFrame = 0;
1084
1085 }
1086
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001087#ifdef FEATURE_WLAN_ESE
1088 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
1089#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001090
1091#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1092 /* check whether replay check is valid for the station or not */
1093 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
1094 {
1095 /* Encryption mode is either TKIP or AES
1096 and replay check is valid for only these
1097 two encryption modes */
1098 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1099 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1100 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1101 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001102
Jeff Johnson295189b2012-06-20 16:38:30 -07001103 else
1104 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001105 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001106 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001107 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001108 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1109 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1110 }
1111#endif
1112
1113#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001114 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001115 if (pAdapter->wapi_info.fIsWapiSta)
1116 {
1117 staDesc.ucIsWapiSta = 1;
1118 }
1119 else
1120 {
1121 staDesc.ucIsWapiSta = 0;
1122 }
1123#endif /* FEATURE_WLAN_WAPI */
1124
1125 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1126 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1127
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 // UMA is Not ready yet, Xlation will be done by TL
1129 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001130 staDesc.ucSwFrameRXXlation = 1;
1131 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001132 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001133 staDesc.ucQosEnabled );
1134 // Initialize signatures and state
1135 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1136 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1137 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1138 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001139 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001140 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 -07001141 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1142 hdd_rx_packet_cbk,
1143 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001144 hdd_tx_fetch_packet_cbk, &staDesc,
1145 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001146
Jeff Johnson295189b2012-06-20 16:38:30 -07001147 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1148 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001149 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001150 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001151 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001152 return vosStatus;
1153 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001154
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001155 if ( cfg_param->dynSplitscan &&
1156 ( VOS_TIMER_STATE_RUNNING !=
1157 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1158 {
1159 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1160 cfg_param->trafficMntrTmrForSplitScan);
1161 }
1162
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301163 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1164 // then go to 'authenticated'. For all other authentication types
1165 // (those that donot require upper layer authentication) we can put
1166 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001167 if (staDesc.wSTAType != WLAN_STA_IBSS)
1168 VOS_ASSERT( fConnected );
1169
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301170 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001171 {
1172 // Connections that do not need Upper layer auth, transition TL directly
1173 // to 'Authenticated' state.
1174 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1175 WLANTL_STA_AUTHENTICATED );
1176
1177 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1178 }
1179 else
1180 {
1181 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301182 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1183 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001184 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301185 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001186 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1187 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001188 return( vosStatus );
1189}
1190
Jeff Johnson295189b2012-06-20 16:38:30 -07001191static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1192 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1193{
1194 unsigned int len = 0;
1195 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001196 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001197 tANI_U32 rspRsnLength = 0;
1198 struct ieee80211_channel *chan;
1199
Agarwal Ashish51325b52014-06-16 16:50:49 +05301200 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001201 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001202 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001203 }
1204
Agarwal Ashish51325b52014-06-16 16:50:49 +05301205 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001206 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1207 goto done;
1208 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001209
Agarwal Ashish51325b52014-06-16 16:50:49 +05301210 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001211 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1212 goto done;
1213 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001214
1215 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1216 pCsrRoamInfo->nAssocReqLength);
1217 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001218 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001219
1220 //pFTAssocRsp needs to point to the IEs
1221 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001222 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001223 (unsigned int)pFTAssocRsp[0],
1224 (unsigned int)pFTAssocRsp[1]);
1225
1226 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001227 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001228 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001230 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001231
1232 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1233 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1234 reqRsnIe, reqRsnLength,
1235 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001236
1237done:
1238 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001239}
Jeff Johnson295189b2012-06-20 16:38:30 -07001240
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301241void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1242{
1243 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1244 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1245 tCsrRoamInfo roamInfo;
1246 roamInfo.fAuthRequired = FALSE;
1247 vos_mem_copy(roamInfo.bssid,
1248 pHddStaCtx->roam_info.bssid,
1249 WNI_CFG_BSSID_LEN);
1250 vos_mem_copy(roamInfo.peerMac,
1251 pHddStaCtx->roam_info.peerMac,
1252 WNI_CFG_BSSID_LEN);
1253
1254 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1255 &roamInfo,
1256 pHddStaCtx->roam_info.roamId,
1257 pHddStaCtx->roam_info.roamStatus,
1258 eCSR_ROAM_RESULT_AUTHENTICATED);
1259 if (halStatus != eHAL_STATUS_SUCCESS)
1260 {
1261 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1262 }
1263 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1264}
1265
Shailender Karmuchia734f332013-04-19 14:02:48 -07001266static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1267 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001268 eCsrRoamResult roamResult )
1269{
1270 struct net_device *dev = pAdapter->dev;
1271 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1272 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301273 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05301274 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001275 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1276 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001277#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001278 int ft_carrier_on = FALSE;
1279#endif
1280 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301281 v_BOOL_t hddDisconInProgress = FALSE;
1282
1283 /* HDD has initiated disconnect, do not send connect result indication
1284 * to kernel as it will be handled by __cfg80211_disconnect.
1285 */
1286 if(( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) &&
1287 (( eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
1288 ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)) )
1289 {
1290 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1291 FL(" Disconnect from HDD in progress "));
1292 hddDisconInProgress = TRUE;
1293 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001294
Jeff Johnson295189b2012-06-20 16:38:30 -07001295 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1296 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301297 if ( !hddDisconInProgress )
1298 {
1299 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05301300 "%s: Set HDD connState to eConnectionState_Associated",
1301 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301302 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001304
c_hpothu44ff4e02014-05-08 00:13:57 +05301305 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001306 // Save the connection info from CSR...
1307 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1308#ifdef FEATURE_WLAN_WAPI
1309 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1310 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1311 {
1312 pAdapter->wapi_info.fIsWapiSta = 1;
1313 }
1314 else
1315 {
1316 pAdapter->wapi_info.fIsWapiSta = 0;
1317 }
1318#endif /* FEATURE_WLAN_WAPI */
1319
1320 // indicate 'connect' status to userspace
1321 hdd_SendAssociationEvent(dev,pRoamInfo);
1322
1323
Shailender Karmuchia734f332013-04-19 14:02:48 -07001324 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001325 INIT_COMPLETION(pAdapter->linkup_event_var);
1326
1327 /*
1328 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1329 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 -07001330 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001331 know that the device is getting activated properly.
1332 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001333#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05301334 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07001335 {
1336#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001337 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001338 pAdapter->isLinkUpSvcNeeded = TRUE;
1339
Shailender Karmuchia734f332013-04-19 14:02:48 -07001340 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001341 pAdapter->isLinkUpSvcNeeded = TRUE;
1342
1343 // Switch on the Carrier to activate the device
1344 netif_carrier_on(dev);
1345
1346 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1347 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1348 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001349 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001350 {
1351 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1352 }
1353
1354 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1355 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001356#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001357 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001358 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001359 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001360 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001361 }
1362#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05301363 /* Check for STAID */
1364 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
1365 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1366 else
1367 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001368
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001369#ifdef FEATURE_WLAN_TDLS
1370 wlan_hdd_tdls_connection_callback(pAdapter);
1371#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001372 //For reassoc, the station is already registered, all we need is to change the state
1373 //of the STA in TL.
1374 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05301375 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07001376 if( !pRoamInfo->fReassocReq )
1377 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001378 struct cfg80211_bss *bss;
1379#ifdef WLAN_FEATURE_VOWIFI_11R
1380 u8 *pFTAssocRsp = NULL;
1381 unsigned int assocRsplen = 0;
1382 u8 *pFTAssocReq = NULL;
1383 unsigned int assocReqlen = 0;
1384 struct ieee80211_channel *chan;
1385#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001386 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001387 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001388
1389 /* add bss_id to cfg80211 data base */
1390 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1391 if (NULL == bss)
1392 {
1393 pr_err("wlan: Not able to create BSS entry\n");
Katya Nigam346d4e92014-09-02 16:16:12 +05301394 netif_carrier_off(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001395 return eHAL_STATUS_FAILURE;
1396 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001397#ifdef WLAN_FEATURE_VOWIFI_11R
1398 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001399 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001401
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001402 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001403 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001404 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001405 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001406 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001407 // pFTAssocRsp needs to point to the IEs
1408 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1409 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1410 (unsigned int)pFTAssocRsp[0],
1411 (unsigned int)pFTAssocRsp[1]);
1412 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001413 }
1414 else
1415 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001416 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1417 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001418 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001419
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001420 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001421 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001422 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001423 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001424 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001425 if(!ft_carrier_on)
1426 {
1427 // pFTAssocReq needs to point to the IEs
1428 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1429 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1430 (unsigned int)pFTAssocReq[0],
1431 (unsigned int)pFTAssocReq[1]);
1432 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1433 }
1434 else
1435 {
1436 /* This should contain only the FTIEs */
1437 assocReqlen = pRoamInfo->nAssocReqLength;
1438 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001439 }
1440 else
1441 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001442 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1443 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001444 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001445
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001446 if(ft_carrier_on)
1447 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301448 if ( !hddDisconInProgress )
1449 {
1450 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001451 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301452 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001453 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301454 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001455 assocRsplen);
Girish Gowlidf0ed732014-08-11 12:39:39 +05301456#ifdef DEBUG_ROAM_DELAY
1457 //HACK we are using the buff len as Auth Type
1458 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1459#endif
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301460 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001461 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1462 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301463 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301464 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1465 {
1466 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1467 pRoamInfo->fAuthRequired = FALSE;
1468
1469 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1470 pRoamInfo->bssid,
1471 HDD_MAC_ADDR_LEN);
1472 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1473 pRoamInfo->peerMac,
1474 HDD_MAC_ADDR_LEN);
1475 pHddStaCtx->roam_info.roamId = roamId;
1476 pHddStaCtx->roam_info.roamStatus = roamStatus;
1477 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1478 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001479 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301480 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001481 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001482 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001483 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001484 cfg80211_connect_result(dev, pRoamInfo->bssid,
1485 pFTAssocReq, assocReqlen,
1486 pFTAssocRsp, assocRsplen,
1487 WLAN_STATUS_SUCCESS,
1488 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001489 }
1490 }
1491 else
1492#endif
1493 {
1494 /* wpa supplicant expecting WPA/RSN IE in connect result */
1495 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1496 pAdapter->sessionId,
1497 &reqRsnLength,
1498 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001499
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001500 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1501 pAdapter->sessionId,
1502 &rspRsnLength,
1503 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301504 if ( !hddDisconInProgress )
1505 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001506#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301507 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05301508 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301509 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Mukul Sharma84f27252014-07-14 18:11:42 +05301510#ifdef DEBUG_ROAM_DELAY
1511 //HACK we are using the buff len as Auth Type
1512 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1513#endif
1514 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301515 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001516#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001517
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301518 {
1519 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301520 "%s: sending connect indication to nl80211:"
1521 " for bssid " MAC_ADDRESS_STR
1522 " reason:%d and Status:%d\n",
1523 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1524 roamResult, roamStatus);
1525
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301526 /* inform connect result to nl80211 */
1527 cfg80211_connect_result(dev, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001528 reqRsnIe, reqRsnLength,
1529 rspRsnIe, rspRsnLength,
1530 WLAN_STATUS_SUCCESS,
1531 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301532 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001533 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001534 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301535 if ( !hddDisconInProgress )
1536 {
1537 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07001538#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301539 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07001540#endif
1541 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301542 // Register the Station with TL after associated...
1543 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001544 pRoamInfo,
1545 pHddStaCtx->conn_info.staId[ 0 ],
1546 NULL,
1547 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301548 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001549 }
1550 else
1551 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001552 /* wpa supplicant expecting WPA/RSN IE in connect result */
1553 /* in case of reassociation also need to indicate it to supplicant */
1554 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1555 pAdapter->sessionId,
1556 &reqRsnLength,
1557 reqRsnIe);
1558
1559 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001560 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301561 if( pRoamInfo->fAuthRequired )
1562 {
1563 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1564 pHddStaCtx->conn_info.staId[ 0 ],
1565 WLANTL_STA_CONNECTED );
1566 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1567 }
1568 else
1569 {
1570 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1571 "%s: staId: %d Changing TL state to AUTHENTICATED",
1572 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1573 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1574 pHddStaCtx->conn_info.staId[ 0 ],
1575 WLANTL_STA_AUTHENTICATED );
1576 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001578 }
1579
1580 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1581 {
1582 // perform any WMM-related association processing
1583 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1584 }
1585 else
1586 {
1587 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001588 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001589 vosStatus, vosStatus );
1590 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001591#ifdef WLAN_FEATURE_11W
1592 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1593 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1594#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001595 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05301596 if ( !hddDisconInProgress )
1597 netif_tx_wake_all_queues(dev);
Mukul Sharma84f27252014-07-14 18:11:42 +05301598#ifdef DEBUG_ROAM_DELAY
1599 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
1600#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001601 }
1602 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001603 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001604 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1605
1606 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001607 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001608 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1609 " reason:%d and Status:%d\n",
1610 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1611 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001612 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001613 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1614 " reason:%d and Status:%d\n",
1615 MAC_ADDR_ARRAY(pWextState->req_bssId),
1616 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001617
Abhishek Singhf4669da2014-05-26 15:07:49 +05301618 /* Set connection state to eConnectionState_NotConnected only when CSR
1619 * has completed operation - with a ASSOCIATION_FAILURE status
1620 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301621 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05301622 {
1623 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1624 "%s: Set HDD connState to eConnectionState_NotConnected",
1625 __func__);
1626 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1627 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05301628 if((pHddCtx->concurrency_mode <= 1) &&
1629 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07001630 {
1631 pHddCtx->isAmpAllowed = VOS_TRUE;
1632 }
1633
1634 //If the Device Mode is Station
1635 // and the P2P Client is Connected
1636 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001637
1638 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001639 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001640 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1641 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05301642 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07001643 {
1644 //Enable BMPS only of other Session is P2P Client
1645 hdd_context_t *pHddCtx = NULL;
1646 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1647
1648 if (NULL != pVosContext)
1649 {
1650 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1651
1652 if(NULL != pHddCtx)
1653 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301654 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301655 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1656 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301657 {
1658 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001659 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301660 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001661 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301662 hdd_enable_bmps_imps(pHddCtx);
1663 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001664 }
1665 }
1666 }
1667
James Zmudafbf5ffc2013-03-25 12:45:35 -07001668 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001669 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301670 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07001671 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301672 if (pRoamInfo)
1673 hddLog(VOS_TRACE_LEVEL_ERROR,
1674 "%s: send connect failure to nl80211:"
1675 " for bssid " MAC_ADDRESS_STR
1676 " reason:%d and Status:%d\n" ,
1677 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1678 roamResult, roamStatus);
1679 else
1680 hddLog(VOS_TRACE_LEVEL_ERROR,
1681 "%s: connect failed:"
1682 " for bssid " MAC_ADDRESS_STR
1683 " reason:%d and Status:%d\n" ,
1684 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
1685 roamResult, roamStatus);
1686
c_hpothudaa90e22014-06-24 17:23:43 +05301687 /*Clear the roam profile*/
1688 hdd_clearRoamProfileIe( pAdapter );
1689
James Zmudafbf5ffc2013-03-25 12:45:35 -07001690 /* inform association failure event to nl80211 */
1691 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1692 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001693 if (pRoamInfo)
1694 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1695 NULL, 0, NULL, 0,
1696 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1697 GFP_KERNEL );
1698 else
1699 cfg80211_connect_result ( dev, pWextState->req_bssId,
1700 NULL, 0, NULL, 0,
1701 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1702 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001703 }
1704 else
1705 {
Sushant Kaushik21f28232014-12-18 11:42:46 +05301706 if (pRoamInfo){
1707 eCsrAuthType authType =
1708 pWextState->roamProfile.AuthType.authType[0];
1709 v_BOOL_t isWep = (authType == eCSR_AUTH_TYPE_OPEN_SYSTEM) ||
1710 (authType == eCSR_AUTH_TYPE_SHARED_KEY);
1711
1712 /* In case of OPEN-WEP or SHARED-WEP authentication,
1713 * send exact protocol reason code. This enables user
1714 * applications to reconnect the station with correct
1715 * configuration.
1716 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001717 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1718 NULL, 0, NULL, 0,
Sushant Kaushik21f28232014-12-18 11:42:46 +05301719 isWep ? pRoamInfo->reasonCode :
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001720 WLAN_STATUS_UNSPECIFIED_FAILURE,
1721 GFP_KERNEL );
Sushant Kaushik21f28232014-12-18 11:42:46 +05301722 } else
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001723 cfg80211_connect_result ( dev, pWextState->req_bssId,
1724 NULL, 0, NULL, 0,
1725 WLAN_STATUS_UNSPECIFIED_FAILURE,
1726 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001727 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001728 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001729
Kumar Anand82c009f2014-05-29 00:29:42 -07001730 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001731
c_hpothu24f40982014-04-18 18:00:36 +05301732 if (pRoamInfo)
1733 {
1734 WLANTL_AssocFailed(pRoamInfo->staId);
1735 }
Mihir Sheteb7337272014-04-11 15:53:08 +05301736
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 netif_tx_disable(dev);
1738 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001739
Jeff Johnson295189b2012-06-20 16:38:30 -07001740 }
1741
Sushant Kaushikbf584e92014-08-06 17:59:20 +05301742 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301743 {
1744 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
1745 if (pHostapdAdapter != NULL)
1746 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05301747 /* Restart SAP if its operating channel is different
1748 * from AP channel.
1749 */
1750 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
1751 (int)pRoamInfo->pBssDesc->channelId)
1752 {
1753 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
1754 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
1755 (int)pRoamInfo->pBssDesc->channelId);
Deepthi Gowric9c777d2014-12-10 16:17:11 +05301756 hdd_hostapd_stop(pHostapdAdapter->dev);
Sushant Kaushikbf584e92014-08-06 17:59:20 +05301757 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301758 }
1759 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001760 return eHAL_STATUS_SUCCESS;
1761}
1762
1763/**============================================================================
1764 *
Jeff Johnson81c17882013-05-03 09:53:35 -07001765 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07001766 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07001767
Jeff Johnson295189b2012-06-20 16:38:30 -07001768 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07001769static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
1770 tCsrRoamInfo *pRoamInfo,
1771 tANI_U32 roamId,
1772 eRoamCmdStatus roamStatus,
1773 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07001774{
Jeff Johnson81c17882013-05-03 09:53:35 -07001775 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
1776 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
1777
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 switch( roamResult )
1779 {
1780 // both IBSS Started and IBSS Join should come in here.
1781 case eCSR_ROAM_RESULT_IBSS_STARTED:
1782 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001783 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07001784 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001785 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1786 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001787
Jeff Johnson81c17882013-05-03 09:53:35 -07001788 if (NULL == pRoamInfo)
1789 {
1790 VOS_ASSERT(0);
1791 return;
1792 }
1793
1794 /* When IBSS Started comes from CSR, we need to move
1795 * connection state to IBSS Disconnected (meaning no peers
1796 * are in the IBSS).
1797 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05301798 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1799 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
1800 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07001801 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
1802 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05301803 /*notify wmm */
1804 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001805 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1806 hdd_roamRegisterSTA (pAdapter, pRoamInfo,
1807 IBSS_BROADCAST_STAID,
1808 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001809
Jeff Johnson81c17882013-05-03 09:53:35 -07001810 if (pRoamInfo->pBssDesc)
1811 {
1812 struct cfg80211_bss *bss;
1813
1814 /* we created the IBSS, notify supplicant */
1815 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
1816 MAC_ADDRESS_STR,
1817 __func__, pAdapter->dev->name,
1818 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
1819
1820 /* we must first give cfg80211 the BSS information */
1821 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1822 if (NULL == bss)
1823 {
1824 hddLog(VOS_TRACE_LEVEL_ERROR,
1825 "%s: %s: unable to create IBSS entry",
1826 __func__, pAdapter->dev->name);
1827 return;
1828 }
1829
1830 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07001831 cfg80211_put_bss(
1832#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1833 pHddCtx->wiphy,
1834#endif
1835 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07001836 }
1837
Jeff Johnson295189b2012-06-20 16:38:30 -07001838 break;
1839 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001840
Jeff Johnson295189b2012-06-20 16:38:30 -07001841 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
1842 {
Jeff Johnson81c17882013-05-03 09:53:35 -07001843 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
1844 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07001845 break;
1846 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001847
Jeff Johnson295189b2012-06-20 16:38:30 -07001848 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07001849 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
1850 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001851 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001852 }
1853
Jeff Johnson81c17882013-05-03 09:53:35 -07001854 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001855}
1856
1857/**============================================================================
1858 *
1859 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
1860 This information is passed to iwconfig later. The peer that joined
1861 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001862 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001863 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001864
Jeff Johnson295189b2012-06-20 16:38:30 -07001865 ===========================================================================*/
1866static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
1867{
1868 int fSuccess = FALSE;
1869 int idx = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001870
Jeff Johnson295189b2012-06-20 16:38:30 -07001871 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1872 {
1873 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
1874 {
1875 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001876
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001878
Jeff Johnson295189b2012-06-20 16:38:30 -07001879 fSuccess = TRUE;
1880 break;
1881 }
1882 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001883
1884 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07001885}
1886/**============================================================================
1887 *
1888 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001889 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001891
Jeff Johnson295189b2012-06-20 16:38:30 -07001892 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07001893static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07001894{
1895 int fSuccess = FALSE;
1896 int idx = 0;
1897 v_U8_t valid_idx = 0;
1898 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07001899 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001900 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001901
Jeff Johnson295189b2012-06-20 16:38:30 -07001902 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1903 {
1904 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
1905 {
1906 pHddStaCtx->conn_info.staId[ idx ] = 0;
1907
1908 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
1909
1910 fSuccess = TRUE;
Ravi Joshi8a934352013-09-25 16:46:58 -07001911
Jeff Johnson295189b2012-06-20 16:38:30 -07001912 // Note the deleted Index, if its 0 we need special handling
1913 del_idx = idx;
Ravi Joshi8a934352013-09-25 16:46:58 -07001914
1915 empty_slots++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 }
1917 else
1918 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001919 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001920 {
1921 valid_idx = idx;
1922 }
Ravi Joshi8a934352013-09-25 16:46:58 -07001923 else
1924 {
1925 // Found an empty slot
1926 empty_slots++;
1927 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 }
1929 }
1930
Ravi Joshi8a934352013-09-25 16:46:58 -07001931 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
1932 {
1933 // Last peer departed, set the IBSS state appropriately
1934 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001935 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07001936 "Last IBSS Peer Departed!!!" );
1937 }
1938
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 // Find next active staId, to have a valid sta trigger for TL.
1940 if (fSuccess == TRUE)
1941 {
1942 if (del_idx == 0)
1943 {
1944 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
1945 {
1946 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
1947 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
1948 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
1949
1950 pHddStaCtx->conn_info.staId[valid_idx] = 0;
1951 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
1952 }
1953 }
1954 }
1955 return( fSuccess );
1956}
1957
1958/**============================================================================
1959 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001960 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07001961 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001962
Jeff Johnson295189b2012-06-20 16:38:30 -07001963 ===========================================================================*/
1964static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
1965{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001966 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05301967 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1968 "%s: IBSS Connect Indication from SME!!! "
1969 "Set HDD connState to eConnectionState_IbssConnected",
1970 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
1972 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
1973
1974 // Save the connection info from CSR...
1975 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
1976
1977 // Send the bssid address to the wext.
1978 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001979 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001980 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1981 if (NULL == bss)
1982 {
1983 hddLog(VOS_TRACE_LEVEL_ERROR,
1984 "%s: %s: unable to create IBSS entry",
1985 __func__, pAdapter->dev->name);
1986 return eHAL_STATUS_FAILURE;
1987 }
Yue Maf49ba872013-08-19 12:04:25 -07001988 cfg80211_put_bss(
1989#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1990 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
1991#endif
1992 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001993
1994 return( eHAL_STATUS_SUCCESS );
1995}
1996/**============================================================================
1997 *
Mukul Sharmad2589a52014-04-23 21:06:25 +05301998 @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
1999 suspend related data which was cleared during roaming in FWR.
2000
2001 ===========================================================================*/
2002static void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
2003{
2004 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
2005 hdd_adapter_t *pAdapter;
2006 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
2007 ENTER();
2008
2009 spin_lock(&pHddCtx->filter_lock);
2010 if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
2011 {
2012 pHddCtx->sus_res_mcastbcast_filter =
2013 pHddCtx->configuredMcastBcastFilter;
2014 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
2015 hddLog(VOS_TRACE_LEVEL_INFO, FL("offload: callback to associated"));
2016 hddLog(VOS_TRACE_LEVEL_INFO,
2017 FL("saving configuredMcastBcastFilter = %d"),
2018 pHddCtx->configuredMcastBcastFilter);
2019 hddLog(VOS_TRACE_LEVEL_INFO,
2020 FL("offload: calling hdd_conf_mcastbcast_filter"));
2021 }
2022 spin_unlock(&pHddCtx->filter_lock);
2023
2024 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
2025 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
2026 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
2027
2028 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
2029 //No need to configure GTK Offload from here because it might possible
2030 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
2031 //be handled as part of cfg80211_set_rekey_data processing.
2032 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
2033 {
2034 pAdapter = pAdapterNode->pAdapter;
2035 if( pAdapter &&
2036 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
2037 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
2038 {
2039 if (pHddCtx->cfg_ini->fhostArpOffload)
2040 {
2041 //Configure ARPOFFLOAD
2042 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
2043 if (!VOS_IS_STATUS_SUCCESS(vstatus))
2044 {
2045 hddLog(VOS_TRACE_LEVEL_ERROR,
2046 FL("Failed to disable ARPOffload Feature %d"), vstatus);
2047 }
2048 }
2049#ifdef WLAN_NS_OFFLOAD
2050 //Configure NSOFFLOAD
2051 if (pHddCtx->cfg_ini->fhostNSOffload)
2052 {
2053 hdd_conf_ns_offload(pAdapter, TRUE);
2054 }
2055#endif
Mukul Sharma25e70c32014-05-22 12:50:24 +05302056#ifdef WLAN_FEATURE_PACKET_FILTERING
2057 /* During suspend, configure MC Addr list filter to the firmware
2058 * function takes care of checking necessary conditions before
2059 * configuring.
2060 */
2061 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
2062#endif
Mukul Sharmad2589a52014-04-23 21:06:25 +05302063 }
2064 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2065 pAdapterNode = pNext;
2066 }
2067 EXIT();
2068}
2069
2070/**============================================================================
2071 *
Jeff Johnson295189b2012-06-20 16:38:30 -07002072 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002073
Jeff Johnson295189b2012-06-20 16:38:30 -07002074 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002075static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2076 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002077 eCsrRoamResult roamResult )
2078{
2079 eCsrEncryptionType connectedCipherAlgo;
2080 v_BOOL_t fConnected = FALSE;
2081 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2082 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2083 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2084 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07002085
2086 if (NULL == pRoamInfo)
2087 {
2088 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
2089 return eHAL_STATUS_FAILURE;
2090 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002091 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002092 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07002093 // not require upper layer authentication) we can put TL directly into 'authenticated'
2094 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002095 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2096 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
2097 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002098
Jeff Johnson295189b2012-06-20 16:38:30 -07002099 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2100 if( fConnected )
2101 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002102 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
2103 {
2104 v_U8_t staId;
2105
2106 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2107
2108 if ( 0 == memcmp( pRoamInfo->peerMac,
2109 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
2110 {
2111 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2112 IBSS_BROADCAST_STAID);
2113 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2114 }
2115 else
2116 {
2117 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
2118 (v_MACADDR_t*)pRoamInfo->peerMac,
2119 &staId);
2120 if ( VOS_STATUS_SUCCESS == vosStatus )
2121 {
2122 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2123 "WLAN TL STA Ptk Installed for STAID=%d", staId);
2124 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2125 staId);
2126 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2127 }
2128 }
2129 }
2130 else
2131 {
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302132 // TODO: Considering getting a state machine in HDD later.
2133 // This routine is invoked twice. 1)set PTK 2)set GTK.
2134 // The folloing if statement will be TRUE when setting GTK.
2135 // At this time we don't handle the state in detail.
2136 // Related CR: 174048 - TL not in authenticated state
2137 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
2138 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
2139 {
2140 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
2141 "for StaId= %d. Changing TL state to AUTHENTICATED",
2142 pHddStaCtx->conn_info.staId[ 0 ] );
2143
2144 // Connections that do not need Upper layer authentication,
2145 // transition TL to 'Authenticated' state after the keys are set.
2146 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2147 pHddStaCtx->conn_info.staId[ 0 ],
2148 WLANTL_STA_AUTHENTICATED );
2149
2150 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Mukul Sharmad2589a52014-04-23 21:06:25 +05302151 //Need to call offload because when roaming happen at that time fwr
2152 //clean offload info as part of the DelBss
2153 // No need to configure offload if host was not suspended
2154 spin_lock(&pHddCtx->filter_lock);
2155 if(pHddCtx->hdd_wlan_suspended)
2156 {
2157 spin_unlock(&pHddCtx->filter_lock);
2158 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
2159 }
2160 else
2161 {
2162 spin_unlock(&pHddCtx->filter_lock);
2163 }
Mukul Sharma84f27252014-07-14 18:11:42 +05302164#ifdef DEBUG_ROAM_DELAY
2165 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
2166#endif
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302167 }
2168 else
2169 {
2170 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2171 pHddStaCtx->conn_info.staId[ 0 ]);
Mukul Sharma84f27252014-07-14 18:11:42 +05302172#ifdef DEBUG_ROAM_DELAY
2173 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
2174#endif
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302175 }
2176
2177 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002179 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302180 else
2181 {
2182 // possible disassoc after issuing set key and waiting set key complete
2183 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2184 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002185
Jeff Johnson295189b2012-06-20 16:38:30 -07002186 EXIT();
2187 return( eHAL_STATUS_SUCCESS );
2188}
2189/**============================================================================
2190 *
2191 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2192 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002193static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002194 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002195{
Jeff Johnson295189b2012-06-20 16:38:30 -07002196 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2197
2198 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2199 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2200 {
2201 struct iw_michaelmicfailure msg;
2202 union iwreq_data wreq;
2203 memset(&msg, '\0', sizeof(msg));
2204 msg.src_addr.sa_family = ARPHRD_ETHER;
2205 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002206 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2207 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002208
Jeff Johnson295189b2012-06-20 16:38:30 -07002209 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2210 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002211 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002212 msg.flags = IW_MICFAILURE_PAIRWISE;
2213 memset(&wreq, 0, sizeof(wreq));
2214 wreq.data.length = sizeof(msg);
2215 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002216 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002217 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002218 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2219 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2220 NL80211_KEYTYPE_GROUP :
2221 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002222 pRoamInfo->u.pMICFailureInfo->keyId,
2223 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002224 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002225
Jeff Johnson295189b2012-06-20 16:38:30 -07002226 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002227
Jeff Johnson295189b2012-06-20 16:38:30 -07002228 return( eHAL_STATUS_SUCCESS );
2229}
2230
2231/**============================================================================
2232 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002233 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002234 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002235
Jeff Johnson295189b2012-06-20 16:38:30 -07002236 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002237static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2238 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002239 eCsrRoamResult roamResult )
2240{
2241 VOS_STATUS vosStatus;
2242
2243 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2244 switch( roamResult )
2245 {
2246 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2247 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002248 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002249 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002250
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002251 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002252 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2253 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2254 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002255 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002256
Jeff Johnson295189b2012-06-20 16:38:30 -07002257 if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
2258 {
2259 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2260 "New IBSS peer but we already have the max we can handle. Can't register this one" );
2261 break;
2262 }
2263
2264 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2265
Shailender Karmuchia734f332013-04-19 14:02:48 -07002266 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2267 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2268 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2269
2270 // Register the Station with TL for the new peer.
Jeff Johnson295189b2012-06-20 16:38:30 -07002271 vosStatus = hdd_roamRegisterSTA( pAdapter,
2272 pRoamInfo,
2273 pRoamInfo->staId,
2274 (v_MACADDR_t *)pRoamInfo->peerMac,
2275 pRoamInfo->pBssDesc );
2276 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2277 {
2278 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002279 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002280 vosStatus, vosStatus );
2281 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002282 pHddStaCtx->ibss_sta_generation++;
2283 memset(&staInfo, 0, sizeof(staInfo));
2284 staInfo.filled = 0;
2285 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2286
2287 cfg80211_new_sta(pAdapter->dev,
2288 (const u8 *)pRoamInfo->peerMac,
2289 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002290
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002291 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2292 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2293 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2294 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2295 {
2296 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2297 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2298 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2299
2300 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002301 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002302 pHddStaCtx->ibss_enc_key.encType);
2303
2304 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2305 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2306
2307 if ( VOS_STATUS_SUCCESS != vosStatus )
2308 {
2309 hddLog(VOS_TRACE_LEVEL_ERROR,
2310 "%s: sme_RoamSetKey failed, returned %d",
2311 __func__, vosStatus);
2312 return VOS_STATUS_E_FAILURE;
2313 }
2314 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002315 netif_carrier_on(pAdapter->dev);
2316 netif_tx_start_all_queues(pAdapter->dev);
2317 break;
2318 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002319
Jeff Johnson295189b2012-06-20 16:38:30 -07002320 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2321 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002322
Jeff Johnson295189b2012-06-20 16:38:30 -07002323 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002324
Jeff Johnson295189b2012-06-20 16:38:30 -07002325 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002326 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002327 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2328 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002329 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002330
Ravi Joshicc57ed42013-10-12 16:31:25 -07002331 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002332 {
2333 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2334 "IBSS peer departed by cannot find peer in our registration table with TL" );
2335 }
2336
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002337 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002338 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2339 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2340 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2341 pRoamInfo->staId );
2342
Jeff Johnson295189b2012-06-20 16:38:30 -07002343 hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
2344
2345 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002346 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002347
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002348 cfg80211_del_sta(pAdapter->dev,
2349 (const u8 *)&pRoamInfo->peerMac,
2350 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002351 break;
2352 }
2353 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2354 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002355 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2356 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002357 // Stop only when we are inactive
2358 netif_tx_disable(pAdapter->dev);
2359 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05302360 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2361 "%s: Set HDD connState to eConnectionState_NotConnected",
2362 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002363 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002364
Jeff Johnson295189b2012-06-20 16:38:30 -07002365 // Send the bssid address to the wext.
2366 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2367 // clean up data path
2368 hdd_disconnect_tx_rx(pAdapter);
2369 break;
2370 }
2371 default:
2372 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002373
Jeff Johnson295189b2012-06-20 16:38:30 -07002374 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002375
Jeff Johnson295189b2012-06-20 16:38:30 -07002376 return( eHAL_STATUS_SUCCESS );
2377}
2378
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002379#ifdef FEATURE_WLAN_TDLS
2380/**============================================================================
2381 *
2382 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2383 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2384 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002385
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002386 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002387VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
2388 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002389{
2390 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002391 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002392 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2393 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002394 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2395 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002396 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2397 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002398
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002399 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2400 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002401 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002402 "%s not connected. ignored", __func__);
2403 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002404 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002405
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002406 /*
2407 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2408 * be peer MAC, here we are wokrking on direct Link
2409 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002410 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002411
2412 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002413
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002414 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002415 sizeof(tSirMacAddr) );
2416
2417 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2418 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2419
2420 /* set the QoS field appropriately ..*/
2421 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2422 : (staDesc.ucQosEnabled = 0) ;
2423
2424 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002425 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002426
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002427 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002428
2429 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002430 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002431
Shailender Karmuchia734f332013-04-19 14:02:48 -07002432 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002433 * UMA is ready we inform TL to do frame translation.
2434 */
2435 staDesc.ucSwFrameTXXlation = 1;
2436 staDesc.ucSwFrameRXXlation = 1;
2437 staDesc.ucAddRmvLLC = 1;
2438
2439 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002440 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002441
2442 /* tdls Direct Link do not need bcastSig */
2443 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002444
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002445#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2446 if(staDesc.ucProtectedFrame)
2447 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2448 else
2449 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2450#endif
2451
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302452 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002453
Shailender Karmuchia734f332013-04-19 14:02:48 -07002454 /* Register the Station with TL... */
2455 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2456 hdd_rx_packet_cbk,
2457 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002458 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002459
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002460 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2461 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002462 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002463 "%s: WLANTL_RegisterSTAClient() failed to register. "
2464 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002465 return vosStatus;
2466 }
2467
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002468 if ( cfg_param->dynSplitscan &&
2469 ( VOS_TIMER_STATE_RUNNING !=
2470 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2471 {
2472 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2473 cfg_param->trafficMntrTmrForSplitScan);
2474 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002475 return( vosStatus );
2476}
2477
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002478static VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
2479{
2480 VOS_STATUS vosStatus;
2481 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2482 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2483 {
2484 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2485 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002486 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002487 __func__, staId, vosStatus, vosStatus );
2488 }
2489 return( vosStatus );
2490}
2491
2492
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002493/*
2494 * HDD interface between SME and TL to ensure TDLS client registration with
2495 * TL in case of new TDLS client is added and deregistration at the time
2496 * TDLS client is deleted.
2497 */
2498
Shailender Karmuchia734f332013-04-19 14:02:48 -07002499eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2500 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002501 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002502 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002503 eCsrRoamResult roamResult)
2504{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002505 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002506 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002507 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002508
2509#ifdef WLAN_FEATURE_TDLS_DEBUG
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302510 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002511 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2512 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2513 "ADD_TDLS_PEER" :
2514 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2515 "DEL_TDLS_PEER" :
2516 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2517 "DEL_TDLS_PEER_IND" :
2518 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2519 "DEL_ALL_TDLS_PEER_IND" :
2520 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2521 "UPDATE_TDLS_PEER" :
2522 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2523 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2524 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002525#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002526 switch( roamResult )
2527 {
2528 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2529 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002530 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2531 {
2532 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002533 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002534 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002535 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002536 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002537
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002538 /* check if there is available index for this new TDLS STA */
2539 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2540 {
2541 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2542 {
2543 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2544 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2545
2546 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002547 ("TDLS: STA IDX at %d is %d "
2548 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002549 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002550 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002551
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002552 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002553 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2554 status = eHAL_STATUS_SUCCESS ;
2555 break ;
2556 }
2557 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002558 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002559 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002560 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002561 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2562 "wlan_hdd_tdls_set_sta_id() failed");
2563 return VOS_FALSE;
2564 }
2565
2566 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302567 /* store the ucast signature , if required for further reference. */
2568
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002569 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302570 /* start TDLS client registration with TL */
2571 status = hdd_roamRegisterTDLSSTA( pAdapter,
2572 pRoamInfo->peerMac,
2573 pRoamInfo->staId,
2574 pRoamInfo->ucastSig);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002575 }
2576 else
2577 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002578 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002579 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002580 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002581 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002582 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002583 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002584 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002585 break ;
2586 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002587 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
2588 {
2589 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2590 {
2591 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2592 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
2593 }
2594 /* store the ucast signature which will be used later when
2595 * registering to TL
2596 */
2597 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
2598 complete(&pAdapter->tdls_add_station_comp);
2599 break;
2600 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302601 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
2602 {
2603 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2604 {
2605 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2606 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
2607 }
2608 complete(&pAdapter->tdls_link_establish_req_comp);
2609 break;
2610 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002611 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002612 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002613 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002614 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002615 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002616 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2617 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002618 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002619 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002620 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2621
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302622 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002623 if (NULL != curr_peer && TDLS_IS_CONNECTED(curr_peer))
2624 {
2625 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2626 wlan_hdd_tdls_decrement_peer_count(pAdapter);
2627 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002628 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002629
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002630 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2631 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
2632 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002633 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002634 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002635 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002636 break ;
2637 }
2638 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002639 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002640 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002641 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002642 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
2643 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002644 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002645 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2646 "%s: Sending teardown to supplicant with reason code %u",
2647 __func__, pRoamInfo->reasonCode);
2648
2649#ifdef CONFIG_TDLS_IMPLICIT
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302650 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002651 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002652#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002653 status = eHAL_STATUS_SUCCESS ;
2654 break ;
2655 }
2656 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
2657 {
2658 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002659 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002660 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002661 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2662 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002663 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002664 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002665 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002666 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002667 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002668 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
2669 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
2670 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002671
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002672 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002673 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002674 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2675 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002676
2677 status = eHAL_STATUS_SUCCESS ;
2678 }
2679 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05302680 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002681 break ;
2682 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002683 default:
2684 {
2685 break ;
2686 }
2687 }
2688
2689 return status ;
2690}
2691#endif
2692
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002693static void iw_full_power_cbfn (void *pContext, eHalStatus status)
2694{
2695 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
2696 hdd_context_t *pHddCtx = NULL;
2697 int ret;
2698
2699 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
2700 {
2701 hddLog(VOS_TRACE_LEVEL_ERROR,
2702 "%s: Bad param, pAdapter [%p]",
2703 __func__, pAdapter);
2704 return;
2705 }
2706
2707 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2708 ret = wlan_hdd_validate_context(pHddCtx);
2709 if (0 != ret)
2710 {
2711 hddLog(VOS_TRACE_LEVEL_ERROR,
2712 "%s: HDD context is not valid (%d)", __func__, ret);
2713 return;
2714 }
2715
2716 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
2717 {
2718 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
2719 }
2720}
2721
Shailender Karmuchia734f332013-04-19 14:02:48 -07002722eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002723 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
2724{
2725 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2726 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302727 hdd_wext_state_t *pWextState = NULL;
2728 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002729 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07002730 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002731
2732 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002733 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002734 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002735
2736 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302737 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002738 {
2739 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302740 "invalid adapter or adapter has invalid magic");
2741 return eHAL_STATUS_FAILURE;
2742 }
2743
2744 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2745 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2746
2747 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2748 {
2749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2750 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002751 return eHAL_STATUS_FAILURE;
2752 }
2753
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 switch( roamStatus )
2755 {
2756 case eCSR_ROAM_SESSION_OPENED:
2757 if(pAdapter != NULL)
2758 {
2759 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2760 complete(&pAdapter->session_open_comp_var);
2761 }
2762 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002763
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002764#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
2765 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07002767 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07002768 * interface down */
2769 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05302770 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
2771 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05302772 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07002773 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2774 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2775 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002776 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2777 }
2778 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05302779 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002780 break;
2781
2782 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002783 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07002784 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07002785 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 // eCSR_ROAM_SHOULD_ROAM will be received.
2787 // Where in we will not mark the link down
2788 // Also we want to stop tx at this point when we will be
2789 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002790 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002791 {
2792 struct net_device *dev = pAdapter->dev;
2793 netif_tx_disable(dev);
Mukul Sharma84f27252014-07-14 18:11:42 +05302794#ifdef DEBUG_ROAM_DELAY
2795 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
2796#endif
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002797 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002798 * Deregister for this STA with TL with the objective to flush
2799 * all the packets for this STA from wmm_tx_queue. If not done here,
2800 * we would run into a race condition (CR390567) wherein TX
2801 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2802 * been deleted. And, these packets get assigned with a STA idx of
2803 * self-sta (since the peer STA has been deleted) and get transmitted
2804 * on the new channel before the reassoc request. Since there will be
2805 * no ACK on the new channel, each packet gets retransmitted which
2806 * takes several seconds before the transmission of reassoc request.
2807 * This leads to reassoc-timeout and roam failure.
2808 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002809 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2810 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2811 {
2812 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2813 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2814 pHddStaCtx->conn_info.staId[0], status, status );
2815 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002816 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 }
2818 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002819 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002820 break;
2821#endif
2822
2823 case eCSR_ROAM_SHOULD_ROAM:
2824 // Dont need to do anything
2825 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 struct net_device *dev = pAdapter->dev;
2827 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2828 // notify apps that we can't pass traffic anymore
2829 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002830#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002831 if (pHddStaCtx->ft_carrier_on == FALSE)
2832 {
2833#endif
2834 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002835#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002836 }
2837#endif
2838
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002839#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002840 //We should clear all sta register with TL, for now, only one.
2841 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2842 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2843 {
2844 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2845 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2846 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002847 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002848 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002849#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002850 }
2851 break;
2852 case eCSR_ROAM_LOSTLINK:
2853 case eCSR_ROAM_DISASSOCIATED:
2854 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2856 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05302857 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2859 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07002860 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2861 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302862 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07002863 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08002864
2865 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
2866 pHddCtx->configuredMcastBcastFilter =
2867 pHddCtx->sus_res_mcastbcast_filter;
2868 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
2869 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302870
Amar Singhald53568e2013-09-26 11:03:45 -07002871 hddLog(VOS_TRACE_LEVEL_INFO,
2872 "offload: disassociation happening, restoring configuredMcastBcastFilter");
2873 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
2874 pHddCtx->configuredMcastBcastFilter);
2875 hddLog(VOS_TRACE_LEVEL_INFO,
2876 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07002877 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2878 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002879#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302880 /* Call to clear any MC Addr List filter applied after
2881 * successful connection.
2882 */
2883 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002884#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002885 }
2886 break;
2887 case eCSR_ROAM_IBSS_LEAVE:
2888 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2889 "****eCSR_ROAM_IBSS_LEAVE****");
2890 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2891 break;
2892 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2893 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2894 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302895 // To Do - address probable memory leak with WEP encryption upon successful association
2896 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07002897 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302898 //Clear saved connection information in HDD
2899 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05302901 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002902
2903 break;
2904 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002905 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002906 pRoamInfo, roamId, roamStatus, roamResult );
2907 break;
2908 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07002909 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
2910 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 break;
2912
2913 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2914 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002915 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002916
2917 case eCSR_ROAM_MIC_ERROR_IND:
2918 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2919 break;
2920
2921 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002922 {
2923 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2924
2925 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002926 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
2927 (TRUE == pHddCtx->hdd_wlan_suspended) &&
2928 (eCSR_ROAM_RESULT_NONE == roamResult))
2929 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002930 /* Send DTIM period to the FW; only if the wlan is already
2931 in suspend. This is the case with roaming (reassoc),
2932 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
2933 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
2934 before the ENTER_BMPS_REQ ensures Listen Interval is
2935 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002936 hdd_set_pwrparams(pHddCtx);
2937 pHddStaCtx->hdd_ReassocScenario = VOS_FALSE;
2938
2939 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002940 if due to unexpected scenario, if we are in BMPS,
2941 then trigger Exit and Enter BMPS to take DTIM period
2942 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002943 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
2944 {
2945 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
2946
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08002947 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
2948 iw_full_power_cbfn, pAdapter,
2949 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002950 }
2951 }
2952 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05302953 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002954 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002955 break;
2956#ifdef WLAN_FEATURE_VOWIFI_11R
2957 case eCSR_ROAM_FT_RESPONSE:
2958 hdd_SendFTEvent(pAdapter);
2959 break;
2960#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002961#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002962 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002963 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07002964 {
2965 /* Notify the supplicant of a new candidate */
2966 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
2967 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002968 break;
2969#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002970
Yue Maef608272013-04-08 23:09:17 -07002971#ifdef FEATURE_WLAN_LFR_METRICS
2972 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
2973 /* This event is to notify pre-auth initiation */
2974 if (VOS_STATUS_SUCCESS !=
2975 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
2976 {
2977 halStatus = eHAL_STATUS_FAILURE;
2978 }
2979 break;
2980 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
2981 /* This event will notify pre-auth completion in case of success */
2982 if (VOS_STATUS_SUCCESS !=
2983 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2984 pRoamInfo, 1))
2985 {
2986 halStatus = eHAL_STATUS_FAILURE;
2987 }
2988 break;
2989 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
2990 /* This event will notify pre-auth completion in case of failure. */
2991 if (VOS_STATUS_SUCCESS !=
2992 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2993 pRoamInfo, 0))
2994 {
2995 halStatus = eHAL_STATUS_FAILURE;
2996 }
2997 break;
2998 case eCSR_ROAM_HANDOVER_SUCCESS:
2999 /* This event is to notify handover success.
3000 It will be only invoked on success */
3001 if (VOS_STATUS_SUCCESS !=
3002 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
3003 {
3004 halStatus = eHAL_STATUS_FAILURE;
3005 }
3006 break;
3007#endif
3008
Jeff Johnson295189b2012-06-20 16:38:30 -07003009 case eCSR_ROAM_INDICATE_MGMT_FRAME:
3010 hdd_indicateMgmtFrame( pAdapter,
3011 pRoamInfo->nFrameLength,
3012 pRoamInfo->pbFrames,
3013 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05303014 pRoamInfo->rxChan,
3015 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07003016 break;
3017 case eCSR_ROAM_REMAIN_CHAN_READY:
3018 hdd_remainChanReadyHandler( pAdapter );
3019 break;
3020 case eCSR_ROAM_SEND_ACTION_CNF:
3021 hdd_sendActionCnf( pAdapter,
3022 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
3023 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003024#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08003025 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003026 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08003027 roamId, roamStatus, roamResult );
3028 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003029 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
3030 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
3031 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003032#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003033#ifdef WLAN_FEATURE_11W
3034 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
3035 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
3036 pRoamInfo->pbFrames,
3037 pRoamInfo->frameType);
3038 break;
3039#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003040#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003041 case eCSR_ROAM_TSM_IE_IND:
3042 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
3043 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
3044 break;
3045
3046 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
3047 {
3048 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
3049 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
3050 {
3051 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
3052 }
3053 break;
3054 }
3055
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003056 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003057 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003058 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003059 break;
3060 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003061
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003062 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003063 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003064 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003065 break;
3066 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003067#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07003068 default:
3069 break;
3070 }
3071 return( halStatus );
3072}
Shailender Karmuchia734f332013-04-19 14:02:48 -07003073eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003074{
3075 eCsrAuthType auth_type;
3076 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003077 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003078 {
3079 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003080 } else
3081 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 {
3083 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003084 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003085#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003086 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003087 {
3088 // Check for 11r FT Authentication with PSK
3089 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003090 } else
3091 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 {
3093 // Check for 11R FT Authentication with 802.1X
3094 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003095 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003096#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003097#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003098 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003099 {
3100 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
3101 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003102#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07003103#ifdef WLAN_FEATURE_11W
3104 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
3105 {
3106 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3107 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303108 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
3109 {
3110 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3111 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003112#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003113 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003114 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3115 }
3116 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003117}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003118
Shailender Karmuchia734f332013-04-19 14:02:48 -07003119eCsrAuthType
3120hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003121{
3122 eCsrAuthType auth_type;
3123 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003124 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003125 {
3126 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003127 } else
3128 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003129 {
3130 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003131 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003132#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003133 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 {
3135 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003136 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003137#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003138 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003139 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3140 }
3141 hddLog(LOG1, FL("auth_type: %d"), auth_type);
3142 return auth_type;
3143}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003144
Shailender Karmuchia734f332013-04-19 14:02:48 -07003145eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003146hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003147{
3148 eCsrEncryptionType cipher_type;
3149 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003150 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003151 {
3152 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003153 }
3154 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003155 {
3156 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003157 }
3158 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003159 {
3160 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003161 }
3162 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003163 {
3164 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003165 }
3166 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
3167 {
3168 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3169 }
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/* To find if the MAC address is NULL */
3178static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3179{
3180 int i;
3181 for (i = 0; i < length; i++)
3182 {
3183 if (0x00 != (macAddr[i]))
3184 {
3185 return FALSE;
3186 }
3187 }
3188 return TRUE;
3189} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003190
Shailender Karmuchia734f332013-04-19 14:02:48 -07003191eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003192hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003193{
3194 eCsrEncryptionType cipher_type;
3195 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003196 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003197 {
3198 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003199 } else
3200 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 {
3202 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003203 } else
3204 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003205 {
3206 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003207 } else
3208 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003209 {
3210 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003211 } else
3212 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003213 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003214 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3215 } else
3216 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3218 }
3219 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3220 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003221}
Jeff Johnson295189b2012-06-20 16:38:30 -07003222
Shailender Karmuchia734f332013-04-19 14:02:48 -07003223static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3224 struct ether_addr *pBssid,
3225 eCsrEncryptionType *pEncryptType,
3226 eCsrEncryptionType *mcEncryptType,
3227 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003228#ifdef WLAN_FEATURE_11W
3229 u_int8_t *pMfpRequired,
3230 u_int8_t *pMfpCapable,
3231#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003232 u_int16_t gen_ie_len,
3233 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003234{
3235 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003236 eHalStatus result;
3237 tDot11fIERSN dot11RSNIE;
3238 tDot11fIEWPA dot11WPAIE;
3239 tANI_U32 i;
3240 tANI_U8 *pRsnIe;
3241 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003242 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003243 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003244
3245 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3246 flag to 0 */
3247 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3248 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3249
3250 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003251 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
3252 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303253 {
3254 hddLog(LOGE, "%s: Invalid DOT11F IE Length passed :%d",
3255 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 return -EINVAL;
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303257 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003258 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003259 if ( gen_ie[0] == DOT11F_EID_RSN)
3260 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003261 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003262 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003263 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3264 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303265 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3266 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003267 return -EINVAL;
3268 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003269 // Skip past the EID byte and length byte
3270 pRsnIe = gen_ie + 2;
3271 RSNIeLen = gen_ie_len - 2;
3272 // Unpack the RSN IE
3273 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3274 pRsnIe,
3275 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003276 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003277 // Copy out the encryption and authentication types
3278 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003279 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003280 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003281 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003282 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003283 but probably I suspect we can do something different*/
3284 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003285 // Just translate the FIRST one
3286 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3287 //dot11RSNIE.pwise_cipher_suite_count
3288 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3289 //dot11RSNIE.gp_cipher_suite_count
3290 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003291#ifdef WLAN_FEATURE_11W
3292 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3293 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3294#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003295 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003296 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003297 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003298 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303300 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003301 break;
3302 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003303 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003304 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303305 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003306 break;
3307 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003308 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003309 // For right now, I assume setASSOCIATE() has passed in the bssid.
3310 vos_mem_copy(PMKIDCache[i].BSSID,
3311 pBssid, ETHER_ADDR_LEN);
3312 vos_mem_copy(PMKIDCache[i].PMKID,
3313 dot11RSNIE.pmkid[i],
3314 CSR_RSN_PMKID_SIZE);
3315 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003316
3317 if (updatePMKCache)
3318 {
3319 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003320 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003321 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003322 // Finally set the PMKSA ID Cache in CSR
3323 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3324 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05303325 dot11RSNIE.pmkid_count,
3326 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07003327 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003328 }
3329 else if (gen_ie[0] == DOT11F_EID_WPA)
3330 {
3331 // Validity checks
3332 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3333 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3334 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303335 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3336 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003337 return -EINVAL;
3338 }
3339 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003340 pRsnIe = gen_ie + 2 + 4;
3341 RSNIeLen = gen_ie_len - (2 + 4);
3342 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003343 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3344 pRsnIe,
3345 RSNIeLen,
3346 &dot11WPAIE);
3347 // Copy out the encryption and authentication types
3348 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003349 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003350 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003351 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003352 //dot11WPAIE.auth_suite_count
3353 // Just translate the FIRST one
3354 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3355 //dot11WPAIE.unicast_cipher_count
3356 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3357 //dot11WPAIE.unicast_cipher_count
3358 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3359 }
3360 else
3361 {
3362 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003363 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003364 }
3365 return 0;
3366}
3367int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3368{
3369 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3370 v_U32_t status = 0;
3371 eCsrEncryptionType RSNEncryptType;
3372 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003373#ifdef WLAN_FEATURE_11W
3374 u_int8_t RSNMfpRequired;
3375 u_int8_t RSNMfpCapable;
3376#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003377 struct ether_addr bSsid; // MAC address of assoc peer
3378 // MAC address of assoc peer
3379 // But, this routine is only called when we are NOT associated.
3380 vos_mem_copy(bSsid.ether_addr_octet,
3381 pWextState->roamProfile.BSSIDs.bssid,
3382 sizeof(bSsid.ether_addr_octet));
3383 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3384 {
3385 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003386 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003387 else
3388 {
3389 return 0;
3390 }
3391 // The actual processing may eventually be more extensive than this.
3392 // Right now, just consume any PMKIDs that are sent in by the app.
3393 status = hdd_ProcessGENIE(pAdapter,
3394 &bSsid, // MAC address of assoc peer
3395 &RSNEncryptType,
3396 &mcRSNEncryptType,
3397 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003398#ifdef WLAN_FEATURE_11W
3399 &RSNMfpRequired,
3400 &RSNMfpCapable,
3401#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003402 pWextState->WPARSNIE[1]+2,
3403 pWextState->WPARSNIE);
3404 if (status == 0)
3405 {
3406 // Now copy over all the security attributes you have parsed out
3407 pWextState->roamProfile.EncryptionType.numEntries = 1;
3408 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003409
Jeff Johnson295189b2012-06-20 16:38:30 -07003410 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3411 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003412
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003413 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3414 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3415 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3416 {
3417 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3418 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3419 either AES/TKIP based on group cipher configuration
3420 mentioned in the wpa_supplicant.conf.*/
3421
3422 /*Set the unicast cipher same as multicast cipher*/
3423 pWextState->roamProfile.EncryptionType.encryptionType[0]
3424 = mcRSNEncryptType;
3425 }
3426
Chet Lanctot186b5732013-03-18 10:26:30 -07003427#ifdef WLAN_FEATURE_11W
3428 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3429 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3430#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003431 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003432 }
3433 return 0;
3434}
3435int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3436{
3437 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3438 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3439 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3440 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003441
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003443 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003444
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 switch( pHddStaCtx->conn_info.authType)
3446 {
3447 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003448#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003449 case eCSR_AUTH_TYPE_CCKM_WPA:
3450 case eCSR_AUTH_TYPE_CCKM_RSN:
3451#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003452 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3453
Jeff Johnson295189b2012-06-20 16:38:30 -07003454 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003455 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003456 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003457
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003458#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003459 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3460 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3461 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003462 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003463 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3464 } else
3465 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003466 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003467 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 } else
3469#endif
3470 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3471 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003472 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3473 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3475 == IW_AUTH_KEY_MGMT_PSK) {
3476 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003477 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003479 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003480 }
3481 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003482#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003483 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3484 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3485 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003486 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003487 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003488 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003489 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003490 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003491 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003492 } else
3493#endif
3494
3495#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003496 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3497 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003499 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003500 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003501 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003502 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3503 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003504 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003505 } else
3506#endif
3507
Chet Lanctot186b5732013-03-18 10:26:30 -07003508#ifdef WLAN_FEATURE_11W
3509 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3510 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3511 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303512 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
3513 pRoamProfile->AuthType.authType[0] =
3514 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3515 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003516#endif
3517
Shailender Karmuchia734f332013-04-19 14:02:48 -07003518 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003520 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3521 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003522 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3523 == IW_AUTH_KEY_MGMT_PSK) {
3524 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003525 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003526 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003527 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003528 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003529 break;
3530
Jeff Johnson295189b2012-06-20 16:38:30 -07003531 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003532
3533 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003534 break;
3535 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003536
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003537#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08003538 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003539#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003540 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3541 break;
3542 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003543
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003545 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003546
Jeff Johnson295189b2012-06-20 16:38:30 -07003547 EXIT();
3548 return 0;
3549}
3550
3551/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003552
3553 \brief iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003554 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07003555 to the CSR roam profile.
3556
Jeff Johnson295189b2012-06-20 16:38:30 -07003557 \param - dev - Pointer to the net device.
3558 - info - Pointer to the iw_request_info.
3559 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003560 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003561 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003562
Jeff Johnson295189b2012-06-20 16:38:30 -07003563 --------------------------------------------------------------------------*/
3564
Shailender Karmuchia734f332013-04-19 14:02:48 -07003565int iw_set_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003566 struct iw_request_info *info,
3567 union iwreq_data *wrqu, char *extra)
3568{
3569 v_U32_t status = 0;
3570 hdd_wext_state_t *pWextState;
3571 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3572 v_U32_t roamId;
3573 tCsrRoamProfile *pRoamProfile;
3574 eMib_dot11DesiredBssType connectedBssType;
3575 eCsrAuthType RSNAuthType;
3576 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3577 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003578
3579 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3580
Jeff Johnson295189b2012-06-20 16:38:30 -07003581 ENTER();
3582
3583 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3584 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303585 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07003586 "%s:LOGP in Progress. Ignore!!!",__func__);
3587 return 0;
3588 }
3589
3590 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
3591 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
3592 return -EBUSY;
3593 }
3594 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
3595 return -EINVAL;
3596 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003597 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003598 {
3599 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
3600 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
3601 {
3602 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003603 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07003604 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3605 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
3606
3607 if(VOS_STATUS_SUCCESS == vosStatus)
3608 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3609 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3610 }
3611 }
3612 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003613 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003614 {
3615 return -EINVAL;
3616 }
3617 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003618 /** when cfg80211 defined, wpa_supplicant wext driver uses
3619 zero-length, null-string ssid for force disconnection.
3620 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07003621 driver MUST return success */
3622 if ( 0 == wrqu->essid.length ) {
3623 return 0;
3624 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003625
3626 status = hdd_wmm_get_uapsd_mask(pAdapter,
3627 &pWextState->roamProfile.uapsd_mask);
3628 if (VOS_STATUS_SUCCESS != status)
3629 {
3630 pWextState->roamProfile.uapsd_mask = 0;
3631 }
3632 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003633
Jeff Johnson295189b2012-06-20 16:38:30 -07003634 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003635
3636 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003637 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
3638 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
3639 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003640
Jeff Johnson295189b2012-06-20 16:38:30 -07003641 //set gen ie
3642 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
3643
3644 //set auth
3645 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
3646 }
3647#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003648 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 if (pAdapter->wapi_info.nWapiMode)
3650 {
3651 switch (pAdapter->wapi_info.wapiAuthMode)
3652 {
3653 case WAPI_AUTH_MODE_PSK:
3654 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003655 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003656 pRoamProfile->AuthType.numEntries = 1;
3657 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3658 break;
3659 }
3660 case WAPI_AUTH_MODE_CERT:
3661 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003662 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003663 pRoamProfile->AuthType.numEntries = 1;
3664 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3665 break;
3666 }
3667 } // End of switch
3668 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
3669 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
3670 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003671 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003672 pRoamProfile->EncryptionType.numEntries = 1;
3673 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3674 pRoamProfile->mcEncryptionType.numEntries = 1;
3675 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3676 }
3677 }
3678#endif /* FEATURE_WLAN_WAPI */
3679 /* if previous genIE is not NULL, update AssocIE */
3680 if (0 != pWextState->genIE.length)
3681 {
3682 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
3683 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
3684 pWextState->genIE.length);
3685 pWextState->assocAddIE.length = pWextState->genIE.length;
3686 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
3687 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
3688
3689 /* clear previous genIE after use it */
3690 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
3691 }
3692
3693 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
3694 pWextState->roamProfile.bWPSAssociation = FALSE;
3695
3696 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
3697 pWextState->roamProfile.nAddIEAssocLength))
3698 pWextState->roamProfile.bWPSAssociation = TRUE;
3699
3700
3701 // Disable auto BMPS entry by PMC until DHCP is done
3702 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
3703
Shailender Karmuchia734f332013-04-19 14:02:48 -07003704 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003706
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003707 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
3708 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003709 hdd_select_cbmode(pAdapter,
3710 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
3711 }
3712 status = sme_RoamConnect( hHal,pAdapter->sessionId,
3713 &(pWextState->roamProfile), &roamId);
3714 pRoamProfile->ChannelInfo.ChannelList = NULL;
3715 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003716
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003717 EXIT();
3718 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003719}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003720
Jeff Johnson295189b2012-06-20 16:38:30 -07003721/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003722
3723 \brief iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003724 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003725
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 \param - dev - Pointer to the net device.
3727 - info - Pointer to the iw_request_info.
3728 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003729 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003730 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003731
Jeff Johnson295189b2012-06-20 16:38:30 -07003732 --------------------------------------------------------------------------*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003733int iw_get_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 struct iw_request_info *info,
3735 struct iw_point *dwrq, char *extra)
3736{
3737 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003738 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003739 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3740 ENTER();
3741
3742 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
3743 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
3744 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
3745 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
3746 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
3747 {
3748 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
3749 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
3750 dwrq->flags = 1;
3751 } else {
3752 memset(extra, 0, dwrq->length);
3753 dwrq->length = 0;
3754 dwrq->flags = 0;
3755 }
3756 EXIT();
3757 return 0;
3758}
3759/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003760
3761 \brief iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003762 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003763
Jeff Johnson295189b2012-06-20 16:38:30 -07003764 \param - dev - Pointer to the net device.
3765 - info - Pointer to the iw_request_info.
3766 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003767 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003768 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003769
Jeff Johnson295189b2012-06-20 16:38:30 -07003770 --------------------------------------------------------------------------*/
3771int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
3772 union iwreq_data *wrqu,char *extra)
3773{
3774 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003775 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003776 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3777 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003778 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07003779 eCsrEncryptionType ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003780
Jeff Johnson295189b2012-06-20 16:38:30 -07003781 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003782
3783 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3784 {
3785 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3786 "%s:LOGP in Progress. Ignore!!!", __func__);
3787 return -EBUSY;
3788 }
3789
Jeff Johnson295189b2012-06-20 16:38:30 -07003790 switch(wrqu->param.flags & IW_AUTH_INDEX)
3791 {
3792 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003793
Jeff Johnson295189b2012-06-20 16:38:30 -07003794 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003795
Jeff Johnson295189b2012-06-20 16:38:30 -07003796 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003797
Jeff Johnson295189b2012-06-20 16:38:30 -07003798 case IW_AUTH_CIPHER_PAIRWISE:
3799 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003800 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003801 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003802 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003803 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3804 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003805 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003806 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
3807 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003808 }
3809
Jeff Johnson295189b2012-06-20 16:38:30 -07003810 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003811
3812 if( (IW_AUTH_KEY_MGMT_802_1X
3813 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
3815 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003816 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07003817 else
3818 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003819 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3820 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003821 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003822
3823 if( ( IW_AUTH_KEY_MGMT_802_1X
3824 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003825 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3826 /*Dynamic WEP key*/
3827 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3828 else
3829 /*Static WEP key*/
3830 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003831
Jeff Johnson295189b2012-06-20 16:38:30 -07003832 }
3833 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003834
Jeff Johnson295189b2012-06-20 16:38:30 -07003835 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003836 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003837 return -EINVAL;
3838 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003839
Jeff Johnson295189b2012-06-20 16:38:30 -07003840 pRoamProfile->EncryptionType.numEntries = 1;
3841 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003842 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003843 break;
3844 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003845 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003846 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
3847 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3848 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003849
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3851 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
3852 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003853
3854 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003855 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
3856 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003857
Jeff Johnson295189b2012-06-20 16:38:30 -07003858 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003859
3860 if( ( IW_AUTH_KEY_MGMT_802_1X
3861 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
3862 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3863
Jeff Johnson295189b2012-06-20 16:38:30 -07003864 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003865
3866 else
3867 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003868 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003869
3870 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
3871 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003872 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003873 if( ( IW_AUTH_KEY_MGMT_802_1X
3874 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003875 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3876 {
3877 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3878 }
3879 else
3880 {
3881 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3882 }
3883 }
3884 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003885
Jeff Johnson295189b2012-06-20 16:38:30 -07003886 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003887 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003888 return -EINVAL;
3889 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003890
Jeff Johnson295189b2012-06-20 16:38:30 -07003891 pRoamProfile->mcEncryptionType.numEntries = 1;
3892 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
3893 }
3894 break;
3895
3896 case IW_AUTH_80211_AUTH_ALG:
3897 {
3898 /*Save the auth algo here and set auth type to SME Roam profile
3899 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003900 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003902
Jeff Johnson295189b2012-06-20 16:38:30 -07003903 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
3904 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
3905
3906 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
3907 /*Not supported*/
3908 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3909 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
3910 }
3911 break;
3912
3913 case IW_AUTH_KEY_MGMT:
3914 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003915#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003916#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
3917 /*Check for CCKM AKM type */
3918 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003919 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
3920 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003921 /* Set the CCKM bit in authKeyMgmt */
3922 /* Right now, this breaks all ref to authKeyMgmt because our
3923 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07003924 */
3925 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
3926 /*Set the key management to 802.1X*/
3927 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003928 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3930 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3931 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
3932 /*Save the key management*/
3933 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
3934 //pWextState->authKeyMgmt = wrqu->param.value;
3935 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3936 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3937 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
3938 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
3939 /*Save the key management anyway*/
3940 pWextState->authKeyMgmt = wrqu->param.value;
3941 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
3942 /*Save the key management*/
3943 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
3944 //pWextState->authKeyMgmt = wrqu->param.value;
3945 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3946 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3947 }
3948#else
3949 /*Save the key management*/
3950 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003951#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003952 }
3953 break;
3954
3955 case IW_AUTH_TKIP_COUNTERMEASURES:
3956 {
3957 if(wrqu->param.value) {
3958 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3959 "Counter Measure started %d", wrqu->param.value);
3960 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
3961 }
3962 else {
3963 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3964 "Counter Measure stopped=%d", wrqu->param.value);
3965 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3966 }
3967 }
3968 break;
3969 case IW_AUTH_DROP_UNENCRYPTED:
3970 case IW_AUTH_WPA_ENABLED:
3971 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3972 case IW_AUTH_ROAMING_CONTROL:
3973 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003974
Jeff Johnson295189b2012-06-20 16:38:30 -07003975 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003976
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003977 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003978 wrqu->param.flags & IW_AUTH_INDEX);
3979 break;
3980 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003981
Jeff Johnson295189b2012-06-20 16:38:30 -07003982 EXIT();
3983 return 0;
3984}
3985/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003986
3987 \brief iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003988 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003989
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 \param - dev - Pointer to the net device.
3991 - info - Pointer to the iw_request_info.
3992 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003993 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003994 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003995
Jeff Johnson295189b2012-06-20 16:38:30 -07003996 --------------------------------------------------------------------------*/
3997int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
3998 union iwreq_data *wrqu,char *extra)
3999{
4000 hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004001 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07004002 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
4003 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004004
4005 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
4006 {
4007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
4008 "%s:LOGP in Progress. Ignore!!!", __func__);
4009 return -EBUSY;
4010 }
4011
Jeff Johnson295189b2012-06-20 16:38:30 -07004012 switch(pRoamProfile->negotiatedAuthType)
4013 {
4014 case eCSR_AUTH_TYPE_WPA_NONE:
4015 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4016 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
4017 break;
4018 case eCSR_AUTH_TYPE_WPA:
4019 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4020 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
4021 break;
4022#ifdef WLAN_FEATURE_VOWIFI_11R
4023 case eCSR_AUTH_TYPE_FT_RSN:
4024#endif
4025 case eCSR_AUTH_TYPE_RSN:
4026 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4027 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
4028 break;
4029 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4030 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4031 break;
4032 case eCSR_AUTH_TYPE_SHARED_KEY:
4033 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
4034 break;
4035 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004036 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004037 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4038 break;
4039 case eCSR_AUTH_TYPE_AUTOSWITCH:
4040 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4041 break;
4042 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304043 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4045 return -EIO;
4046#ifdef WLAN_FEATURE_VOWIFI_11R
4047 case eCSR_AUTH_TYPE_FT_RSN_PSK:
4048#endif
4049 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07004050#ifdef WLAN_FEATURE_11W
4051 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05304052 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07004053#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05304054 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4056 return -EIO;
4057 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304058 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4060 return -EIO;
4061 }
4062 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
4063 {
4064 switch(pRoamProfile->negotiatedUCEncryptionType)
4065 {
4066 case eCSR_ENCRYPT_TYPE_NONE:
4067 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4068 break;
4069 case eCSR_ENCRYPT_TYPE_WEP40:
4070 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4071 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4072 break;
4073 case eCSR_ENCRYPT_TYPE_TKIP:
4074 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4075 break;
4076 case eCSR_ENCRYPT_TYPE_WEP104:
4077 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4078 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4079 break;
4080 case eCSR_ENCRYPT_TYPE_AES:
4081 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4082 break;
4083 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304084 hddLog(LOG1, "%s called with unknown auth type %d ",
4085 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004086 return -EIO;
4087 }
4088 }
4089
Shailender Karmuchia734f332013-04-19 14:02:48 -07004090 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07004091 {
4092 switch(pRoamProfile->negotiatedMCEncryptionType)
4093 {
4094 case eCSR_ENCRYPT_TYPE_NONE:
4095 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4096 break;
4097 case eCSR_ENCRYPT_TYPE_WEP40:
4098 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4099 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4100 break;
4101 case eCSR_ENCRYPT_TYPE_TKIP:
4102 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4103 break;
4104 case eCSR_ENCRYPT_TYPE_WEP104:
4105 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4106 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4107 break;
4108 case eCSR_ENCRYPT_TYPE_AES:
4109 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4110 break;
4111 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304112 hddLog(LOG1, "%s called with unknown auth type %d ",
4113 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004114 return -EIO;
4115 }
4116 }
4117
4118 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004119 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004120 EXIT();
4121 return 0;
4122}
4123/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004124
4125 \brief iw_set_ap_address() -
4126 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07004127 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004128
Jeff Johnson295189b2012-06-20 16:38:30 -07004129 \param - dev - Pointer to the net device.
4130 - info - Pointer to the iw_request_info.
4131 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004132 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004133 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004134
Jeff Johnson295189b2012-06-20 16:38:30 -07004135 --------------------------------------------------------------------------*/
4136int iw_set_ap_address(struct net_device *dev,
4137 struct iw_request_info *info,
4138 union iwreq_data *wrqu, char *extra)
4139{
4140 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
4141 v_U8_t *pMacAddress=NULL;
4142 ENTER();
4143 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08004144 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
4145 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07004146 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
4147 EXIT();
Shailender Karmuchia734f332013-04-19 14:02:48 -07004148
Jeff Johnson295189b2012-06-20 16:38:30 -07004149 return 0;
4150}
4151/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004152
4153 \brief iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004154 This function returns the BSSID to the wpa_supplicant
4155 \param - dev - Pointer to the net device.
4156 - info - Pointer to the iw_request_info.
4157 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004158 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004159 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004160
Jeff Johnson295189b2012-06-20 16:38:30 -07004161 --------------------------------------------------------------------------*/
4162int iw_get_ap_address(struct net_device *dev,
4163 struct iw_request_info *info,
4164 union iwreq_data *wrqu, char *extra)
4165{
4166 //hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4167 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
4168
4169 ENTER();
4170
4171 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
4172 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
4173 {
Jeff Johnson4416a782013-03-25 14:17:50 -07004174 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07004175 }
4176 else
4177 {
4178 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4179 }
4180 EXIT();
4181 return 0;
4182}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004183
Chet Lanctot186b5732013-03-18 10:26:30 -07004184#ifdef WLAN_FEATURE_11W
4185/**---------------------------------------------------------------------------
4186
4187 \brief hdd_indicateUnprotMgmtFrame -
4188 This function forwards the unprotected management frame to the supplicant
4189 \param - pAdapter - Pointer to HDD adapter
4190 - nFrameLength - Length of the unprotected frame being passed
4191 - pbFrames - Pointer to the frame buffer
4192 - frameType - 802.11 frame type
4193 \return - nothing
4194
4195 --------------------------------------------------------------------------*/
4196void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
4197 tANI_U32 nFrameLength,
4198 tANI_U8* pbFrames,
4199 tANI_U8 frameType )
4200{
4201 tANI_U8 type = 0;
4202 tANI_U8 subType = 0;
4203
4204 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
4205 __func__, frameType, nFrameLength);
4206
4207 /* Sanity Checks */
4208 if (NULL == pAdapter)
4209 {
4210 hddLog( LOGE, FL("pAdapter is NULL"));
4211 return;
4212 }
4213
4214 if (NULL == pAdapter->dev)
4215 {
4216 hddLog( LOGE, FL("pAdapter->dev is NULL"));
4217 return;
4218 }
4219
4220 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
4221 {
4222 hddLog( LOGE, FL("pAdapter has invalid magic"));
4223 return;
4224 }
4225
4226 if( !nFrameLength )
4227 {
4228 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
4229 return;
4230 }
4231
4232 if (NULL == pbFrames) {
4233 hddLog( LOGE, FL("pbFrames is NULL"));
4234 return;
4235 }
4236
4237 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4238 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4239
4240 /* Get pAdapter from Destination mac address of the frame */
4241 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
4242 {
4243 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
4244 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4245 }
4246 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
4247 {
4248 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
4249 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4250 }
4251 else
4252 {
4253 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
4254 return;
4255 }
4256}
4257#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004258
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004259#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004260void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
4261 tANI_U8 state,
4262 tANI_U16 measInterval )
4263{
4264 union iwreq_data wrqu;
4265 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004266 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004267
4268 if (NULL == pAdapter)
4269 return;
4270
4271 // create the event
4272 memset(&wrqu, '\0', sizeof(wrqu));
4273 memset(buf, '\0', sizeof(buf));
4274
4275 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
4276 tid, state, measInterval);
4277
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004278 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004279
4280 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004281 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004282 // send the event
4283 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4284}
4285
4286void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4287{
4288 union iwreq_data wrqu;
4289 char buf[IW_CUSTOM_MAX + 1];
4290 char *pos = buf;
4291 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4292
4293 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4294 return;
4295
4296 // create the event
4297 memset(&wrqu, '\0', sizeof(wrqu));
4298 memset(buf, '\0', sizeof(buf));
4299
4300 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304301 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
4302 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
4303 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
4304 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004305
4306 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4307 pos += nBytes;
4308 freeBytes -= nBytes;
4309
4310 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
4311 pos += WNI_CFG_BSSID_LEN;
4312 freeBytes -= WNI_CFG_BSSID_LEN;
4313
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004314 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4315 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004316
4317 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004318 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004319
4320 // send the event
4321 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4322}
4323
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004324void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004325{
4326 union iwreq_data wrqu;
4327 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004328 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004329
4330 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4331 return;
4332
4333 // create the event
4334 memset(&wrqu, '\0', sizeof(wrqu));
4335 memset(buf, '\0', sizeof(buf));
4336
4337 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
4338
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004339 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004340
4341 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004342 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004343
4344 // send the event
4345 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4346}
4347
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004348void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
4349 const tANI_U16 measurementToken,
4350 const tANI_BOOLEAN flag,
4351 const tANI_U8 numBss)
4352{
4353 union iwreq_data wrqu;
4354 char buf[IW_CUSTOM_MAX];
4355 char *pos = buf;
4356 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4357
4358 memset(&wrqu, '\0', sizeof(wrqu));
4359 memset(buf, '\0', sizeof(buf));
4360
4361 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
4362 numBss);
4363
4364 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4365 flag, numBss);
4366
4367 wrqu.data.pointer = buf;
4368 wrqu.data.length = nBytes;
4369 // send the event
4370 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4371}
4372
4373
4374static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004375 const tCsrRoamInfo *pRoamInfo)
4376{
4377 union iwreq_data wrqu;
4378 char buf[IW_CUSTOM_MAX + 1];
4379 char *pos = buf;
4380 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4381 tANI_U8 i = 0, len = 0;
4382 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
4383 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004384 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
4385 tANI_U8 ieLenByte = 1;
4386 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
4387#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004388
4389 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4390 return;
4391
4392 /* Custom event can pass maximum of 256 bytes of data,
4393 based on the IE len we need to identify how many BSS info can
4394 be filled in to custom event data */
4395 /*
4396 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4397 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4398 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4399 */
4400
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004401 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004402 {
4403 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
4404 /* If the measurement is none and no scan results found,
4405 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004406 hdd_indicateEseBcnReportNoResults(pAdapter,
4407 pRoamInfo->pEseBcnReportRsp->measurementToken,
4408 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004409 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004410 }
4411 else
4412 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004413 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004414 {
4415 memset(&wrqu, '\0', sizeof(wrqu));
4416 memset(buf, '\0', sizeof(buf));
4417 tot_bcn_ieLen = 0;
4418 sendBss = 0;
4419 pos = buf;
4420 freeBytes = IW_CUSTOM_MAX;
4421
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004422 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004423 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004424 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
4425 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004426 {
4427 break;
4428 }
4429 tot_bcn_ieLen += len;
4430 sendBss++;
4431 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
4432 "IeLength(%d) Length of Ie(%d) totLen(%d)",
4433 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004434 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004435 tot_bcn_ieLen);
4436 }
4437
4438 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
4439 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004440 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4441 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004442
4443 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004444 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
4445 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004446 pos += nBytes;
4447 freeBytes -= nBytes;
4448
4449 /* Copy total Beacon report data length */
4450 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
4451 pos += sizeof(tot_bcn_ieLen);
4452 freeBytes -= sizeof(tot_bcn_ieLen);
4453
4454 for (i = 0; i < sendBss; i++)
4455 {
4456 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304457 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
4458 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004459 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004460 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
4461 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
4462 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
4463 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
4464 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
4465 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
4466 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
4467 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
4468 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
4469 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
4470 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
4471 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
4472 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
4473 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
4474 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
4475 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004476
4477 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004478 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
4479 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004480 pos += len;
4481 freeBytes -= len;
4482
4483 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004484 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004485 vos_mem_copy(pos, (char*)&len, sizeof(len));
4486 pos += sizeof(len);
4487 freeBytes -= sizeof(len);
4488
4489 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004490 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004491 pos += len;
4492 freeBytes -= len;
4493 }
4494
4495 wrqu.data.pointer = buf;
4496 wrqu.data.length = strlen(buf);
4497
4498 // send the event
4499 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4500 lastSent += sendBss;
4501 }
4502 }
4503}
4504
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004505#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004506