blob: 3a1bf9ffbd0e7574b5a82a262d0f09757e6e093a [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302 * Copyright (c) 2012-2015 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028/**========================================================================
29
30 \file wlan_hdd_assoc.c
31 \brief WLAN Host Device Driver implementation
Shailender Karmuchia734f332013-04-19 14:02:48 -070032
Jeff Johnson295189b2012-06-20 16:38:30 -070033 ========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070034/**=========================================================================
35 EDIT HISTORY FOR FILE
36
37
38 This section contains comments describing changes made to the module.
39 Notice that changes are listed in reverse chronological order.
40
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070046 -------- --- --------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -070047 05/06/09 Shailender Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070048 ==========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070049
Jeff Johnson295189b2012-06-20 16:38:30 -070050#include "wlan_hdd_includes.h"
51#include <aniGlobal.h>
52#include "dot11f.h"
53#include "wlan_nlink_common.h"
54#include "wlan_btc_svc.h"
55#include "wlan_hdd_power.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070056#include <linux/ieee80211.h>
57#include <linux/wireless.h>
58#include <net/cfg80211.h>
59#include "wlan_hdd_cfg80211.h"
60#include "csrInsideApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070061#include "wlan_hdd_p2p.h"
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053062#include <vos_sched.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080063#ifdef FEATURE_WLAN_TDLS
64#include "wlan_hdd_tdls.h"
65#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070066#include "sme_Api.h"
Sushant Kaushikba6764e2014-06-30 19:52:09 +053067#include "wlan_hdd_hostapd.h"
Mukul Sharma84f27252014-07-14 18:11:42 +053068#include "vos_utils.h"
Siddharth Bhalda0d1622015-04-24 15:47:49 +053069#include <wlan_hdd_wext.h>
Mukul Sharma84f27252014-07-14 18:11:42 +053070
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
Kanchanapally, Vidyullatha31b8d142015-01-30 14:25:18 +0530434 sme_GetRICIEs(pHddCtx->hHal, (u8 *)ricIe,
435 DOT11F_IE_RICDESCRIPTOR_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}
Katya Nigam47528772015-02-11 12:24:49 +0530746
747VOS_STATUS hdd_ibss_deinit_tx_rx_sta ( hdd_adapter_t *pAdapter, v_U8_t STAId )
748{
Katya Nigam1fd24402015-02-16 14:52:19 +0530749 v_U8_t ac;
750 /**Track whether OS TX queue has been disabled.*/
751 v_BOOL_t txSuspended[NUM_TX_QUEUES];
752 v_U8_t tlAC;
Katya Nigam47528772015-02-11 12:24:49 +0530753 v_U8_t i;
754 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
755 hdd_ibss_peer_info_t *pPeerInfo;
756
757 if( NULL == pHddStaCtx )
758 {
759 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
760 "%s: HDD station context NULL ",__func__);
761 return VOS_STATUS_E_FAILURE;
762 }
Katya Nigam1fd24402015-02-16 14:52:19 +0530763
Katya Nigam47528772015-02-11 12:24:49 +0530764 pPeerInfo = &pHddStaCtx->ibss_peer_info;
765 if (FALSE == pPeerInfo->ibssStaInfo[STAId].isUsed)
766 {
767 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
768 "%s: Deinit station not inited %d", __func__, STAId );
769 return VOS_STATUS_E_FAILURE;
770 }
771
772 hdd_flush_ibss_tx_queues(pAdapter, STAId);
Katya Nigam1fd24402015-02-16 14:52:19 +0530773
774 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
775 {
776 tlAC = hdd_QdiscAcToTlAC[ac];
777 txSuspended[ac] = pPeerInfo->ibssStaInfo[STAId].txSuspended[tlAC];
778 }
779
Katya Nigam47528772015-02-11 12:24:49 +0530780 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
781
Katya Nigam1fd24402015-02-16 14:52:19 +0530782 /* re-init hdd list, since netdev can still open adapter until
783 * driver gets unloaded
784 */
785 for (i = 0; i < NUM_TX_QUEUES; i ++)
786 {
787 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i],
788 HDD_TX_QUEUE_MAX_LEN);
789 }
790
791 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
792 {
793 if (txSuspended[ac])
794 {
795 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
796 "%s: TX queue re-enabled", __func__);
797 netif_wake_subqueue(pAdapter->dev, ac);
798 }
799 }
Katya Nigam47528772015-02-11 12:24:49 +0530800 return VOS_STATUS_SUCCESS;
801}
802
803static VOS_STATUS hdd_ibss_DeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
804{
805 VOS_STATUS vosStatus;
806
807 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
808 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
809 {
810 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
811 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
812 "Status= %d [0x%08X]",
813 __func__, staId, vosStatus, vosStatus );
814 }
815
816 vosStatus = hdd_ibss_deinit_tx_rx_sta ( pAdapter, staId );
817 if( VOS_STATUS_E_FAILURE == vosStatus )
818 {
819 VOS_TRACE ( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
820 "hdd_ibss_deinit_tx_rx_sta() failed for staID %d. "
821 "Status = %d [0x%08X]",
822 staId, vosStatus, vosStatus );
823 }
824
825 return( vosStatus );
826}
827
828VOS_STATUS hdd_ibss_init_tx_rx_sta( hdd_adapter_t *pAdapter, v_U8_t STAId, v_MACADDR_t *pmacAddrSTA)
829{
830 v_U8_t i = 0;
831 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
832 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
833
834 if (pPeerInfo->ibssStaInfo[STAId].isUsed)
835 {
836 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
837 "%s: Reinit station %d", __func__, STAId );
838 return VOS_STATUS_E_FAILURE;
839 }
840
841 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
842 for (i = 0; i < NUM_TX_QUEUES; i ++)
843 {
844 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i], HDD_TX_QUEUE_MAX_LEN);
845 }
846
847 pPeerInfo->ibssStaInfo[STAId].isUsed = VOS_TRUE;
848 pPeerInfo->ibssStaInfo[STAId].isDeauthInProgress = VOS_FALSE;
849 vos_copy_macaddr( &pPeerInfo->ibssStaInfo[STAId].macAddrSTA, pmacAddrSTA);
850
851 return VOS_STATUS_SUCCESS;
852}
853
854static VOS_STATUS hdd_ibss_RegisterSTA( hdd_adapter_t *pAdapter,
855 tCsrRoamInfo *pRoamInfo,
856 v_U8_t staId,
857 v_MACADDR_t *pPeerMacAddress,
858 tSirBssDescription *pBssDesc )
859{
860 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
861 WLAN_STADescType staDesc = {0};
862 eCsrEncryptionType connectedCipherAlgo;
863 v_BOOL_t fConnected;
864 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
865 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
866 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
867
868 if ( pPeerInfo->ibssStaInfo[staId].isUsed )
869 {
870 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
871 "clean up old entry for STA %d", staId);
872 hdd_ibss_DeregisterSTA( pAdapter, staId );
873 }
874
875 staDesc.ucSTAId = staId;
876 staDesc.wSTAType = WLAN_STA_IBSS;
877
878 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
879 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
880 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
881 // pass when making an Infrastructure connection.
882 vos_mem_copy(staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes));
883 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId, 6 );
884 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
885
886 if (hdd_wmm_is_active(pAdapter))
887 {
888 staDesc.ucQosEnabled = 1;
889 }
890 else
891 {
892 staDesc.ucQosEnabled = 0;
893 }
894 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
895 "HDD SOFTAP register TL QoS_enabled=%d",
896 staDesc.ucQosEnabled );
897
898 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
899 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
900 {
901 staDesc.ucProtectedFrame = 1;
902 }
903 else
904 {
905 staDesc.ucProtectedFrame = 0;
906
907 }
908
909 hdd_ibss_init_tx_rx_sta(pAdapter, staId, &staDesc.vSTAMACAddress);
910
911 // UMA is Not ready yet, Xlation will be done by TL
912 staDesc.ucSwFrameTXXlation = 1;
913 staDesc.ucSwFrameRXXlation = 1;
914 staDesc.ucAddRmvLLC = 1;
915 // Initialize signatures and state
916 staDesc.ucUcastSig = pRoamInfo->ucastSig;
917 staDesc.ucBcastSig = pRoamInfo->bcastSig;
918 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED;
919
920 staDesc.ucIsReplayCheckValid = VOS_FALSE;
921
922 // Register the Station with TL.
923 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
924 hdd_rx_packet_cbk,
925 hdd_tx_complete_cbk,
926 hdd_ibss_tx_fetch_packet_cbk, &staDesc,
927 pBssDesc->rssi );
928 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
929 {
930 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
931 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
932 vosStatus, vosStatus );
933 return vosStatus;
934 }
935
936 //Timer value should be in milliseconds
937 if ( pHddCtx->cfg_ini->dynSplitscan &&
938 ( VOS_TIMER_STATE_RUNNING !=
939 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
940 {
941 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
942 pHddCtx->cfg_ini->trafficMntrTmrForSplitScan);
943 }
944
945 pPeerInfo->ibssStaInfo[staId].ucSTAId = staId;
946 pPeerInfo->ibssStaInfo[staId].isQosEnabled = staDesc.ucQosEnabled;
947
948 vosStatus = WLANTL_ChangeSTAState( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staDesc.ucSTAId,
949 WLANTL_STA_AUTHENTICATED );
950
951 pPeerInfo->ibssStaInfo[staId].tlSTAState = WLANTL_STA_AUTHENTICATED;
952 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
953
954 return( vosStatus );
955}
956
Jeff Johnson295189b2012-06-20 16:38:30 -0700957/* TODO Revist this function. and data path */
958static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
959{
960 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700961
Katya Nigam47528772015-02-11 12:24:49 +0530962 hdd_disconnect_tx_rx(pAdapter);
Ravi Joshif9520d62013-10-18 04:11:46 -0700963
Jeff Johnson295189b2012-06-20 16:38:30 -0700964 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
965 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
966 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530967 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700968 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700969 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700970 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700971 }
972 return( vosStatus );
973}
974
975
976static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
977 tANI_U32 roamId, eRoamCmdStatus roamStatus,
978 eCsrRoamResult roamResult )
979{
980 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700981 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700982 struct net_device *dev = pAdapter->dev;
983 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
984 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700985 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +0530986 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700987
988 // Sanity check
989 if(dev == NULL)
990 {
Agarwal Ashish971c2882013-10-30 20:11:12 +0530991 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700992 "%s: net_dev is released return", __func__);
993 return eHAL_STATUS_FAILURE;
994 }
995
Jeff Johnson295189b2012-06-20 16:38:30 -0700996 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +0530997 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 netif_tx_disable(dev);
999 netif_carrier_off(dev);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +05301000 //TxTimeoutCount need to reset in case of disconnect handler
1001 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001002
Jeff Johnsone7245742012-09-05 17:12:55 -07001003 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301004 /* HDD has initiated disconnect, do not send disconnect indication
1005 * to kernel as it will be handled by __cfg80211_disconnect.
1006 */
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301007 /* If only STA mode is on */
1008 if((pHddCtx->concurrency_mode <= 1) &&
1009 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
1010 {
1011 pHddCtx->isAmpAllowed = VOS_TRUE;
1012 }
1013
Agarwal Ashish47d18112014-08-04 19:55:07 +05301014 /* Need to apply spin lock before decreasing active sessions
1015 * as there can be chance for double decrement if context switch
1016 * Calls wlan_hdd_disconnect.
1017 */
1018
1019 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301020 if ( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState )
1021 {
1022 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1023 FL(" HDD has initiated a disconnect, no need to send"
1024 " disconnect indication to kernel"));
1025 sendDisconInd = FALSE;
1026 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301027 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -07001028 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301029 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Agarwal Ashish47d18112014-08-04 19:55:07 +05301030 FL(" Set HDD connState to eConnectionState_Disconnecting from %d "),
1031 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301032 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
1033 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 }
Agarwal Ashish47d18112014-08-04 19:55:07 +05301035 spin_unlock_bh(&pAdapter->lock_for_active_session);
1036
Jeff Johnson295189b2012-06-20 16:38:30 -07001037 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -07001038
1039 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07001040
1041 // indicate 'disconnect' status to wpa_supplicant...
1042 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 /* indicate disconnected event to nl80211 */
1044 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
1045 {
1046 /*During the WLAN uninitialization,supplicant is stopped before the
1047 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301048 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001049 {
Sushant Kaushik0b343422015-05-25 17:15:55 +05301050 if (sendDisconInd)
1051 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1052 "%s: sent disconnected event to nl80211",
1053 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001054#ifdef WLAN_FEATURE_P2P_DEBUG
1055 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1056 {
1057 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
1058 {
1059 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
1060 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
1061 "and moved to disconnected state");
1062 }
1063 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
1064 {
1065 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
1066 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
1067 "and moved to inactive state");
1068 }
1069 }
1070#endif
Sushant Kaushikbad61892015-07-10 16:43:28 +05301071 if ((roamStatus == eCSR_ROAM_LOSTLINK) &&
1072 !pRoamInfo->reasonCode)
1073 wlan_hdd_get_frame_logs(pAdapter,
1074 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301075 /*Only send indication to kernel if not initiated by kernel*/
1076 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -07001077 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301078 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
1079 if ( eCSR_ROAM_LOSTLINK == roamStatus )
1080 {
1081 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
1082 }
1083 else
1084 {
1085 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
1086 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001087 }
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301088 if ((TRUE == pHddCtx->cfg_ini->fEnableTDLSSupport) &&
1089 (TRUE == sme_IsFeatureSupportedByFW(TDLS))) {
1090 if (pAdapter->device_mode != WLAN_HDD_INFRA_STATION)
1091 /* Enable TDLS support Once P2P session ends since
1092 * upond detection of concurrency TDLS would be disabled
1093 */
1094 wlan_hdd_tdls_set_mode(pHddCtx, eTDLS_SUPPORT_ENABLED,
1095 FALSE);
1096 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001097 //If the Device Mode is Station
1098 // and the P2P Client is Connected
1099 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001100
1101 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001102 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07001103 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -07001104 {
1105 //Enable BMPS only of other Session is P2P Client
1106 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001107 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001108
1109 if (NULL != pVosContext)
1110 {
1111 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1112
1113 if(NULL != pHddCtx)
1114 {
1115 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301116 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1117 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001118 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301119 if (pHddCtx->hdd_wlan_suspended)
1120 {
1121 hdd_set_pwrparams(pHddCtx);
1122 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301124 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001125 }
1126 }
1127 }
1128 }
1129 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001130
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +05301131 hdd_wmm_adapter_clear(pAdapter);
Mukul Sharmac159c432014-01-15 15:42:46 +05301132#if defined(WLAN_FEATURE_VOWIFI_11R)
1133 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
1134#endif
Katya Nigam63ce1772014-09-26 15:53:49 +05301135
1136 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
1137 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301138 v_U8_t i;
1139
Katya Nigam63ce1772014-09-26 15:53:49 +05301140 sta_id = IBSS_BROADCAST_STAID;
Katya Nigam47528772015-02-11 12:24:49 +05301141 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Katya Nigam63ce1772014-09-26 15:53:49 +05301142 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1143 {
1144 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301145 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1146 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +05301147 sta_id, status, status );
1148
1149 status = eHAL_STATUS_FAILURE;
1150 }
Katya Nigam63ce1772014-09-26 15:53:49 +05301151 pHddCtx->sta_to_adapter[sta_id] = NULL;
1152
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301153 /*Clear all the peer sta register with TL.*/
1154 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
1155 {
1156 if (0 != pHddStaCtx->conn_info.staId[i])
1157 {
1158 sta_id = pHddStaCtx->conn_info.staId[i];
1159
1160 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1161 FL("Deregister StaID %d"),sta_id);
Katya Nigam47528772015-02-11 12:24:49 +05301162 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301163 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1164 {
1165 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1166 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1167 "Status= %d [0x%x]"),
1168 sta_id, status, status );
1169 status = eHAL_STATUS_FAILURE;
1170 }
1171
Nirav Shah7e3c8132015-06-22 23:51:42 +05301172 vstatus = hdd_sta_id_hash_remove_entry(pAdapter,
1173 sta_id, &pHddStaCtx->conn_info.peerMacAddress[i]);
1174 if (vstatus != VOS_STATUS_SUCCESS) {
1175 hddLog(VOS_TRACE_LEVEL_ERROR,
1176 FL("Not able to remove staid hash %d"),
1177 sta_id);
1178 status = eHAL_STATUS_FAILURE;
1179 } else {
1180 hddLog(VOS_TRACE_LEVEL_INFO,
1181 FL("ibss station removed sta_id %d mac:"
1182 MAC_ADDRESS_STR), sta_id,
1183 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[i].bytes));
1184 }
1185
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301186 /*set the staid and peer mac as 0, all other reset are
1187 * done in hdd_connRemoveConnectInfo.
1188 */
1189 pHddStaCtx->conn_info.staId[i]= 0;
1190 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
1191
1192 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1193 pHddCtx->sta_to_adapter[sta_id] = NULL;
1194 }
1195 }
1196
Katya Nigam63ce1772014-09-26 15:53:49 +05301197 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301198 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301200 sta_id = pHddStaCtx->conn_info.staId[0];
1201
1202 //We should clear all sta register with TL, for now, only one.
1203 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
1204 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1205 {
1206 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1207 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1208 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -07001209 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001210
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301211 status = eHAL_STATUS_FAILURE;
1212 }
1213
1214 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001215 }
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301216
1217#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1218 if (VOS_STATUS_SUCCESS !=
1219 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1220 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE_AC))
1221 {
1222 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1223 "WLANTL_ClearInterfaceStats Failed", __func__);
1224 }
1225 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1226 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1227 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1228 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1229#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
1230
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 // Clear saved connection information in HDD
1232 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhf4669da2014-05-26 15:07:49 +05301233 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1234 "%s: Set HDD connState to eConnectionState_NotConnected",
1235 __func__);
1236 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301237#ifdef WLAN_FEATURE_GTK_OFFLOAD
1238 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1239 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1240 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301241 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1242 sizeof (tSirGtkOffloadParams));
1243 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301244 }
1245#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001246
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001247#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001248 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1249 {
1250 wlan_hdd_tdls_disconnection_callback(pAdapter);
1251 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001252#endif
1253
Jeff Johnson295189b2012-06-20 16:38:30 -07001254 //Unblock anyone waiting for disconnect to complete
1255 complete(&pAdapter->disconnect_comp_var);
1256 return( status );
1257}
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301258
1259static void hdd_postTLPacketPendingInd(hdd_adapter_t *pAdapter,
1260 v_U8_t staId)
1261{
1262 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1263 v_SINT_t i;
1264 v_SIZE_t size;
1265 VOS_STATUS status;
1266 v_BOOL_t granted = VOS_FALSE;
1267
1268 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1269 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ||
1270 (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE))
1271 {
1272 //Indicate to TL that there is pending data if a queue is non empty
1273 for (i = WLANTL_AC_HIGH_PRIO; i>=0; --i)
1274 {
1275 size = 0;
1276 hdd_list_size(&pAdapter->wmm_tx_queue[i], &size);
1277 if (size > 0)
1278 {
1279 if (i != WLANTL_AC_HIGH_PRIO)
1280 {
1281 if (VOS_FALSE ==
1282 pAdapter->hddWmmStatus.wmmAcStatus[i].wmmAcAccessAllowed)
1283 {
1284 hdd_wmm_acquire_access(pAdapter,
1285 (WLANTL_ACEnumType)i, &granted);
1286 pAdapter->psbChanged |= (1 << i);
1287 }
1288 else
1289 granted = VOS_TRUE;
1290 }
1291
1292 if (granted || (i == WLANTL_AC_HIGH_PRIO))
1293 {
1294 status = WLANTL_STAPktPending(pHddCtx->pvosContext,
1295 staId, (WLANTL_ACEnumType)i);
1296 if (!VOS_IS_STATUS_SUCCESS(status))
1297 {
1298 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1299 "%s: Failure in indicating pkt to TL for QID=%d",
1300 __func__, i);
1301 }
1302 }
1303 }
1304 }
1305 }
1306}
1307
Jeff Johnson295189b2012-06-20 16:38:30 -07001308static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
1309 tCsrRoamInfo *pRoamInfo,
1310 v_U8_t staId,
1311 v_MACADDR_t *pPeerMacAddress,
1312 tSirBssDescription *pBssDesc )
1313{
1314 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1315 WLAN_STADescType staDesc = {0};
1316 eCsrEncryptionType connectedCipherAlgo;
1317 v_BOOL_t fConnected;
1318 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1319 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001320 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001321
1322 if ( NULL == pBssDesc)
1323 {
1324 return VOS_STATUS_E_FAILURE;
1325 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001326 // Get the Station ID from the one saved during the assocation.
1327 staDesc.ucSTAId = staId;
1328
Katya Nigam47528772015-02-11 12:24:49 +05301329 staDesc.wSTAType = WLAN_STA_INFRA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001330
Katya Nigam47528772015-02-11 12:24:49 +05301331 // grab the bssid from the connection info in the adapter structure and hand that
1332 // over to TL when registering.
1333 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,
1334 sizeof(pHddStaCtx->conn_info.bssId) );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001335
Jeff Johnson295189b2012-06-20 16:38:30 -07001336 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1337
1338 // set the QoS field appropriately
1339 if (hdd_wmm_is_active(pAdapter))
1340 {
1341 staDesc.ucQosEnabled = 1;
1342 }
1343 else
1344 {
1345 staDesc.ucQosEnabled = 0;
1346 }
1347
1348 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1349 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1350 {
1351 staDesc.ucProtectedFrame = 1;
1352 }
1353 else
1354 {
1355 staDesc.ucProtectedFrame = 0;
1356
1357 }
1358
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001359#ifdef FEATURE_WLAN_ESE
1360 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
1361#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001362
1363#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
1364 /* check whether replay check is valid for the station or not */
1365 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
1366 {
1367 /* Encryption mode is either TKIP or AES
1368 and replay check is valid for only these
1369 two encryption modes */
1370 staDesc.ucIsReplayCheckValid = VOS_TRUE;
1371 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1372 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
1373 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001374
Jeff Johnson295189b2012-06-20 16:38:30 -07001375 else
1376 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001377 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07001378 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001379 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001380 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1381 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1382 }
1383#endif
1384
1385#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001386 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001387 if (pAdapter->wapi_info.fIsWapiSta)
1388 {
1389 staDesc.ucIsWapiSta = 1;
1390 }
1391 else
1392 {
1393 staDesc.ucIsWapiSta = 0;
1394 }
1395#endif /* FEATURE_WLAN_WAPI */
1396
1397 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1398 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1399
Jeff Johnson295189b2012-06-20 16:38:30 -07001400 // UMA is Not ready yet, Xlation will be done by TL
1401 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001402 staDesc.ucSwFrameRXXlation = 1;
1403 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001404 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001405 staDesc.ucQosEnabled );
1406 // Initialize signatures and state
1407 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1408 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1409 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1410 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001411 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001412 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 -07001413 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1414 hdd_rx_packet_cbk,
1415 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001416 hdd_tx_fetch_packet_cbk, &staDesc,
1417 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001418
Jeff Johnson295189b2012-06-20 16:38:30 -07001419 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1420 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001421 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001422 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001423 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001424 return vosStatus;
1425 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001426
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001427 if ( cfg_param->dynSplitscan &&
1428 ( VOS_TIMER_STATE_RUNNING !=
1429 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1430 {
1431 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1432 cfg_param->trafficMntrTmrForSplitScan);
1433 }
1434
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301435 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1436 // then go to 'authenticated'. For all other authentication types
1437 // (those that donot require upper layer authentication) we can put
1438 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001439 if (staDesc.wSTAType != WLAN_STA_IBSS)
1440 VOS_ASSERT( fConnected );
1441
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301442 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001443 {
1444 // Connections that do not need Upper layer auth, transition TL directly
1445 // to 'Authenticated' state.
1446 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1447 WLANTL_STA_AUTHENTICATED );
1448
1449 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301450
1451 hdd_postTLPacketPendingInd(pAdapter, staDesc.ucSTAId);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001452 }
1453 else
1454 {
1455 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301456 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1457 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001458 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301459 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001460 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1461 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001462 return( vosStatus );
1463}
1464
Jeff Johnson295189b2012-06-20 16:38:30 -07001465static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1466 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1467{
1468 unsigned int len = 0;
1469 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001470 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 tANI_U32 rspRsnLength = 0;
1472 struct ieee80211_channel *chan;
1473
Agarwal Ashish51325b52014-06-16 16:50:49 +05301474 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001475 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001476 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001477 }
1478
Agarwal Ashish51325b52014-06-16 16:50:49 +05301479 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001480 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1481 goto done;
1482 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001483
Agarwal Ashish51325b52014-06-16 16:50:49 +05301484 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001485 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1486 goto done;
1487 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001488
1489 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1490 pCsrRoamInfo->nAssocReqLength);
1491 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001492 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001493
1494 //pFTAssocRsp needs to point to the IEs
1495 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001496 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001497 (unsigned int)pFTAssocRsp[0],
1498 (unsigned int)pFTAssocRsp[1]);
1499
1500 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001501 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001502 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001503 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001504 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001505
1506 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1507 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1508 reqRsnIe, reqRsnLength,
1509 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001510
1511done:
1512 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001513}
Jeff Johnson295189b2012-06-20 16:38:30 -07001514
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301515void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1516{
1517 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1518 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1519 tCsrRoamInfo roamInfo;
1520 roamInfo.fAuthRequired = FALSE;
1521 vos_mem_copy(roamInfo.bssid,
1522 pHddStaCtx->roam_info.bssid,
1523 WNI_CFG_BSSID_LEN);
1524 vos_mem_copy(roamInfo.peerMac,
1525 pHddStaCtx->roam_info.peerMac,
1526 WNI_CFG_BSSID_LEN);
1527
1528 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1529 &roamInfo,
1530 pHddStaCtx->roam_info.roamId,
1531 pHddStaCtx->roam_info.roamStatus,
1532 eCSR_ROAM_RESULT_AUTHENTICATED);
1533 if (halStatus != eHAL_STATUS_SUCCESS)
1534 {
1535 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1536 }
1537 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1538}
1539
Shailender Karmuchia734f332013-04-19 14:02:48 -07001540static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1541 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001542 eCsrRoamResult roamResult )
1543{
1544 struct net_device *dev = pAdapter->dev;
1545 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1546 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05301547 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05301548 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001549 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1550 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001551#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001552 int ft_carrier_on = FALSE;
1553#endif
1554 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301555 v_BOOL_t hddDisconInProgress = FALSE;
1556
1557 /* HDD has initiated disconnect, do not send connect result indication
1558 * to kernel as it will be handled by __cfg80211_disconnect.
1559 */
1560 if(( eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) &&
1561 (( eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
1562 ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)) )
1563 {
1564 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1565 FL(" Disconnect from HDD in progress "));
1566 hddDisconInProgress = TRUE;
1567 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001568
Jeff Johnson295189b2012-06-20 16:38:30 -07001569 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1570 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301571 if ( !hddDisconInProgress )
1572 {
1573 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05301574 "%s: Set HDD connState to eConnectionState_Associated",
1575 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301576 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1577 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001578
c_hpothu44ff4e02014-05-08 00:13:57 +05301579 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07001580 // Save the connection info from CSR...
1581 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1582#ifdef FEATURE_WLAN_WAPI
1583 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1584 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1585 {
1586 pAdapter->wapi_info.fIsWapiSta = 1;
1587 }
1588 else
1589 {
1590 pAdapter->wapi_info.fIsWapiSta = 0;
1591 }
1592#endif /* FEATURE_WLAN_WAPI */
1593
1594 // indicate 'connect' status to userspace
1595 hdd_SendAssociationEvent(dev,pRoamInfo);
1596
1597
Shailender Karmuchia734f332013-04-19 14:02:48 -07001598 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001599 INIT_COMPLETION(pAdapter->linkup_event_var);
1600
1601 /*
1602 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1603 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 -07001604 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001605 know that the device is getting activated properly.
1606 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001607#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05301608 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07001609 {
1610#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001611 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 pAdapter->isLinkUpSvcNeeded = TRUE;
1613
Shailender Karmuchia734f332013-04-19 14:02:48 -07001614 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001615 pAdapter->isLinkUpSvcNeeded = TRUE;
1616
1617 // Switch on the Carrier to activate the device
1618 netif_carrier_on(dev);
1619
1620 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1621 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1622 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001623 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 {
1625 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1626 }
1627
1628 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1629 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001630#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001632 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001633 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001634 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001635 }
1636#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05301637 /* Check for STAID */
1638 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
1639 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1640 else
1641 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001642
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001643#ifdef FEATURE_WLAN_TDLS
1644 wlan_hdd_tdls_connection_callback(pAdapter);
1645#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001646 //For reassoc, the station is already registered, all we need is to change the state
1647 //of the STA in TL.
1648 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05301649 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07001650 if( !pRoamInfo->fReassocReq )
1651 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001652 struct cfg80211_bss *bss;
1653#ifdef WLAN_FEATURE_VOWIFI_11R
1654 u8 *pFTAssocRsp = NULL;
1655 unsigned int assocRsplen = 0;
1656 u8 *pFTAssocReq = NULL;
1657 unsigned int assocReqlen = 0;
1658 struct ieee80211_channel *chan;
1659#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001660 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001661 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001662
1663 /* add bss_id to cfg80211 data base */
1664 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1665 if (NULL == bss)
1666 {
1667 pr_err("wlan: Not able to create BSS entry\n");
Katya Nigam346d4e92014-09-02 16:16:12 +05301668 netif_carrier_off(dev);
Jeff Johnson295189b2012-06-20 16:38:30 -07001669 return eHAL_STATUS_FAILURE;
1670 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001671#ifdef WLAN_FEATURE_VOWIFI_11R
1672 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001673 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001674 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001675
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001676 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001677 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001678 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001679 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001680 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001681 // pFTAssocRsp needs to point to the IEs
1682 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1683 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1684 (unsigned int)pFTAssocRsp[0],
1685 (unsigned int)pFTAssocRsp[1]);
1686 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001687 }
1688 else
1689 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001690 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1691 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001692 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001693
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001694 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001695 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001696 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001697 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001698 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001699 if(!ft_carrier_on)
1700 {
1701 // pFTAssocReq needs to point to the IEs
1702 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1703 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1704 (unsigned int)pFTAssocReq[0],
1705 (unsigned int)pFTAssocReq[1]);
1706 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1707 }
1708 else
1709 {
1710 /* This should contain only the FTIEs */
1711 assocReqlen = pRoamInfo->nAssocReqLength;
1712 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001713 }
1714 else
1715 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001716 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1717 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001718 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001719
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001720 if(ft_carrier_on)
1721 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301722 if ( !hddDisconInProgress )
1723 {
1724 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001725 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301726 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001727 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301728 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001729 assocRsplen);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301730 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1731 {
1732 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1733 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301734 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001735 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1736 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301737 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301738 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1739 {
1740 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1741 pRoamInfo->fAuthRequired = FALSE;
1742
1743 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1744 pRoamInfo->bssid,
1745 HDD_MAC_ADDR_LEN);
1746 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1747 pRoamInfo->peerMac,
1748 HDD_MAC_ADDR_LEN);
1749 pHddStaCtx->roam_info.roamId = roamId;
1750 pHddStaCtx->roam_info.roamStatus = roamStatus;
1751 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1752 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001753 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301754 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001755 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001756 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001757 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001758 cfg80211_connect_result(dev, pRoamInfo->bssid,
1759 pFTAssocReq, assocReqlen,
1760 pFTAssocRsp, assocRsplen,
1761 WLAN_STATUS_SUCCESS,
1762 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001763 }
1764 }
1765 else
1766#endif
1767 {
1768 /* wpa supplicant expecting WPA/RSN IE in connect result */
1769 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1770 pAdapter->sessionId,
1771 &reqRsnLength,
1772 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001773
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001774 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1775 pAdapter->sessionId,
1776 &rspRsnLength,
1777 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301778 if ( !hddDisconInProgress )
1779 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001780#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301781 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05301782 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301783 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301784 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1785 {
1786 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
1787 }
Mukul Sharma84f27252014-07-14 18:11:42 +05301788 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301789 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001790#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001791
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301792 {
1793 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301794 "%s: sending connect indication to nl80211:"
1795 " for bssid " MAC_ADDRESS_STR
1796 " reason:%d and Status:%d\n",
1797 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1798 roamResult, roamStatus);
1799
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301800 /* inform connect result to nl80211 */
1801 cfg80211_connect_result(dev, pRoamInfo->bssid,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001802 reqRsnIe, reqRsnLength,
1803 rspRsnIe, rspRsnLength,
1804 WLAN_STATUS_SUCCESS,
1805 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301806 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001807 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001808 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301809 if ( !hddDisconInProgress )
1810 {
1811 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07001812#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301813 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07001814#endif
1815 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301816 // Register the Station with TL after associated...
1817 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001818 pRoamInfo,
1819 pHddStaCtx->conn_info.staId[ 0 ],
1820 NULL,
1821 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301822 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001823 }
1824 else
1825 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001826 /* wpa supplicant expecting WPA/RSN IE in connect result */
1827 /* in case of reassociation also need to indicate it to supplicant */
1828 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1829 pAdapter->sessionId,
1830 &reqRsnLength,
1831 reqRsnIe);
1832
1833 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001834 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301835 if( pRoamInfo->fAuthRequired )
1836 {
1837 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1838 pHddStaCtx->conn_info.staId[ 0 ],
1839 WLANTL_STA_CONNECTED );
1840 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1841 }
1842 else
1843 {
1844 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1845 "%s: staId: %d Changing TL state to AUTHENTICATED",
1846 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1847 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1848 pHddStaCtx->conn_info.staId[ 0 ],
1849 WLANTL_STA_AUTHENTICATED );
1850 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301851 hdd_postTLPacketPendingInd(pAdapter,
1852 pHddStaCtx->conn_info.staId[0]);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301853 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001854 }
1855
1856 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1857 {
1858 // perform any WMM-related association processing
1859 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1860 }
1861 else
1862 {
1863 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001864 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001865 vosStatus, vosStatus );
1866 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001867#ifdef WLAN_FEATURE_11W
1868 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1869 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1870#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301871
Jeff Johnson295189b2012-06-20 16:38:30 -07001872 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05301873 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301874 {
1875 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05301876 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301877 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05301878 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
1879 {
1880 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
1881 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001882 }
1883 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001884 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1886
1887 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001888 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001889 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1890 " reason:%d and Status:%d\n",
1891 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1892 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001893 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001894 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1895 " reason:%d and Status:%d\n",
1896 MAC_ADDR_ARRAY(pWextState->req_bssId),
1897 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001898
Abhishek Singh611295e2015-07-09 11:11:54 +05301899 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)
1900 wlan_hdd_get_frame_logs(pAdapter,
Siddharth Bhalda0d1622015-04-24 15:47:49 +05301901 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
1902
Abhishek Singhf4669da2014-05-26 15:07:49 +05301903 /* Set connection state to eConnectionState_NotConnected only when CSR
1904 * has completed operation - with a ASSOCIATION_FAILURE status
1905 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301906 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05301907 {
1908 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1909 "%s: Set HDD connState to eConnectionState_NotConnected",
1910 __func__);
1911 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1912 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05301913 if((pHddCtx->concurrency_mode <= 1) &&
1914 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07001915 {
1916 pHddCtx->isAmpAllowed = VOS_TRUE;
1917 }
1918
1919 //If the Device Mode is Station
1920 // and the P2P Client is Connected
1921 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001922
1923 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001924 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001925 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1926 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05301927 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07001928 {
1929 //Enable BMPS only of other Session is P2P Client
1930 hdd_context_t *pHddCtx = NULL;
1931 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1932
1933 if (NULL != pVosContext)
1934 {
1935 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1936
1937 if(NULL != pHddCtx)
1938 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301939 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301940 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1941 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301942 {
1943 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001944 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301945 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001946 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301947 hdd_enable_bmps_imps(pHddCtx);
1948 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001949 }
1950 }
1951 }
1952
James Zmudafbf5ffc2013-03-25 12:45:35 -07001953 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08001954 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301955 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07001956 {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05301957 if (pRoamInfo)
1958 hddLog(VOS_TRACE_LEVEL_ERROR,
1959 "%s: send connect failure to nl80211:"
1960 " for bssid " MAC_ADDRESS_STR
1961 " reason:%d and Status:%d\n" ,
1962 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
1963 roamResult, roamStatus);
1964 else
1965 hddLog(VOS_TRACE_LEVEL_ERROR,
1966 "%s: connect failed:"
1967 " for bssid " MAC_ADDRESS_STR
1968 " reason:%d and Status:%d\n" ,
1969 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
1970 roamResult, roamStatus);
1971
c_hpothudaa90e22014-06-24 17:23:43 +05301972 /*Clear the roam profile*/
1973 hdd_clearRoamProfileIe( pAdapter );
1974
James Zmudafbf5ffc2013-03-25 12:45:35 -07001975 /* inform association failure event to nl80211 */
1976 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1977 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001978 if (pRoamInfo)
1979 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1980 NULL, 0, NULL, 0,
1981 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1982 GFP_KERNEL );
1983 else
1984 cfg80211_connect_result ( dev, pWextState->req_bssId,
1985 NULL, 0, NULL, 0,
1986 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1987 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001988 }
1989 else
1990 {
Sushant Kaushik21f28232014-12-18 11:42:46 +05301991 if (pRoamInfo){
1992 eCsrAuthType authType =
1993 pWextState->roamProfile.AuthType.authType[0];
1994 v_BOOL_t isWep = (authType == eCSR_AUTH_TYPE_OPEN_SYSTEM) ||
1995 (authType == eCSR_AUTH_TYPE_SHARED_KEY);
1996
1997 /* In case of OPEN-WEP or SHARED-WEP authentication,
1998 * send exact protocol reason code. This enables user
1999 * applications to reconnect the station with correct
2000 * configuration.
2001 */
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002002 cfg80211_connect_result ( dev, pRoamInfo->bssid,
2003 NULL, 0, NULL, 0,
Sushant Kaushik21f28232014-12-18 11:42:46 +05302004 isWep ? pRoamInfo->reasonCode :
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002005 WLAN_STATUS_UNSPECIFIED_FAILURE,
2006 GFP_KERNEL );
Sushant Kaushik21f28232014-12-18 11:42:46 +05302007 } else
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002008 cfg80211_connect_result ( dev, pWextState->req_bssId,
2009 NULL, 0, NULL, 0,
2010 WLAN_STATUS_UNSPECIFIED_FAILURE,
2011 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07002012 }
Jeff Johnsone7245742012-09-05 17:12:55 -07002013 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002014
Kumar Anand82c009f2014-05-29 00:29:42 -07002015 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07002016
c_hpothu24f40982014-04-18 18:00:36 +05302017 if (pRoamInfo)
2018 {
2019 WLANTL_AssocFailed(pRoamInfo->staId);
2020 }
Mihir Sheteb7337272014-04-11 15:53:08 +05302021
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302022 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002023 netif_tx_disable(dev);
2024 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002025
Jeff Johnson295189b2012-06-20 16:38:30 -07002026 }
2027
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302028 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302029 {
2030 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
2031 if (pHostapdAdapter != NULL)
2032 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302033 /* Restart SAP if its operating channel is different
2034 * from AP channel.
2035 */
2036 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
2037 (int)pRoamInfo->pBssDesc->channelId)
2038 {
2039 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
2040 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
2041 (int)pRoamInfo->pBssDesc->channelId);
Deepthi Gowric9c777d2014-12-10 16:17:11 +05302042 hdd_hostapd_stop(pHostapdAdapter->dev);
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302043 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302044 }
2045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002046 return eHAL_STATUS_SUCCESS;
2047}
2048
2049/**============================================================================
2050 *
Jeff Johnson81c17882013-05-03 09:53:35 -07002051 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07002052 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07002053
Jeff Johnson295189b2012-06-20 16:38:30 -07002054 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07002055static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
2056 tCsrRoamInfo *pRoamInfo,
2057 tANI_U32 roamId,
2058 eRoamCmdStatus roamStatus,
2059 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07002060{
Katya Nigam47528772015-02-11 12:24:49 +05302061 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2062 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2063 struct cfg80211_bss *bss;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302064 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Katya Nigam47528772015-02-11 12:24:49 +05302065
Jeff Johnson81c17882013-05-03 09:53:35 -07002066 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
2067 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
2068
Jeff Johnson295189b2012-06-20 16:38:30 -07002069 switch( roamResult )
2070 {
2071 // both IBSS Started and IBSS Join should come in here.
2072 case eCSR_ROAM_RESULT_IBSS_STARTED:
2073 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002074 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07002075 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002076 if (NULL == pRoamInfo)
2077 {
2078 VOS_ASSERT(0);
2079 return;
2080 }
2081
2082 /* When IBSS Started comes from CSR, we need to move
2083 * connection state to IBSS Disconnected (meaning no peers
2084 * are in the IBSS).
2085 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05302086 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2087 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
2088 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07002089 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2090 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302091 /*notify wmm */
2092 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002093 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002094
Jeff Johnson81c17882013-05-03 09:53:35 -07002095 if (pRoamInfo->pBssDesc)
2096 {
Katya Nigam47528772015-02-11 12:24:49 +05302097 hdd_ibss_RegisterSTA (pAdapter, pRoamInfo,
2098 IBSS_BROADCAST_STAID,
2099 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson81c17882013-05-03 09:53:35 -07002100
2101 /* we created the IBSS, notify supplicant */
2102 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
2103 MAC_ADDRESS_STR,
2104 __func__, pAdapter->dev->name,
2105 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2106
2107 /* we must first give cfg80211 the BSS information */
2108 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2109 if (NULL == bss)
2110 {
2111 hddLog(VOS_TRACE_LEVEL_ERROR,
2112 "%s: %s: unable to create IBSS entry",
2113 __func__, pAdapter->dev->name);
2114 return;
2115 }
2116
2117 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07002118 cfg80211_put_bss(
2119#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2120 pHddCtx->wiphy,
2121#endif
2122 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07002123 }
Katya Nigam47528772015-02-11 12:24:49 +05302124 else
2125 {
2126 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2127 "%s: NULL Bss Desc",__func__);
2128 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05302129
2130 /* Set Broadcast key again in case IBSS_COALESCED as DEL BSS,
2131 * in IBSS_COALESCED will remove the BC key.
2132 */
2133 if ((eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) &&
2134 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY
2135 == pHddStaCtx->ibss_enc_key.encType
2136 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY
2137 == pHddStaCtx->ibss_enc_key.encType
2138 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2139 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType ))
2140 {
2141 u8 grpmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2142 VOS_STATUS vosStatus;
2143
2144 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2145
2146 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2147 grpmacaddr, WNI_CFG_BSSID_LEN);
2148 hddLog(VOS_TRACE_LEVEL_INFO,
2149 FL(" SET GTK in case of COALESCED"));
2150 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2151 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2152 if ( VOS_STATUS_SUCCESS != vosStatus )
2153 {
2154 hddLog(VOS_TRACE_LEVEL_ERROR,
2155 FL("sme_RoamSetKey failed, returned %d"),vosStatus);
2156 }
2157 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002158 break;
2159 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002160
Jeff Johnson295189b2012-06-20 16:38:30 -07002161 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
2162 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002163 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
2164 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07002165 break;
2166 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002167
Jeff Johnson295189b2012-06-20 16:38:30 -07002168 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07002169 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
2170 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07002171 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002172 }
2173
Jeff Johnson81c17882013-05-03 09:53:35 -07002174 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07002175}
2176
2177/**============================================================================
2178 *
2179 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
2180 This information is passed to iwconfig later. The peer that joined
2181 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002182 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002183 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002184
Jeff Johnson295189b2012-06-20 16:38:30 -07002185 ===========================================================================*/
Nirav Shah7e3c8132015-06-22 23:51:42 +05302186static int roamSaveIbssStation(hdd_adapter_t *pAdapter, v_U8_t staId, v_MACADDR_t *peerMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07002187{
2188 int fSuccess = FALSE;
2189 int idx = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302190 VOS_STATUS status;
2191 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002192
Jeff Johnson295189b2012-06-20 16:38:30 -07002193 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2194 {
2195 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
2196 {
2197 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002198
Jeff Johnson295189b2012-06-20 16:38:30 -07002199 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002200
Jeff Johnson295189b2012-06-20 16:38:30 -07002201 fSuccess = TRUE;
2202 break;
2203 }
2204 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002205
Nirav Shah7e3c8132015-06-22 23:51:42 +05302206 status = hdd_sta_id_hash_add_entry(pAdapter, staId, peerMacAddress);
2207 if (status != VOS_STATUS_SUCCESS) {
2208 hddLog(VOS_TRACE_LEVEL_ERROR,
2209 FL("Not able to add staid hash %d"), staId);
2210 return FALSE;
2211 }
2212
2213 hddLog(VOS_TRACE_LEVEL_INFO,
2214 FL("New station added sta_id %d mac:"
2215 MAC_ADDRESS_STR), staId,
2216 MAC_ADDR_ARRAY(peerMacAddress->bytes));
2217
Shailender Karmuchia734f332013-04-19 14:02:48 -07002218 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07002219}
2220/**============================================================================
2221 *
2222 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002223 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07002224 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002225
Jeff Johnson295189b2012-06-20 16:38:30 -07002226 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07002227static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07002228{
2229 int fSuccess = FALSE;
2230 int idx = 0;
2231 v_U8_t valid_idx = 0;
2232 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07002233 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002234 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Nirav Shah7e3c8132015-06-22 23:51:42 +05302235 VOS_STATUS status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002236
Jeff Johnson295189b2012-06-20 16:38:30 -07002237 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
2238 {
2239 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
2240 {
2241 pHddStaCtx->conn_info.staId[ idx ] = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05302242 status = hdd_sta_id_hash_remove_entry(pAdapter,
2243 staId, &pHddStaCtx->conn_info.peerMacAddress[idx]);
2244 if (status != VOS_STATUS_SUCCESS) {
2245 hddLog(VOS_TRACE_LEVEL_ERROR,
2246 FL("Not able to remove staid hash %d"), staId );
2247 fSuccess = FALSE;
2248 } else {
2249 hddLog(VOS_TRACE_LEVEL_INFO,
2250 FL("station removed sta_id %d mac:"
2251 MAC_ADDRESS_STR), staId,
2252 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[idx].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07002253
Nirav Shah7e3c8132015-06-22 23:51:42 +05302254 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07002255
Nirav Shah7e3c8132015-06-22 23:51:42 +05302256 fSuccess = TRUE;
2257 // Note the deleted Index, if its 0 we need special handling
2258 del_idx = idx;
2259 empty_slots++;
2260 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002261 }
2262 else
2263 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002264 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002265 {
2266 valid_idx = idx;
2267 }
Ravi Joshi8a934352013-09-25 16:46:58 -07002268 else
2269 {
2270 // Found an empty slot
2271 empty_slots++;
2272 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 }
2274 }
2275
Ravi Joshi8a934352013-09-25 16:46:58 -07002276 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
2277 {
2278 // Last peer departed, set the IBSS state appropriately
2279 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002280 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07002281 "Last IBSS Peer Departed!!!" );
2282 }
2283
Jeff Johnson295189b2012-06-20 16:38:30 -07002284 // Find next active staId, to have a valid sta trigger for TL.
2285 if (fSuccess == TRUE)
2286 {
2287 if (del_idx == 0)
2288 {
2289 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
2290 {
2291 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
2292 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
2293 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
2294
2295 pHddStaCtx->conn_info.staId[valid_idx] = 0;
2296 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
2297 }
2298 }
2299 }
2300 return( fSuccess );
2301}
2302
2303/**============================================================================
2304 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002305 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07002306 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002307
Jeff Johnson295189b2012-06-20 16:38:30 -07002308 ===========================================================================*/
2309static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
2310{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002311 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05302312 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2313 "%s: IBSS Connect Indication from SME!!! "
2314 "Set HDD connState to eConnectionState_IbssConnected",
2315 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002316 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
2317 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
2318
2319 // Save the connection info from CSR...
2320 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
2321
2322 // Send the bssid address to the wext.
2323 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07002324 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002325 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2326 if (NULL == bss)
2327 {
2328 hddLog(VOS_TRACE_LEVEL_ERROR,
2329 "%s: %s: unable to create IBSS entry",
2330 __func__, pAdapter->dev->name);
2331 return eHAL_STATUS_FAILURE;
2332 }
Yue Maf49ba872013-08-19 12:04:25 -07002333 cfg80211_put_bss(
2334#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2335 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
2336#endif
2337 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07002338
2339 return( eHAL_STATUS_SUCCESS );
2340}
2341/**============================================================================
2342 *
Mukul Sharmad2589a52014-04-23 21:06:25 +05302343 @brief hdd_ReConfigSuspendDataClearedDuringRoaming() - Reconfigure the
2344 suspend related data which was cleared during roaming in FWR.
2345
2346 ===========================================================================*/
2347static void hdd_ReConfigSuspendDataClearedDuringRoaming(hdd_context_t *pHddCtx)
2348{
2349 VOS_STATUS vstatus = VOS_STATUS_E_FAILURE;
2350 hdd_adapter_t *pAdapter;
2351 hdd_adapter_list_node_t *pAdapterNode = NULL, *pNext = NULL;
2352 ENTER();
2353
2354 spin_lock(&pHddCtx->filter_lock);
2355 if (VOS_FALSE == pHddCtx->sus_res_mcastbcast_filter_valid)
2356 {
2357 pHddCtx->sus_res_mcastbcast_filter =
2358 pHddCtx->configuredMcastBcastFilter;
2359 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_TRUE;
2360 hddLog(VOS_TRACE_LEVEL_INFO, FL("offload: callback to associated"));
2361 hddLog(VOS_TRACE_LEVEL_INFO,
2362 FL("saving configuredMcastBcastFilter = %d"),
2363 pHddCtx->configuredMcastBcastFilter);
2364 hddLog(VOS_TRACE_LEVEL_INFO,
2365 FL("offload: calling hdd_conf_mcastbcast_filter"));
2366 }
2367 spin_unlock(&pHddCtx->filter_lock);
2368
2369 hdd_conf_mcastbcast_filter(pHddCtx, TRUE);
2370 if(pHddCtx->hdd_mcastbcast_filter_set != TRUE)
2371 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Not able to set mcast/bcast filter "));
2372
2373 vstatus = hdd_get_front_adapter ( pHddCtx, &pAdapterNode );
2374 //No need to configure GTK Offload from here because it might possible
2375 //cfg80211_set_rekey_data might not yet came, anyway GTK offload will
2376 //be handled as part of cfg80211_set_rekey_data processing.
2377 while ( NULL != pAdapterNode && VOS_STATUS_SUCCESS == vstatus )
2378 {
2379 pAdapter = pAdapterNode->pAdapter;
2380 if( pAdapter &&
2381 (( pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
2382 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)))
2383 {
2384 if (pHddCtx->cfg_ini->fhostArpOffload)
2385 {
2386 //Configure ARPOFFLOAD
2387 vstatus = hdd_conf_arp_offload(pAdapter, TRUE);
2388 if (!VOS_IS_STATUS_SUCCESS(vstatus))
2389 {
2390 hddLog(VOS_TRACE_LEVEL_ERROR,
2391 FL("Failed to disable ARPOffload Feature %d"), vstatus);
2392 }
2393 }
2394#ifdef WLAN_NS_OFFLOAD
2395 //Configure NSOFFLOAD
2396 if (pHddCtx->cfg_ini->fhostNSOffload)
2397 {
2398 hdd_conf_ns_offload(pAdapter, TRUE);
2399 }
2400#endif
Mukul Sharma25e70c32014-05-22 12:50:24 +05302401#ifdef WLAN_FEATURE_PACKET_FILTERING
2402 /* During suspend, configure MC Addr list filter to the firmware
2403 * function takes care of checking necessary conditions before
2404 * configuring.
2405 */
2406 wlan_hdd_set_mc_addr_list(pAdapter, TRUE);
2407#endif
Mukul Sharmad2589a52014-04-23 21:06:25 +05302408 }
2409 vstatus = hdd_get_next_adapter ( pHddCtx, pAdapterNode, &pNext );
2410 pAdapterNode = pNext;
2411 }
2412 EXIT();
2413}
2414
2415/**============================================================================
2416 *
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002418
Jeff Johnson295189b2012-06-20 16:38:30 -07002419 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002420static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2421 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002422 eCsrRoamResult roamResult )
2423{
2424 eCsrEncryptionType connectedCipherAlgo;
2425 v_BOOL_t fConnected = FALSE;
2426 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2427 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2428 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302429 WLANTL_STAStateType prevTLState = WLANTL_STA_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07002430 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07002431
2432 if (NULL == pRoamInfo)
2433 {
2434 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
2435 return eHAL_STATUS_FAILURE;
2436 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002437 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002438 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07002439 // not require upper layer authentication) we can put TL directly into 'authenticated'
2440 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002441 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2442 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
2443 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002444
Jeff Johnson295189b2012-06-20 16:38:30 -07002445 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2446 if( fConnected )
2447 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002448 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
2449 {
2450 v_U8_t staId;
2451
2452 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2453
2454 if ( 0 == memcmp( pRoamInfo->peerMac,
2455 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
2456 {
2457 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2458 IBSS_BROADCAST_STAID);
Abhishek Singhb25e8442015-06-23 14:28:05 +05302459 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2460 "WLAN TL STA GTK Installed for STAID=%d", IBSS_BROADCAST_STAID);
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002461 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2462 }
2463 else
2464 {
2465 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
2466 (v_MACADDR_t*)pRoamInfo->peerMac,
2467 &staId);
2468 if ( VOS_STATUS_SUCCESS == vosStatus )
2469 {
2470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2471 "WLAN TL STA Ptk Installed for STAID=%d", staId);
2472 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2473 staId);
2474 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2475 }
2476 }
2477 }
2478 else
2479 {
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302480 // TODO: Considering getting a state machine in HDD later.
2481 // This routine is invoked twice. 1)set PTK 2)set GTK.
2482 // The folloing if statement will be TRUE when setting GTK.
2483 // At this time we don't handle the state in detail.
2484 // Related CR: 174048 - TL not in authenticated state
2485 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
2486 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
2487 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302488 WLANTL_GetSTAState(pHddCtx->pvosContext,
2489 pHddStaCtx->conn_info.staId[0],
2490 &prevTLState);
2491
2492 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
2493 "for StaId=%d. Changing TL state to AUTHENTICATED from"
2494 " state:%d", pHddStaCtx->conn_info.staId[0], prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302495
2496 // Connections that do not need Upper layer authentication,
2497 // transition TL to 'Authenticated' state after the keys are set.
2498 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2499 pHddStaCtx->conn_info.staId[ 0 ],
2500 WLANTL_STA_AUTHENTICATED );
2501
2502 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302503
2504 if (WLANTL_STA_AUTHENTICATED != prevTLState)
2505 hdd_postTLPacketPendingInd(pAdapter,
2506 pHddStaCtx->conn_info.staId[0]);
Mukul Sharmad2589a52014-04-23 21:06:25 +05302507 //Need to call offload because when roaming happen at that time fwr
2508 //clean offload info as part of the DelBss
2509 // No need to configure offload if host was not suspended
2510 spin_lock(&pHddCtx->filter_lock);
2511 if(pHddCtx->hdd_wlan_suspended)
2512 {
2513 spin_unlock(&pHddCtx->filter_lock);
2514 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
2515 }
2516 else
2517 {
2518 spin_unlock(&pHddCtx->filter_lock);
2519 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302520 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2521 {
2522 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
2523 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302524 }
2525 else
2526 {
2527 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
2528 pHddStaCtx->conn_info.staId[ 0 ]);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302529 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
2530 {
2531 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
2532 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302533 }
2534
2535 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002536 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002537 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302538 else
2539 {
2540 // possible disassoc after issuing set key and waiting set key complete
2541 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
2542 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002543
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 EXIT();
2545 return( eHAL_STATUS_SUCCESS );
2546}
2547/**============================================================================
2548 *
2549 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
2550 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002551static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07002552 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07002553{
Jeff Johnson295189b2012-06-20 16:38:30 -07002554 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2555
2556 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
2557 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
2558 {
2559 struct iw_michaelmicfailure msg;
2560 union iwreq_data wreq;
2561 memset(&msg, '\0', sizeof(msg));
2562 msg.src_addr.sa_family = ARPHRD_ETHER;
2563 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08002564 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
2565 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002566
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
2568 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002569 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002570 msg.flags = IW_MICFAILURE_PAIRWISE;
2571 memset(&wreq, 0, sizeof(wreq));
2572 wreq.data.length = sizeof(msg);
2573 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07002574 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002575 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07002576 pRoamInfo->u.pMICFailureInfo->taMacAddr,
2577 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
2578 NL80211_KEYTYPE_GROUP :
2579 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07002580 pRoamInfo->u.pMICFailureInfo->keyId,
2581 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07002582 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002583
Jeff Johnson295189b2012-06-20 16:38:30 -07002584 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002585
Jeff Johnson295189b2012-06-20 16:38:30 -07002586 return( eHAL_STATUS_SUCCESS );
2587}
2588
2589/**============================================================================
2590 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07002591 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07002592 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002593
Jeff Johnson295189b2012-06-20 16:38:30 -07002594 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07002595static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2596 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002597 eCsrRoamResult roamResult )
2598{
2599 VOS_STATUS vosStatus;
2600
2601 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2602 switch( roamResult )
2603 {
2604 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
2605 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002606 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002607 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002608
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002609 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002610 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2611 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2612 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07002613 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002614
Nirav Shah7e3c8132015-06-22 23:51:42 +05302615 if ( !roamSaveIbssStation( pAdapter, pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002616 {
2617 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2618 "New IBSS peer but we already have the max we can handle. Can't register this one" );
2619 break;
2620 }
2621
2622 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2623
Shailender Karmuchia734f332013-04-19 14:02:48 -07002624 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
2625 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
2626 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
2627
2628 // Register the Station with TL for the new peer.
Katya Nigam47528772015-02-11 12:24:49 +05302629 vosStatus = hdd_ibss_RegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002630 pRoamInfo,
2631 pRoamInfo->staId,
2632 (v_MACADDR_t *)pRoamInfo->peerMac,
2633 pRoamInfo->pBssDesc );
2634 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2635 {
2636 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002637 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002638 vosStatus, vosStatus );
2639 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002640 pHddStaCtx->ibss_sta_generation++;
2641 memset(&staInfo, 0, sizeof(staInfo));
2642 staInfo.filled = 0;
2643 staInfo.generation = pHddStaCtx->ibss_sta_generation;
2644
2645 cfg80211_new_sta(pAdapter->dev,
2646 (const u8 *)pRoamInfo->peerMac,
2647 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002648
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002649 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2650 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
2651 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2652 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
2653 {
2654 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302655
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002656 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2657 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
2658
2659 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002660 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002661 pHddStaCtx->ibss_enc_key.encType);
2662
2663 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2664 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2665
2666 if ( VOS_STATUS_SUCCESS != vosStatus )
2667 {
2668 hddLog(VOS_TRACE_LEVEL_ERROR,
2669 "%s: sme_RoamSetKey failed, returned %d",
2670 __func__, vosStatus);
2671 return VOS_STATUS_E_FAILURE;
2672 }
2673 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002674 netif_carrier_on(pAdapter->dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302675 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002676 netif_tx_start_all_queues(pAdapter->dev);
2677 break;
2678 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002679
Jeff Johnson295189b2012-06-20 16:38:30 -07002680 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2681 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002682
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002684
Jeff Johnson295189b2012-06-20 16:38:30 -07002685 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002686 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002687 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2688 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002689 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002690
Ravi Joshicc57ed42013-10-12 16:31:25 -07002691 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002692 {
2693 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2694 "IBSS peer departed by cannot find peer in our registration table with TL" );
2695 }
2696
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002697 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002698 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2699 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2700 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2701 pRoamInfo->staId );
2702
Katya Nigam47528772015-02-11 12:24:49 +05302703 hdd_ibss_DeregisterSTA( pAdapter, pRoamInfo->staId );
Jeff Johnson295189b2012-06-20 16:38:30 -07002704
2705 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002706 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002707
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002708 cfg80211_del_sta(pAdapter->dev,
2709 (const u8 *)&pRoamInfo->peerMac,
2710 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002711 break;
2712 }
2713 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2714 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002715 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2716 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002717 // Stop only when we are inactive
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302718 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002719 netif_tx_disable(pAdapter->dev);
2720 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05302721 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2722 "%s: Set HDD connState to eConnectionState_NotConnected",
2723 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07002724 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002725
Jeff Johnson295189b2012-06-20 16:38:30 -07002726 // Send the bssid address to the wext.
2727 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2728 // clean up data path
2729 hdd_disconnect_tx_rx(pAdapter);
2730 break;
2731 }
2732 default:
2733 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002734
Jeff Johnson295189b2012-06-20 16:38:30 -07002735 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002736
Jeff Johnson295189b2012-06-20 16:38:30 -07002737 return( eHAL_STATUS_SUCCESS );
2738}
2739
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002740#ifdef FEATURE_WLAN_TDLS
2741/**============================================================================
2742 *
2743 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2744 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2745 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002746
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002747 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002748VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
2749 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002750{
2751 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002752 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002753 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2754 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002755 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2756 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002757 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2758 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002759
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002760 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2761 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002762 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002763 "%s not connected. ignored", __func__);
2764 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002765 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002766
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002767 /*
2768 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2769 * be peer MAC, here we are wokrking on direct Link
2770 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002771 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002772
2773 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002774
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002775 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002776 sizeof(tSirMacAddr) );
2777
2778 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2779 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2780
2781 /* set the QoS field appropriately ..*/
2782 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2783 : (staDesc.ucQosEnabled = 0) ;
2784
2785 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002786 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002787
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002788 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002789
2790 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002791 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002792
Shailender Karmuchia734f332013-04-19 14:02:48 -07002793 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002794 * UMA is ready we inform TL to do frame translation.
2795 */
2796 staDesc.ucSwFrameTXXlation = 1;
2797 staDesc.ucSwFrameRXXlation = 1;
2798 staDesc.ucAddRmvLLC = 1;
2799
2800 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002801 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002802
2803 /* tdls Direct Link do not need bcastSig */
2804 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002805
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002806#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2807 if(staDesc.ucProtectedFrame)
2808 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2809 else
2810 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2811#endif
2812
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302813 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002814
Shailender Karmuchia734f332013-04-19 14:02:48 -07002815 /* Register the Station with TL... */
2816 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2817 hdd_rx_packet_cbk,
2818 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002819 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002820
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002821 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2822 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002823 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002824 "%s: WLANTL_RegisterSTAClient() failed to register. "
2825 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002826 return vosStatus;
2827 }
2828
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002829 if ( cfg_param->dynSplitscan &&
2830 ( VOS_TIMER_STATE_RUNNING !=
2831 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2832 {
2833 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2834 cfg_param->trafficMntrTmrForSplitScan);
2835 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002836 return( vosStatus );
2837}
2838
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05302839VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002840{
2841 VOS_STATUS vosStatus;
2842 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2843 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2844 {
2845 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2846 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002847 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002848 __func__, staId, vosStatus, vosStatus );
2849 }
2850 return( vosStatus );
2851}
2852
2853
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002854/*
2855 * HDD interface between SME and TL to ensure TDLS client registration with
2856 * TL in case of new TDLS client is added and deregistration at the time
2857 * TDLS client is deleted.
2858 */
2859
Shailender Karmuchia734f332013-04-19 14:02:48 -07002860eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2861 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002862 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002863 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002864 eCsrRoamResult roamResult)
2865{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002866 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002867 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002868 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002869
Kaushik, Sushant8489f472014-01-27 11:41:22 +05302870 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08002871 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2872 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2873 "ADD_TDLS_PEER" :
2874 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2875 "DEL_TDLS_PEER" :
2876 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2877 "DEL_TDLS_PEER_IND" :
2878 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2879 "DEL_ALL_TDLS_PEER_IND" :
2880 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2881 "UPDATE_TDLS_PEER" :
2882 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2883 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2884 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002885 switch( roamResult )
2886 {
2887 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2888 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002889 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2890 {
2891 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002892 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002893 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002894 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002895 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002896
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002897 /* check if there is available index for this new TDLS STA */
2898 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2899 {
2900 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2901 {
2902 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2903 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2904
2905 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002906 ("TDLS: STA IDX at %d is %d "
2907 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002908 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002909 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002910
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002911 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002912 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2913 status = eHAL_STATUS_SUCCESS ;
2914 break ;
2915 }
2916 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002917 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002918 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002919 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002920 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2921 "wlan_hdd_tdls_set_sta_id() failed");
2922 return VOS_FALSE;
2923 }
2924
2925 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302926 /* store the ucast signature , if required for further reference. */
2927
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002928 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302929 /* start TDLS client registration with TL */
2930 status = hdd_roamRegisterTDLSSTA( pAdapter,
2931 pRoamInfo->peerMac,
2932 pRoamInfo->staId,
2933 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05302934 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002935 }
2936 else
2937 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002938 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002939 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002940 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002941 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002942 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002943 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002944 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002945 break ;
2946 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002947 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
2948 {
2949 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2950 {
2951 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2952 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
2953 }
2954 /* store the ucast signature which will be used later when
2955 * registering to TL
2956 */
2957 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
2958 complete(&pAdapter->tdls_add_station_comp);
2959 break;
2960 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302961 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
2962 {
2963 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2964 {
2965 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2966 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
2967 }
2968 complete(&pAdapter->tdls_link_establish_req_comp);
2969 break;
2970 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002971 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002972 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002973 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002974 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002975 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002976 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2977 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002978 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002979 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002980 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2981
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302982 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05302983 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002984 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05302985 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2986 " Current status for peer" MAC_ADDRESS_STR "is %d",
2987 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05302988 if (TDLS_IS_CONNECTED(curr_peer) ||
2989 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05302990 {
2991 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2992 }
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05302993 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002994 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002995 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002996
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002997 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2998 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
2999 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003000 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003001 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003002 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003003 break ;
3004 }
3005 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003006 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003007 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003008 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003009 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3010 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003011 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003012 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3013 "%s: Sending teardown to supplicant with reason code %u",
3014 __func__, pRoamInfo->reasonCode);
3015
3016#ifdef CONFIG_TDLS_IMPLICIT
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05303017 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003018 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003019#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003020 status = eHAL_STATUS_SUCCESS ;
3021 break ;
3022 }
3023 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3024 {
3025 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003026 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003027 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003028 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3029 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003030 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003031 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003032 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003033 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003034 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003035 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
3036 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3037 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003038
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003039 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003040 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003041 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3042 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003043
3044 status = eHAL_STATUS_SUCCESS ;
3045 }
3046 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303047 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003048 break ;
3049 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003050 default:
3051 {
3052 break ;
3053 }
3054 }
3055
3056 return status ;
3057}
3058#endif
3059
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003060static void iw_full_power_cbfn (void *pContext, eHalStatus status)
3061{
3062 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3063 hdd_context_t *pHddCtx = NULL;
3064 int ret;
3065
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303066 ENTER();
3067
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003068 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3069 {
3070 hddLog(VOS_TRACE_LEVEL_ERROR,
3071 "%s: Bad param, pAdapter [%p]",
3072 __func__, pAdapter);
3073 return;
3074 }
3075
3076 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3077 ret = wlan_hdd_validate_context(pHddCtx);
3078 if (0 != ret)
3079 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003080 return;
3081 }
3082
3083 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3084 {
3085 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
3086 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303087
3088 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003089}
3090
Shailender Karmuchia734f332013-04-19 14:02:48 -07003091eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
3093{
3094 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
3095 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303096 hdd_wext_state_t *pWextState = NULL;
3097 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003098 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07003099 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003100
3101 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003102 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003103 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003104
3105 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303106 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003107 {
3108 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303109 "invalid adapter or adapter has invalid magic");
3110 return eHAL_STATUS_FAILURE;
3111 }
3112
3113 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3114 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3115
3116 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3117 {
3118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3119 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003120 return eHAL_STATUS_FAILURE;
3121 }
3122
Jeff Johnson295189b2012-06-20 16:38:30 -07003123 switch( roamStatus )
3124 {
3125 case eCSR_ROAM_SESSION_OPENED:
3126 if(pAdapter != NULL)
3127 {
3128 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
3129 complete(&pAdapter->session_open_comp_var);
3130 }
3131 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003132
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003133#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
3134 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07003136 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07003137 * interface down */
3138 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303139 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
3140 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05303141 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003142 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3143 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
3144 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3146 }
3147 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05303148 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003149 break;
3150
3151 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003152 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07003153 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07003154 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07003155 // eCSR_ROAM_SHOULD_ROAM will be received.
3156 // Where in we will not mark the link down
3157 // Also we want to stop tx at this point when we will be
3158 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003159 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003160 {
3161 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303162 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003163 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303164 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3165 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3166 {
3167 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
3168 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003169 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303170 * Deregister this STA with TL, but do not flush the packets
3171 * for this STA from wmm_tx_queue. Since there is no valid STA
3172 * for these packets they will not be transmitted. Eventually
3173 * after the reassociation is successful, these packets will be
3174 * transmitted after registering STA with TL again. This ensures
3175 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003176 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303177 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
3178 pHddStaCtx->conn_info.staId[0]);
3179 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003180 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3182 FL("WLANTL_ClearSTAClient failed for staID %d."
3183 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
3184 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003185 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07003186 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 }
3188 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003189 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 break;
3191#endif
3192
3193 case eCSR_ROAM_SHOULD_ROAM:
3194 // Dont need to do anything
3195 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003196 struct net_device *dev = pAdapter->dev;
3197 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3198 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303199 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003201#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003202 if (pHddStaCtx->ft_carrier_on == FALSE)
3203 {
3204#endif
3205 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003206#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07003207 }
3208#endif
3209
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003210#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07003211 //We should clear all sta register with TL, for now, only one.
3212 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
3213 if ( !VOS_IS_STATUS_SUCCESS(status ) )
3214 {
3215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3216 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
3217 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003218 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003219 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003220#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003221 }
3222 break;
3223 case eCSR_ROAM_LOSTLINK:
3224 case eCSR_ROAM_DISASSOCIATED:
3225 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3227 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05303228 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003229 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3230 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07003231 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3232 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303233 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07003234 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08003235
3236 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
3237 pHddCtx->configuredMcastBcastFilter =
3238 pHddCtx->sus_res_mcastbcast_filter;
3239 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
3240 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303241
Amar Singhald53568e2013-09-26 11:03:45 -07003242 hddLog(VOS_TRACE_LEVEL_INFO,
3243 "offload: disassociation happening, restoring configuredMcastBcastFilter");
3244 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
3245 pHddCtx->configuredMcastBcastFilter);
3246 hddLog(VOS_TRACE_LEVEL_INFO,
3247 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07003248 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3249 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003250#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05303251 /* Call to clear any MC Addr List filter applied after
3252 * successful connection.
3253 */
3254 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07003255#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003256 }
3257 break;
3258 case eCSR_ROAM_IBSS_LEAVE:
3259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3260 "****eCSR_ROAM_IBSS_LEAVE****");
3261 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3262 break;
3263 case eCSR_ROAM_ASSOCIATION_COMPLETION:
3264 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3265 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303266 // To Do - address probable memory leak with WEP encryption upon successful association
3267 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07003268 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303269 //Clear saved connection information in HDD
3270 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07003271 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05303272 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003273
3274 break;
3275 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003276 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 pRoamInfo, roamId, roamStatus, roamResult );
3278 break;
3279 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07003280 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
3281 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07003282 break;
3283
3284 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
3285 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003286 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07003287
3288 case eCSR_ROAM_MIC_ERROR_IND:
3289 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3290 break;
3291
3292 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003293 {
3294 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
3295
3296 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003297 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
3298 (TRUE == pHddCtx->hdd_wlan_suspended) &&
3299 (eCSR_ROAM_RESULT_NONE == roamResult))
3300 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003301 /* Send DTIM period to the FW; only if the wlan is already
3302 in suspend. This is the case with roaming (reassoc),
3303 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
3304 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
3305 before the ENTER_BMPS_REQ ensures Listen Interval is
3306 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003307 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003308
3309 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07003310 if due to unexpected scenario, if we are in BMPS,
3311 then trigger Exit and Enter BMPS to take DTIM period
3312 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003313 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
3314 {
3315 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
3316
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003317 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
3318 iw_full_power_cbfn, pAdapter,
3319 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003320 }
3321 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05303322
3323 if ((pHddCtx) &&
3324 FULL_POWER == pmcGetPmcState(pHddCtx->hHal) &&
3325 VOS_TRUE == pHddStaCtx->hdd_ReassocScenario)
3326 {
3327 hddLog( LOG1, FL("Device in full power."
3328 "Stop and start traffic timer for roaming"));
3329 pmcStopTrafficTimer(pHddCtx->hHal);
3330 if (pmcStartTrafficTimer(pHddCtx->hHal,
3331 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
3332 {
3333 hddLog(LOGP, FL("Cannot start traffic timer"));
3334 }
3335 }
3336
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003337 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05303338 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07003339 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003340 break;
3341#ifdef WLAN_FEATURE_VOWIFI_11R
3342 case eCSR_ROAM_FT_RESPONSE:
3343 hdd_SendFTEvent(pAdapter);
3344 break;
3345#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07003346#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003347 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003348 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07003349 {
3350 /* Notify the supplicant of a new candidate */
3351 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
3352 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003353 break;
3354#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003355
Yue Maef608272013-04-08 23:09:17 -07003356#ifdef FEATURE_WLAN_LFR_METRICS
3357 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
3358 /* This event is to notify pre-auth initiation */
3359 if (VOS_STATUS_SUCCESS !=
3360 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
3361 {
3362 halStatus = eHAL_STATUS_FAILURE;
3363 }
3364 break;
3365 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
3366 /* This event will notify pre-auth completion in case of success */
3367 if (VOS_STATUS_SUCCESS !=
3368 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3369 pRoamInfo, 1))
3370 {
3371 halStatus = eHAL_STATUS_FAILURE;
3372 }
3373 break;
3374 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
3375 /* This event will notify pre-auth completion in case of failure. */
3376 if (VOS_STATUS_SUCCESS !=
3377 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
3378 pRoamInfo, 0))
3379 {
3380 halStatus = eHAL_STATUS_FAILURE;
3381 }
3382 break;
3383 case eCSR_ROAM_HANDOVER_SUCCESS:
3384 /* This event is to notify handover success.
3385 It will be only invoked on success */
3386 if (VOS_STATUS_SUCCESS !=
3387 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
3388 {
3389 halStatus = eHAL_STATUS_FAILURE;
3390 }
3391 break;
3392#endif
3393
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 case eCSR_ROAM_INDICATE_MGMT_FRAME:
3395 hdd_indicateMgmtFrame( pAdapter,
3396 pRoamInfo->nFrameLength,
3397 pRoamInfo->pbFrames,
3398 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05303399 pRoamInfo->rxChan,
3400 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 break;
3402 case eCSR_ROAM_REMAIN_CHAN_READY:
3403 hdd_remainChanReadyHandler( pAdapter );
3404 break;
3405 case eCSR_ROAM_SEND_ACTION_CNF:
3406 hdd_sendActionCnf( pAdapter,
3407 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
3408 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003409#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08003410 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003411 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08003412 roamId, roamStatus, roamResult );
3413 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003414 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
3415 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
3416 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003417#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07003418#ifdef WLAN_FEATURE_11W
3419 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
3420 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
3421 pRoamInfo->pbFrames,
3422 pRoamInfo->frameType);
3423 break;
3424#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003425#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003426 case eCSR_ROAM_TSM_IE_IND:
3427 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
3428 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
3429 break;
3430
3431 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
3432 {
3433 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
3434 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
3435 {
3436 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
3437 }
3438 break;
3439 }
3440
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003441 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003442 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003443 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003444 break;
3445 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003446
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003447 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003448 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003449 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003450 break;
3451 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003452#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05303453 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
3454 {
3455 pAdapter->maxRateFlags = roamResult;
3456 break;
3457 }
3458 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07003459 break;
3460 }
3461 return( halStatus );
3462}
Shailender Karmuchia734f332013-04-19 14:02:48 -07003463eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003464{
3465 eCsrAuthType auth_type;
3466 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003467 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 {
3469 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003470 } else
3471 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 {
3473 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003474 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003475#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003476 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003477 {
3478 // Check for 11r FT Authentication with PSK
3479 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003480 } else
3481 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003482 {
3483 // Check for 11R FT Authentication with 802.1X
3484 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003485 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003486#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003487#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003488 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 {
3490 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
3491 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003492#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07003493#ifdef WLAN_FEATURE_11W
3494 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
3495 {
3496 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3497 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303498 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
3499 {
3500 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3501 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003502#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003503 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3505 }
3506 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003507}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003508
Shailender Karmuchia734f332013-04-19 14:02:48 -07003509eCsrAuthType
3510hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003511{
3512 eCsrAuthType auth_type;
3513 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003514 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 {
3516 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003517 } else
3518 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003519 {
3520 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003521 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003522#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003523 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003524 {
3525 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003526 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003527#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003528 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
3530 }
3531 hddLog(LOG1, FL("auth_type: %d"), auth_type);
3532 return auth_type;
3533}
Jeff Johnson7dda7772013-02-27 08:36:13 -08003534
Shailender Karmuchia734f332013-04-19 14:02:48 -07003535eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003536hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003537{
3538 eCsrEncryptionType cipher_type;
3539 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003540 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003541 {
3542 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003543 }
3544 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003545 {
3546 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003547 }
3548 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003549 {
3550 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003551 }
3552 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003553 {
3554 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003555 }
3556 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
3557 {
3558 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3559 }
3560 else
3561 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003562 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3563 }
3564 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3565 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003566}
Jeff Johnson295189b2012-06-20 16:38:30 -07003567/* To find if the MAC address is NULL */
3568static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
3569{
3570 int i;
3571 for (i = 0; i < length; i++)
3572 {
3573 if (0x00 != (macAddr[i]))
3574 {
3575 return FALSE;
3576 }
3577 }
3578 return TRUE;
3579} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08003580
Shailender Karmuchia734f332013-04-19 14:02:48 -07003581eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07003582hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07003583{
3584 eCsrEncryptionType cipher_type;
3585 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07003586 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003587 {
3588 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003589 } else
3590 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003591 {
3592 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003593 } else
3594 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003595 {
3596 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003597 } else
3598 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003599 {
3600 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003601 } else
3602 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003603 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003604 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3605 } else
3606 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003607 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
3608 }
3609 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
3610 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003611}
Jeff Johnson295189b2012-06-20 16:38:30 -07003612
Shailender Karmuchia734f332013-04-19 14:02:48 -07003613static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
3614 struct ether_addr *pBssid,
3615 eCsrEncryptionType *pEncryptType,
3616 eCsrEncryptionType *mcEncryptType,
3617 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003618#ifdef WLAN_FEATURE_11W
3619 u_int8_t *pMfpRequired,
3620 u_int8_t *pMfpCapable,
3621#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003622 u_int16_t gen_ie_len,
3623 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07003624{
3625 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003626 eHalStatus result;
3627 tDot11fIERSN dot11RSNIE;
3628 tDot11fIEWPA dot11WPAIE;
3629 tANI_U32 i;
3630 tANI_U8 *pRsnIe;
3631 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07003632 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07003633 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003634
3635 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
3636 flag to 0 */
3637 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
3638 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
3639
Jeff Johnson295189b2012-06-20 16:38:30 -07003640 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07003641 if ( gen_ie[0] == DOT11F_EID_RSN)
3642 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003643 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07003644 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
3646 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303647 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
3648 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003649 return -EINVAL;
3650 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003651 // Skip past the EID byte and length byte
3652 pRsnIe = gen_ie + 2;
3653 RSNIeLen = gen_ie_len - 2;
3654 // Unpack the RSN IE
3655 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
3656 pRsnIe,
3657 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07003658 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003659 // Copy out the encryption and authentication types
3660 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003661 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003662 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003663 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003664 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07003665 but probably I suspect we can do something different*/
3666 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07003667 // Just translate the FIRST one
3668 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
3669 //dot11RSNIE.pwise_cipher_suite_count
3670 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
3671 //dot11RSNIE.gp_cipher_suite_count
3672 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07003673#ifdef WLAN_FEATURE_11W
3674 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
3675 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
3676#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003677 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07003678 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07003679 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003680 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07003681 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303682 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003683 break;
3684 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003685 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303687 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003688 break;
3689 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003690 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003691 // For right now, I assume setASSOCIATE() has passed in the bssid.
3692 vos_mem_copy(PMKIDCache[i].BSSID,
3693 pBssid, ETHER_ADDR_LEN);
3694 vos_mem_copy(PMKIDCache[i].PMKID,
3695 dot11RSNIE.pmkid[i],
3696 CSR_RSN_PMKID_SIZE);
3697 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07003698
3699 if (updatePMKCache)
3700 {
3701 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003702 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003703 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07003704 // Finally set the PMKSA ID Cache in CSR
3705 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
3706 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05303707 dot11RSNIE.pmkid_count,
3708 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07003709 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003710 }
3711 else if (gen_ie[0] == DOT11F_EID_WPA)
3712 {
3713 // Validity checks
3714 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
3715 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
3716 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05303717 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
3718 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07003719 return -EINVAL;
3720 }
3721 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07003722 pRsnIe = gen_ie + 2 + 4;
3723 RSNIeLen = gen_ie_len - (2 + 4);
3724 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07003725 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
3726 pRsnIe,
3727 RSNIeLen,
3728 &dot11WPAIE);
3729 // Copy out the encryption and authentication types
3730 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003731 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07003732 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003733 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07003734 //dot11WPAIE.auth_suite_count
3735 // Just translate the FIRST one
3736 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3737 //dot11WPAIE.unicast_cipher_count
3738 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3739 //dot11WPAIE.unicast_cipher_count
3740 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3741 }
3742 else
3743 {
3744 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003745 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003746 }
3747 return 0;
3748}
3749int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3750{
3751 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3752 v_U32_t status = 0;
3753 eCsrEncryptionType RSNEncryptType;
3754 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003755#ifdef WLAN_FEATURE_11W
3756 u_int8_t RSNMfpRequired;
3757 u_int8_t RSNMfpCapable;
3758#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003759 struct ether_addr bSsid; // MAC address of assoc peer
3760 // MAC address of assoc peer
3761 // But, this routine is only called when we are NOT associated.
3762 vos_mem_copy(bSsid.ether_addr_octet,
3763 pWextState->roamProfile.BSSIDs.bssid,
3764 sizeof(bSsid.ether_addr_octet));
3765 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3766 {
3767 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003768 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 else
3770 {
3771 return 0;
3772 }
3773 // The actual processing may eventually be more extensive than this.
3774 // Right now, just consume any PMKIDs that are sent in by the app.
3775 status = hdd_ProcessGENIE(pAdapter,
3776 &bSsid, // MAC address of assoc peer
3777 &RSNEncryptType,
3778 &mcRSNEncryptType,
3779 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003780#ifdef WLAN_FEATURE_11W
3781 &RSNMfpRequired,
3782 &RSNMfpCapable,
3783#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003784 pWextState->WPARSNIE[1]+2,
3785 pWextState->WPARSNIE);
3786 if (status == 0)
3787 {
3788 // Now copy over all the security attributes you have parsed out
3789 pWextState->roamProfile.EncryptionType.numEntries = 1;
3790 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003791
Jeff Johnson295189b2012-06-20 16:38:30 -07003792 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3793 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003794
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003795 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3796 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3797 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3798 {
3799 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3800 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3801 either AES/TKIP based on group cipher configuration
3802 mentioned in the wpa_supplicant.conf.*/
3803
3804 /*Set the unicast cipher same as multicast cipher*/
3805 pWextState->roamProfile.EncryptionType.encryptionType[0]
3806 = mcRSNEncryptType;
3807 }
3808
Chet Lanctot186b5732013-03-18 10:26:30 -07003809#ifdef WLAN_FEATURE_11W
3810 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3811 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3812#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003813 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003814 }
3815 return 0;
3816}
3817int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3818{
3819 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3820 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3821 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3822 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003823
Jeff Johnson295189b2012-06-20 16:38:30 -07003824 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003825 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003826
Jeff Johnson295189b2012-06-20 16:38:30 -07003827 switch( pHddStaCtx->conn_info.authType)
3828 {
3829 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003830#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07003831 case eCSR_AUTH_TYPE_CCKM_WPA:
3832 case eCSR_AUTH_TYPE_CCKM_RSN:
3833#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003834 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3835
Jeff Johnson295189b2012-06-20 16:38:30 -07003836 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003837 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003838 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003839
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003840#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003841 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3842 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3843 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003844 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003845 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3846 } else
3847 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003848 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003849 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003850 } else
3851#endif
3852 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3853 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003854 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3855 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003856 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3857 == IW_AUTH_KEY_MGMT_PSK) {
3858 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003859 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003860 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003861 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003862 }
3863 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003864#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07003865 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3866 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3867 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003868 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003869 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003870 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003871 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003872 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003873 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003874 } else
3875#endif
3876
3877#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003878 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3879 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003880 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003881 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003882 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003883 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003884 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3885 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003886 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003887 } else
3888#endif
3889
Chet Lanctot186b5732013-03-18 10:26:30 -07003890#ifdef WLAN_FEATURE_11W
3891 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3892 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3893 } else
Abhishek Singhae408032014-09-25 17:22:04 +05303894 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
3895 pRoamProfile->AuthType.authType[0] =
3896 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
3897 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07003898#endif
3899
Shailender Karmuchia734f332013-04-19 14:02:48 -07003900 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003901 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003902 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3903 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003904 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3905 == IW_AUTH_KEY_MGMT_PSK) {
3906 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003907 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003908 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003909 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003910 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003911 break;
3912
Jeff Johnson295189b2012-06-20 16:38:30 -07003913 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003914
3915 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003916 break;
3917 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003918
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003919#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08003920 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003921#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07003922 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3923 break;
3924 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003925
Jeff Johnson295189b2012-06-20 16:38:30 -07003926 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003927 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003928
Jeff Johnson295189b2012-06-20 16:38:30 -07003929 EXIT();
3930 return 0;
3931}
3932
3933/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003934
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303935 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003936 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07003937 to the CSR roam profile.
3938
Jeff Johnson295189b2012-06-20 16:38:30 -07003939 \param - dev - Pointer to the net device.
3940 - info - Pointer to the iw_request_info.
3941 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003942 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003943 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003944
Jeff Johnson295189b2012-06-20 16:38:30 -07003945 --------------------------------------------------------------------------*/
3946
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05303947int __iw_set_essid(struct net_device *dev,
3948 struct iw_request_info *info,
3949 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07003950{
3951 v_U32_t status = 0;
3952 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303953 hdd_adapter_t *pAdapter;
3954 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07003955 v_U32_t roamId;
3956 tCsrRoamProfile *pRoamProfile;
3957 eMib_dot11DesiredBssType connectedBssType;
3958 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303959 tHalHandle hHal;
3960 hdd_station_ctx_t *pHddStaCtx;
3961 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003962
Jeff Johnson295189b2012-06-20 16:38:30 -07003963 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303964 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3965 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07003966 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05303967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303968 "%s: Adapter is NULL",__func__);
3969 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003970 }
3971
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303972 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3973 ret = wlan_hdd_validate_context(pHddCtx);
3974 if (0 != ret)
3975 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05303976 return ret;
3977 }
3978
3979 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3980 if (NULL == hHal)
3981 {
3982 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3983 "%s: Hal Context is NULL",__func__);
3984 return -EINVAL;
3985 }
3986 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3987 if (NULL == pHddStaCtx)
3988 {
3989 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3990 "%s: STA Context is NULL",__func__);
3991 return -EINVAL;
3992 }
3993 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3994 if (NULL == pWextState)
3995 {
3996 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3997 "%s: pWextState is NULL",__func__);
3998 return -EINVAL;
3999 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004000 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
4001 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
4002 return -EBUSY;
4003 }
4004 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
4005 return -EINVAL;
4006 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004007 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07004008 {
4009 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
4010 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
4011 {
4012 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004013 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07004014 INIT_COMPLETION(pAdapter->disconnect_comp_var);
4015 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
4016
4017 if(VOS_STATUS_SUCCESS == vosStatus)
4018 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
4019 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
4020 }
4021 }
4022 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004023 else
Jeff Johnson295189b2012-06-20 16:38:30 -07004024 {
4025 return -EINVAL;
4026 }
4027 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004028 /** when cfg80211 defined, wpa_supplicant wext driver uses
4029 zero-length, null-string ssid for force disconnection.
4030 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07004031 driver MUST return success */
4032 if ( 0 == wrqu->essid.length ) {
4033 return 0;
4034 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004035
4036 status = hdd_wmm_get_uapsd_mask(pAdapter,
4037 &pWextState->roamProfile.uapsd_mask);
4038 if (VOS_STATUS_SUCCESS != status)
4039 {
4040 pWextState->roamProfile.uapsd_mask = 0;
4041 }
4042 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004043
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004045
4046 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07004047 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
4048 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
4049 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004050
Jeff Johnson295189b2012-06-20 16:38:30 -07004051 //set gen ie
4052 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
4053
4054 //set auth
4055 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
4056 }
4057#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004058 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 if (pAdapter->wapi_info.nWapiMode)
4060 {
4061 switch (pAdapter->wapi_info.wapiAuthMode)
4062 {
4063 case WAPI_AUTH_MODE_PSK:
4064 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004065 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004066 pRoamProfile->AuthType.numEntries = 1;
4067 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
4068 break;
4069 }
4070 case WAPI_AUTH_MODE_CERT:
4071 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004072 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07004073 pRoamProfile->AuthType.numEntries = 1;
4074 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
4075 break;
4076 }
4077 } // End of switch
4078 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
4079 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
4080 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004081 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004082 pRoamProfile->EncryptionType.numEntries = 1;
4083 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4084 pRoamProfile->mcEncryptionType.numEntries = 1;
4085 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
4086 }
4087 }
4088#endif /* FEATURE_WLAN_WAPI */
4089 /* if previous genIE is not NULL, update AssocIE */
4090 if (0 != pWextState->genIE.length)
4091 {
4092 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
4093 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
4094 pWextState->genIE.length);
4095 pWextState->assocAddIE.length = pWextState->genIE.length;
4096 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
4097 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
4098
4099 /* clear previous genIE after use it */
4100 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
4101 }
4102
4103 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
4104 pWextState->roamProfile.bWPSAssociation = FALSE;
4105
4106 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
4107 pWextState->roamProfile.nAddIEAssocLength))
4108 pWextState->roamProfile.bWPSAssociation = TRUE;
4109
4110
4111 // Disable auto BMPS entry by PMC until DHCP is done
4112 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
4113
Shailender Karmuchia734f332013-04-19 14:02:48 -07004114 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07004115 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004116
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004117 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
4118 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004119 hdd_select_cbmode(pAdapter,
4120 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
4121 }
4122 status = sme_RoamConnect( hHal,pAdapter->sessionId,
4123 &(pWextState->roamProfile), &roamId);
4124 pRoamProfile->ChannelInfo.ChannelList = NULL;
4125 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004126
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07004127 EXIT();
4128 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004129}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07004130
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304131int iw_set_essid(struct net_device *dev,
4132 struct iw_request_info *info,
4133 union iwreq_data *wrqu, char *extra)
4134{
4135 int ret;
4136
4137 vos_ssr_protect(__func__);
4138 ret = __iw_set_essid(dev, info, wrqu, extra);
4139 vos_ssr_unprotect(__func__);
4140
4141 return ret;
4142}
4143
Jeff Johnson295189b2012-06-20 16:38:30 -07004144/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004145
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304146 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004147 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004148
Jeff Johnson295189b2012-06-20 16:38:30 -07004149 \param - dev - Pointer to the net device.
4150 - info - Pointer to the iw_request_info.
4151 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004152 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004153 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004154
Jeff Johnson295189b2012-06-20 16:38:30 -07004155 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304156int __iw_get_essid(struct net_device *dev,
4157 struct iw_request_info *info,
4158 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004159{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304160 hdd_adapter_t *pAdapter;
4161 hdd_context_t *pHddCtx;
4162 hdd_wext_state_t *wextBuf;
4163 hdd_station_ctx_t *pHddStaCtx;
4164 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304165
Jeff Johnson295189b2012-06-20 16:38:30 -07004166 ENTER();
4167
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304168 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4169 if (NULL == pAdapter)
4170 {
4171 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4172 "%s: Adapter is NULL",__func__);
4173 return -EINVAL;
4174 }
4175
4176 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4177 ret = wlan_hdd_validate_context(pHddCtx);
4178 if (0 != ret)
4179 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304180 return ret;
4181 }
4182
4183 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4184 if (NULL == pHddStaCtx)
4185 {
4186 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4187 "%s: STA Context is NULL",__func__);
4188 return -EINVAL;
4189 }
4190
4191 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4192 if (NULL == wextBuf)
4193 {
4194 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4195 "%s: wextBuf is NULL",__func__);
4196 return -EINVAL;
4197 }
4198
Jeff Johnson295189b2012-06-20 16:38:30 -07004199 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
4200 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
4201 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
4202 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
4203 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
4204 {
4205 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
4206 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
4207 dwrq->flags = 1;
4208 } else {
4209 memset(extra, 0, dwrq->length);
4210 dwrq->length = 0;
4211 dwrq->flags = 0;
4212 }
4213 EXIT();
4214 return 0;
4215}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304216
4217int iw_get_essid(struct net_device *dev,
4218 struct iw_request_info *info,
4219 struct iw_point *dwrq, char *extra)
4220{
4221 int ret;
4222
4223 vos_ssr_protect(__func__);
4224 ret = __iw_get_essid(dev, info, dwrq, extra);
4225 vos_ssr_unprotect(__func__);
4226
4227 return ret;
4228}
Jeff Johnson295189b2012-06-20 16:38:30 -07004229/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004230
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304231 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004232 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004233
Jeff Johnson295189b2012-06-20 16:38:30 -07004234 \param - dev - Pointer to the net device.
4235 - info - Pointer to the iw_request_info.
4236 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004237 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004238 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004239
Jeff Johnson295189b2012-06-20 16:38:30 -07004240 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304241int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
4242 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004243{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304244 hdd_adapter_t *pAdapter;
4245 hdd_context_t *pHddCtx;
4246 hdd_wext_state_t *pWextState;
4247 hdd_station_ctx_t *pHddStaCtx;
4248 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004249 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07004250 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304251 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004252
Jeff Johnson295189b2012-06-20 16:38:30 -07004253 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004254
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304255 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4256 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004257 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4259 "%s: Adapter is NULL",__func__);
4260 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004261 }
4262
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304263 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4264 ret = wlan_hdd_validate_context(pHddCtx);
4265 if (0 != ret)
4266 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304267 return ret;
4268 }
4269
4270 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4271 if (NULL == pHddStaCtx)
4272 {
4273 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4274 "%s: STA Context is NULL",__func__);
4275 return -EINVAL;
4276 }
4277
4278 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4279 if (NULL == pWextState)
4280 {
4281 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4282 "%s: pWextState is NULL",__func__);
4283 return -EINVAL;
4284 }
4285
4286 pRoamProfile = &pWextState->roamProfile;
4287
Jeff Johnson295189b2012-06-20 16:38:30 -07004288 switch(wrqu->param.flags & IW_AUTH_INDEX)
4289 {
4290 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004291
Jeff Johnson295189b2012-06-20 16:38:30 -07004292 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004293
Jeff Johnson295189b2012-06-20 16:38:30 -07004294 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004295
Jeff Johnson295189b2012-06-20 16:38:30 -07004296 case IW_AUTH_CIPHER_PAIRWISE:
4297 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004298 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004299 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004300 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004301 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4302 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004303 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004304 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
4305 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004306 }
4307
Jeff Johnson295189b2012-06-20 16:38:30 -07004308 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004309
4310 if( (IW_AUTH_KEY_MGMT_802_1X
4311 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004312 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
4313 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004314 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07004315 else
4316 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004317 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
4318 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004319 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004320
4321 if( ( IW_AUTH_KEY_MGMT_802_1X
4322 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07004323 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4324 /*Dynamic WEP key*/
4325 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4326 else
4327 /*Static WEP key*/
4328 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004329
Jeff Johnson295189b2012-06-20 16:38:30 -07004330 }
4331 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004332
Jeff Johnson295189b2012-06-20 16:38:30 -07004333 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004334 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004335 return -EINVAL;
4336 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004337
Jeff Johnson295189b2012-06-20 16:38:30 -07004338 pRoamProfile->EncryptionType.numEntries = 1;
4339 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004340 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004341 break;
4342 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004343 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004344 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
4345 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
4346 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004347
Jeff Johnson295189b2012-06-20 16:38:30 -07004348 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
4349 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
4350 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004351
4352 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07004353 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
4354 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004355
Jeff Johnson295189b2012-06-20 16:38:30 -07004356 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004357
4358 if( ( IW_AUTH_KEY_MGMT_802_1X
4359 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
4360 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4361
Jeff Johnson295189b2012-06-20 16:38:30 -07004362 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004363
4364 else
4365 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004366 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004367
4368 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
4369 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004370 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004371 if( ( IW_AUTH_KEY_MGMT_802_1X
4372 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07004373 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
4374 {
4375 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
4376 }
4377 else
4378 {
4379 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4380 }
4381 }
4382 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004383
Jeff Johnson295189b2012-06-20 16:38:30 -07004384 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07004385 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 return -EINVAL;
4387 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004388
Jeff Johnson295189b2012-06-20 16:38:30 -07004389 pRoamProfile->mcEncryptionType.numEntries = 1;
4390 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
4391 }
4392 break;
4393
4394 case IW_AUTH_80211_AUTH_ALG:
4395 {
4396 /*Save the auth algo here and set auth type to SME Roam profile
4397 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07004398 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07004399 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004400
Jeff Johnson295189b2012-06-20 16:38:30 -07004401 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
4402 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
4403
4404 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
4405 /*Not supported*/
4406 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
4407 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
4408 }
4409 break;
4410
4411 case IW_AUTH_KEY_MGMT:
4412 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004413#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004414#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
4415 /*Check for CCKM AKM type */
4416 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004417 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
4418 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004419 /* Set the CCKM bit in authKeyMgmt */
4420 /* Right now, this breaks all ref to authKeyMgmt because our
4421 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07004422 */
4423 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
4424 /*Set the key management to 802.1X*/
4425 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004426 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004427 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4428 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
4429 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
4430 /*Save the key management*/
4431 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
4432 //pWextState->authKeyMgmt = wrqu->param.value;
4433 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4434 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4435 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
4436 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
4437 /*Save the key management anyway*/
4438 pWextState->authKeyMgmt = wrqu->param.value;
4439 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
4440 /*Save the key management*/
4441 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
4442 //pWextState->authKeyMgmt = wrqu->param.value;
4443 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
4444 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
4445 }
4446#else
4447 /*Save the key management*/
4448 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004449#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004450 }
4451 break;
4452
4453 case IW_AUTH_TKIP_COUNTERMEASURES:
4454 {
4455 if(wrqu->param.value) {
4456 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4457 "Counter Measure started %d", wrqu->param.value);
4458 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
4459 }
4460 else {
4461 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
4462 "Counter Measure stopped=%d", wrqu->param.value);
4463 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
4464 }
4465 }
4466 break;
4467 case IW_AUTH_DROP_UNENCRYPTED:
4468 case IW_AUTH_WPA_ENABLED:
4469 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
4470 case IW_AUTH_ROAMING_CONTROL:
4471 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004472
Jeff Johnson295189b2012-06-20 16:38:30 -07004473 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004474
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004475 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 wrqu->param.flags & IW_AUTH_INDEX);
4477 break;
4478 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004479
Jeff Johnson295189b2012-06-20 16:38:30 -07004480 EXIT();
4481 return 0;
4482}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304483
4484int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
4485 union iwreq_data *wrqu, char *extra)
4486{
4487 int ret;
4488
4489 vos_ssr_protect(__func__);
4490 ret = __iw_set_auth(dev, info, wrqu, extra);
4491 vos_ssr_unprotect(__func__);
4492
4493 return ret;
4494}
4495
Jeff Johnson295189b2012-06-20 16:38:30 -07004496/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004497
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304498 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004499 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004500
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 \param - dev - Pointer to the net device.
4502 - info - Pointer to the iw_request_info.
4503 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004504 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004506
Jeff Johnson295189b2012-06-20 16:38:30 -07004507 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304508int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4509 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004510{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304511 hdd_adapter_t* pAdapter;
4512 hdd_wext_state_t *pWextState;
4513 tCsrRoamProfile *pRoamProfile;
4514 hdd_context_t *pHddCtx;
4515 int ret = 0;
4516
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004518
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304519 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4520 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004521 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304522 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4523 "%s: Adapter is NULL",__func__);
4524 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08004525 }
4526
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304527 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4528 ret = wlan_hdd_validate_context(pHddCtx);
4529 if (0 != ret)
4530 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304531 return ret;
4532 }
4533
4534 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4535 if (NULL == pWextState)
4536 {
4537 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4538 "%s: pWextState is NULL",__func__);
4539 return -EINVAL;
4540 }
4541 pRoamProfile = &pWextState->roamProfile;
4542
Jeff Johnson295189b2012-06-20 16:38:30 -07004543 switch(pRoamProfile->negotiatedAuthType)
4544 {
4545 case eCSR_AUTH_TYPE_WPA_NONE:
4546 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4547 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
4548 break;
4549 case eCSR_AUTH_TYPE_WPA:
4550 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4551 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
4552 break;
4553#ifdef WLAN_FEATURE_VOWIFI_11R
4554 case eCSR_AUTH_TYPE_FT_RSN:
4555#endif
4556 case eCSR_AUTH_TYPE_RSN:
4557 wrqu->param.flags = IW_AUTH_WPA_VERSION;
4558 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
4559 break;
4560 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
4561 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4562 break;
4563 case eCSR_AUTH_TYPE_SHARED_KEY:
4564 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
4565 break;
4566 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004567 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004568 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4569 break;
4570 case eCSR_AUTH_TYPE_AUTOSWITCH:
4571 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4572 break;
4573 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304574 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004575 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4576 return -EIO;
4577#ifdef WLAN_FEATURE_VOWIFI_11R
4578 case eCSR_AUTH_TYPE_FT_RSN_PSK:
4579#endif
4580 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07004581#ifdef WLAN_FEATURE_11W
4582 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05304583 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07004584#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05304585 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004586 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4587 return -EIO;
4588 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304589 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
4591 return -EIO;
4592 }
4593 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
4594 {
4595 switch(pRoamProfile->negotiatedUCEncryptionType)
4596 {
4597 case eCSR_ENCRYPT_TYPE_NONE:
4598 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4599 break;
4600 case eCSR_ENCRYPT_TYPE_WEP40:
4601 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4602 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4603 break;
4604 case eCSR_ENCRYPT_TYPE_TKIP:
4605 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4606 break;
4607 case eCSR_ENCRYPT_TYPE_WEP104:
4608 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4609 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4610 break;
4611 case eCSR_ENCRYPT_TYPE_AES:
4612 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4613 break;
4614 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304615 hddLog(LOG1, "%s called with unknown auth type %d ",
4616 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004617 return -EIO;
4618 }
4619 }
4620
Shailender Karmuchia734f332013-04-19 14:02:48 -07004621 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07004622 {
4623 switch(pRoamProfile->negotiatedMCEncryptionType)
4624 {
4625 case eCSR_ENCRYPT_TYPE_NONE:
4626 wrqu->param.value = IW_AUTH_CIPHER_NONE;
4627 break;
4628 case eCSR_ENCRYPT_TYPE_WEP40:
4629 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
4630 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
4631 break;
4632 case eCSR_ENCRYPT_TYPE_TKIP:
4633 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
4634 break;
4635 case eCSR_ENCRYPT_TYPE_WEP104:
4636 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
4637 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
4638 break;
4639 case eCSR_ENCRYPT_TYPE_AES:
4640 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
4641 break;
4642 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05304643 hddLog(LOG1, "%s called with unknown auth type %d ",
4644 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07004645 return -EIO;
4646 }
4647 }
4648
4649 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004650 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07004651 EXIT();
4652 return 0;
4653}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304654
4655int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
4656 union iwreq_data *wrqu,char *extra)
4657{
4658 int ret;
4659
4660 vos_ssr_protect(__func__);
4661 ret = __iw_get_auth(dev, info, wrqu, extra);
4662 vos_ssr_unprotect(__func__);
4663
4664 return ret;
4665}
4666
Jeff Johnson295189b2012-06-20 16:38:30 -07004667/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004668
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304669 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07004670 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07004671 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004672
Jeff Johnson295189b2012-06-20 16:38:30 -07004673 \param - dev - Pointer to the net device.
4674 - info - Pointer to the iw_request_info.
4675 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004676 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004677 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004678
Jeff Johnson295189b2012-06-20 16:38:30 -07004679 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304680int __iw_set_ap_address(struct net_device *dev,
4681 struct iw_request_info *info,
4682 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004683{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304684 hdd_station_ctx_t *pHddStaCtx;
4685 hdd_adapter_t *pAdapter;
4686 hdd_context_t *pHddCtx;
4687 v_U8_t *pMacAddress = NULL;
4688 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304689
Jeff Johnson295189b2012-06-20 16:38:30 -07004690 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304691
4692 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4693 if (NULL == pAdapter)
4694 {
4695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4696 "%s: Adapter is NULL", __func__);
4697 return -EINVAL;
4698 }
4699 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4700 ret = wlan_hdd_validate_context(pHddCtx);
4701 if (0 != ret)
4702 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304703 return ret;
4704 }
4705 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4706 if (NULL == pHddStaCtx)
4707 {
4708 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4709 "%s: pHddStaCtx is NULL", __func__);
4710 return -EINVAL;
4711 }
4712
Jeff Johnson295189b2012-06-20 16:38:30 -07004713 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08004714 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
4715 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07004716 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07004717
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304718 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07004719 return 0;
4720}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304721
4722int iw_set_ap_address(struct net_device *dev,
4723 struct iw_request_info *info,
4724 union iwreq_data *wrqu, char *extra)
4725{
4726 int ret;
4727
4728 vos_ssr_protect(__func__);
4729 ret = __iw_set_ap_address(dev, info, wrqu, extra);
4730 vos_ssr_unprotect(__func__);
4731
4732 return ret;
4733}
4734
Jeff Johnson295189b2012-06-20 16:38:30 -07004735/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004736
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304737 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004738 This function returns the BSSID to the wpa_supplicant
4739 \param - dev - Pointer to the net device.
4740 - info - Pointer to the iw_request_info.
4741 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004742 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004743 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004744
Jeff Johnson295189b2012-06-20 16:38:30 -07004745 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304746int __iw_get_ap_address(struct net_device *dev,
4747 struct iw_request_info *info,
4748 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004749{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304750 hdd_station_ctx_t *pHddStaCtx;
4751 hdd_adapter_t *pAdapter;
4752 hdd_context_t *pHddCtx;
4753 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05304754
Jeff Johnson295189b2012-06-20 16:38:30 -07004755 ENTER();
4756
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304757 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4758 if (NULL == pAdapter)
4759 {
4760 hddLog(VOS_TRACE_LEVEL_ERROR,
4761 "%s: Adapter is NULL", __func__);
4762 return -EINVAL;
4763 }
4764 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4765 ret = wlan_hdd_validate_context(pHddCtx);
4766 if (0 != ret)
4767 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304768 return ret;
4769 }
4770 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4771 if (NULL == pHddStaCtx)
4772 {
4773 hddLog(VOS_TRACE_LEVEL_ERROR,
4774 "%s: pHddStaCtx is NULL", __func__);
4775 return -EINVAL;
4776 }
4777
Jeff Johnson295189b2012-06-20 16:38:30 -07004778 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
4779 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
4780 {
Jeff Johnson4416a782013-03-25 14:17:50 -07004781 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07004782 }
4783 else
4784 {
4785 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
4786 }
4787 EXIT();
4788 return 0;
4789}
Jeff Johnsond13512a2012-07-17 11:42:19 -07004790
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304791int iw_get_ap_address(struct net_device *dev,
4792 struct iw_request_info *info,
4793 union iwreq_data *wrqu, char *extra)
4794{
4795 int ret;
4796
4797 vos_ssr_protect(__func__);
4798 ret = __iw_get_ap_address(dev, info, wrqu, extra);
4799 vos_ssr_unprotect(__func__);
4800
4801 return ret;
4802}
4803
Chet Lanctot186b5732013-03-18 10:26:30 -07004804#ifdef WLAN_FEATURE_11W
4805/**---------------------------------------------------------------------------
4806
4807 \brief hdd_indicateUnprotMgmtFrame -
4808 This function forwards the unprotected management frame to the supplicant
4809 \param - pAdapter - Pointer to HDD adapter
4810 - nFrameLength - Length of the unprotected frame being passed
4811 - pbFrames - Pointer to the frame buffer
4812 - frameType - 802.11 frame type
4813 \return - nothing
4814
4815 --------------------------------------------------------------------------*/
4816void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
4817 tANI_U32 nFrameLength,
4818 tANI_U8* pbFrames,
4819 tANI_U8 frameType )
4820{
4821 tANI_U8 type = 0;
4822 tANI_U8 subType = 0;
4823
4824 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
4825 __func__, frameType, nFrameLength);
4826
4827 /* Sanity Checks */
4828 if (NULL == pAdapter)
4829 {
4830 hddLog( LOGE, FL("pAdapter is NULL"));
4831 return;
4832 }
4833
4834 if (NULL == pAdapter->dev)
4835 {
4836 hddLog( LOGE, FL("pAdapter->dev is NULL"));
4837 return;
4838 }
4839
4840 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
4841 {
4842 hddLog( LOGE, FL("pAdapter has invalid magic"));
4843 return;
4844 }
4845
4846 if( !nFrameLength )
4847 {
4848 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
4849 return;
4850 }
4851
4852 if (NULL == pbFrames) {
4853 hddLog( LOGE, FL("pbFrames is NULL"));
4854 return;
4855 }
4856
4857 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
4858 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
4859
4860 /* Get pAdapter from Destination mac address of the frame */
4861 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
4862 {
4863 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
4864 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
4865 }
4866 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
4867 {
4868 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
4869 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
4870 }
4871 else
4872 {
4873 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
4874 return;
4875 }
4876}
4877#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004878
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004879#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004880void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
4881 tANI_U8 state,
4882 tANI_U16 measInterval )
4883{
4884 union iwreq_data wrqu;
4885 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004886 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004887
4888 if (NULL == pAdapter)
4889 return;
4890
4891 // create the event
4892 memset(&wrqu, '\0', sizeof(wrqu));
4893 memset(buf, '\0', sizeof(buf));
4894
4895 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
4896 tid, state, measInterval);
4897
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004898 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004899
4900 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004901 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004902 // send the event
4903 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4904}
4905
4906void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
4907{
4908 union iwreq_data wrqu;
4909 char buf[IW_CUSTOM_MAX + 1];
4910 char *pos = buf;
4911 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4912
4913 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4914 return;
4915
4916 // create the event
4917 memset(&wrqu, '\0', sizeof(wrqu));
4918 memset(buf, '\0', sizeof(buf));
4919
4920 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05304921 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
4922 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
4923 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
4924 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004925
4926 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
4927 pos += nBytes;
4928 freeBytes -= nBytes;
4929
4930 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
4931 pos += WNI_CFG_BSSID_LEN;
4932 freeBytes -= WNI_CFG_BSSID_LEN;
4933
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004934 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
4935 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004936
4937 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004938 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004939
4940 // send the event
4941 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4942}
4943
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004944void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004945{
4946 union iwreq_data wrqu;
4947 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004948 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004949
4950 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4951 return;
4952
4953 // create the event
4954 memset(&wrqu, '\0', sizeof(wrqu));
4955 memset(buf, '\0', sizeof(buf));
4956
4957 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
4958
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004959 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004960
4961 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004962 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004963
4964 // send the event
4965 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4966}
4967
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07004968void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
4969 const tANI_U16 measurementToken,
4970 const tANI_BOOLEAN flag,
4971 const tANI_U8 numBss)
4972{
4973 union iwreq_data wrqu;
4974 char buf[IW_CUSTOM_MAX];
4975 char *pos = buf;
4976 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
4977
4978 memset(&wrqu, '\0', sizeof(wrqu));
4979 memset(buf, '\0', sizeof(buf));
4980
4981 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
4982 numBss);
4983
4984 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
4985 flag, numBss);
4986
4987 wrqu.data.pointer = buf;
4988 wrqu.data.length = nBytes;
4989 // send the event
4990 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4991}
4992
4993
4994static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004995 const tCsrRoamInfo *pRoamInfo)
4996{
4997 union iwreq_data wrqu;
4998 char buf[IW_CUSTOM_MAX + 1];
4999 char *pos = buf;
5000 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5001 tANI_U8 i = 0, len = 0;
5002 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
5003 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005004 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
5005 tANI_U8 ieLenByte = 1;
5006 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
5007#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005008
5009 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5010 return;
5011
5012 /* Custom event can pass maximum of 256 bytes of data,
5013 based on the IE len we need to identify how many BSS info can
5014 be filled in to custom event data */
5015 /*
5016 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
5017 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
5018 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
5019 */
5020
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005021 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005022 {
5023 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
5024 /* If the measurement is none and no scan results found,
5025 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07005026 hdd_indicateEseBcnReportNoResults(pAdapter,
5027 pRoamInfo->pEseBcnReportRsp->measurementToken,
5028 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005029 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005030 }
5031 else
5032 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005033 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005034 {
5035 memset(&wrqu, '\0', sizeof(wrqu));
5036 memset(buf, '\0', sizeof(buf));
5037 tot_bcn_ieLen = 0;
5038 sendBss = 0;
5039 pos = buf;
5040 freeBytes = IW_CUSTOM_MAX;
5041
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005042 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005043 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005044 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
5045 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005046 {
5047 break;
5048 }
5049 tot_bcn_ieLen += len;
5050 sendBss++;
5051 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
5052 "IeLength(%d) Length of Ie(%d) totLen(%d)",
5053 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005054 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005055 tot_bcn_ieLen);
5056 }
5057
5058 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
5059 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005060 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5061 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005062
5063 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005064 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
5065 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005066 pos += nBytes;
5067 freeBytes -= nBytes;
5068
5069 /* Copy total Beacon report data length */
5070 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
5071 pos += sizeof(tot_bcn_ieLen);
5072 freeBytes -= sizeof(tot_bcn_ieLen);
5073
5074 for (i = 0; i < sendBss; i++)
5075 {
5076 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305077 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
5078 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005079 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005080 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
5081 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
5082 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
5083 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
5084 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
5085 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
5086 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
5087 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
5088 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
5089 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
5090 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
5091 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
5092 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
5093 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
5094 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
5095 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005096
5097 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005098 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
5099 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005100 pos += len;
5101 freeBytes -= len;
5102
5103 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005104 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005105 vos_mem_copy(pos, (char*)&len, sizeof(len));
5106 pos += sizeof(len);
5107 freeBytes -= sizeof(len);
5108
5109 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005110 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08005111 pos += len;
5112 freeBytes -= len;
5113 }
5114
5115 wrqu.data.pointer = buf;
5116 wrqu.data.length = strlen(buf);
5117
5118 // send the event
5119 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5120 lastSent += sendBss;
5121 }
5122 }
5123}
5124
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005125#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005126