blob: 03e72feb4531c938ca298865058922fd61cc7417 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Gopichand Nakkala92f07d82013-01-08 21:16:34 -08002 * Copyright (c) 2012-2013, The Linux Foundation. All rights reserved.
3 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
20 */
21/*
Jeff Johnson32d95a32012-09-10 13:15:23 -070022 * Copyright (c) 2012, The Linux Foundation. All rights reserved.
Jeff Johnson295189b2012-06-20 16:38:30 -070023 *
24 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
25 *
26 *
27 * Permission to use, copy, modify, and/or distribute this software for
28 * any purpose with or without fee is hereby granted, provided that the
29 * above copyright notice and this permission notice appear in all
30 * copies.
31 *
32 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
33 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
34 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
35 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
36 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
37 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
38 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
39 * PERFORMANCE OF THIS SOFTWARE.
40 */
41
Shailender Karmuchia734f332013-04-19 14:02:48 -070042
Jeff Johnson295189b2012-06-20 16:38:30 -070043/**========================================================================
44
45 \file wlan_hdd_assoc.c
46 \brief WLAN Host Device Driver implementation
Shailender Karmuchia734f332013-04-19 14:02:48 -070047
Jeff Johnson295189b2012-06-20 16:38:30 -070048 ========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070049/**=========================================================================
50 EDIT HISTORY FOR FILE
51
52
53 This section contains comments describing changes made to the module.
54 Notice that changes are listed in reverse chronological order.
55
56
57 $Header:$ $DateTime: $ $Author: $
58
59
60 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070061 -------- --- --------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -070062 05/06/09 Shailender Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070063 ==========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070064
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "wlan_hdd_includes.h"
66#include <aniGlobal.h>
67#include "dot11f.h"
68#include "wlan_nlink_common.h"
69#include "wlan_btc_svc.h"
70#include "wlan_hdd_power.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070071#include <linux/ieee80211.h>
72#include <linux/wireless.h>
73#include <net/cfg80211.h>
74#include "wlan_hdd_cfg80211.h"
75#include "csrInsideApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070076#include "wlan_hdd_p2p.h"
Mohit Khanna698ba2a2012-12-04 15:08:18 -080077#ifdef FEATURE_WLAN_TDLS
78#include "wlan_hdd_tdls.h"
79#endif
Jeff Johnson295189b2012-06-20 16:38:30 -070080#include "sme_Api.h"
81
82v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
83
Shailender Karmuchia734f332013-04-19 14:02:48 -070084struct ether_addr
Jeff Johnson295189b2012-06-20 16:38:30 -070085{
86 u_char ether_addr_octet[6];
87};
88// These are needed to recognize WPA and RSN suite types
89#define HDD_WPA_OUI_SIZE 4
90v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
91v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
92v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
93v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
94v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
95v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
96#ifdef FEATURE_WLAN_CCX
97v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
98#endif /* FEATURE_WLAN_CCX */
99#define HDD_RSN_OUI_SIZE 4
100v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
101v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
102v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
103v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
104v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
105v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
106#ifdef FEATURE_WLAN_CCX
107v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
108#endif /* FEATURE_WLAN_CCX */
Chet Lanctot186b5732013-03-18 10:26:30 -0700109#ifdef WLAN_FEATURE_11W
110v_U8_t ccpRSNOui07[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x06 }; // RSN-PSK-SHA256
111#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700112
Shailender Karmuchia734f332013-04-19 14:02:48 -0700113#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700114// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700115#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
116#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700117#endif
118
119#define BEACON_FRAME_IES_OFFSET 12
120
Chet Lanctot186b5732013-03-18 10:26:30 -0700121#ifdef WLAN_FEATURE_11W
122void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
123 tANI_U32 nFrameLength,
124 tANI_U8* pbFrames,
125 tANI_U8 frameType );
126#endif
127
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700128#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
129static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
130 tANI_U8 state,
131 tANI_U16 measInterval );
132static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
133static void hdd_indicateCcxAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -0800134static void hdd_indicateCcxBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700135
136#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
137
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530138static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
139 tCsrRoamInfo *pRoamInfo,
140 tANI_U32 roamId,
141 eRoamCmdStatus roamStatus,
142 eCsrRoamResult roamResult );
143
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530144v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
145 eConnectionState connState )
146{
147 // save the new connection state
Jeff Johnson295189b2012-06-20 16:38:30 -0700148 pHddStaCtx->conn_info.connState = connState;
149}
150
151// returns FALSE if not connected.
152// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
153// returns the connection state. Can specify NULL if you dont' want to get the actual state.
154
Shailender Karmuchia734f332013-04-19 14:02:48 -0700155static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
156 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700157{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700158 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700159 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700160
Jeff Johnson295189b2012-06-20 16:38:30 -0700161 // get the connection state.
162 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700163 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700164 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700165 eConnectionState_IbssConnected == connState ||
166 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700167 {
168 fConnected = VOS_TRUE;
169 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700170 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700171 {
172 fConnected = VOS_FALSE;
173 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700174
Jeff Johnson295189b2012-06-20 16:38:30 -0700175 if ( pConnState )
176 {
177 *pConnState = connState;
178 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700179
Jeff Johnson295189b2012-06-20 16:38:30 -0700180 return( fConnected );
181}
182
183v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
184{
185 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700186}
Jeff Johnson295189b2012-06-20 16:38:30 -0700187
188//TODO - Not used anyhwere. Can be removed.
189#if 0
190//
191v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
192{
193 v_BOOL_t fConnectedInfra = FALSE;
194 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700195
Jeff Johnson295189b2012-06-20 16:38:30 -0700196 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700197 {
198 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700199 {
200 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700201 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700202 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700203
Jeff Johnson295189b2012-06-20 16:38:30 -0700204 return( fConnectedInfra );
205}
206#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700207
Jeff Johnson295189b2012-06-20 16:38:30 -0700208static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
209{
210 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700211
Jeff Johnson295189b2012-06-20 16:38:30 -0700212 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700213
214 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700215 {
216 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
217 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700218
Jeff Johnson295189b2012-06-20 16:38:30 -0700219 return( fConnected );
220}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700221
Jeff Johnson295189b2012-06-20 16:38:30 -0700222inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
223{
224 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700225
Jeff Johnson295189b2012-06-20 16:38:30 -0700226 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700227
228 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700229 {
230 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
231 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700232
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 return( fConnected );
234}
235
236static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
237{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700238 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700239 {
240 case eCSR_BSS_TYPE_INFRASTRUCTURE:
241 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
242 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700243
Jeff Johnson295189b2012-06-20 16:38:30 -0700244 case eCSR_BSS_TYPE_IBSS:
245 case eCSR_BSS_TYPE_START_IBSS:
246 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
247 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700248
249 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700250 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700251 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700252 default:
253 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700254 break;
255 }
256
Jeff Johnson295189b2012-06-20 16:38:30 -0700257}
258
259void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
260{
261 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
262 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700263
Jeff Johnson295189b2012-06-20 16:38:30 -0700264 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700265
266 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700267 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700268 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700269 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
270 {
271 VOS_ASSERT( pRoamInfo->pBssDesc );
272 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
273
274 // Save the Station ID for this station from the 'Roam Info'.
275 //For IBSS mode, staId is assigned in NEW_PEER_IND
276 //For reassoc, the staID doesn't change and it may be invalid in this structure
277 //so no change here.
278 if( !pRoamInfo->fReassocReq )
279 {
280 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
281 }
282 }
283 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700284 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700285 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700286 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700287 else
288 {
289 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
290 // or we can't function.
291 VOS_ASSERT( 0 );
292 }
293
294 // notify WMM
295 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
296
297 if( !pRoamInfo->u.pConnectedProfile )
298 {
299 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
300 }
301 else
302 {
303 // Get Multicast Encryption Type
304 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
305 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
306 // Get Unicast Encrytion Type
307 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
308 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
309
310 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
311
312 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
313
314 // Save the ssid for the connection
315 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530316
317 // Save dot11mode in which STA associated to AP
318 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700319 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700320 }
321
Jeff Johnson295189b2012-06-20 16:38:30 -0700322 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700323 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
324
Jeff Johnson295189b2012-06-20 16:38:30 -0700325}
326
327#if defined(WLAN_FEATURE_VOWIFI_11R)
328/*
329 * Send the 11R key information to the supplicant.
330 * Only then can the supplicant generate the PMK-R1.
331 * (BTW, the CCX supplicant also needs the Assoc Resp IEs
332 * for the same purpose.)
333 *
334 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
335 * this contains the R1KHID, R0KHID and the MDID.
336 * For FT, this consists of the Reassoc Rsp FTIEs.
337 * This is the Assoc Response.
338 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700339static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700340 tCsrRoamInfo *pCsrRoamInfo)
341{
342 union iwreq_data wrqu;
343 char *buff;
344 unsigned int len = 0;
345 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700346
347 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700348 {
349 hddLog(LOGE,
350 "%s: pCsrRoamInfo->nAssocRspLength=%d",
351 __func__, (int)pCsrRoamInfo->nAssocRspLength);
352 return;
353 }
354
Shailender Karmuchia734f332013-04-19 14:02:48 -0700355 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700356 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700357 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700358 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700359 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700360 return;
361 }
362
363 // pFTAssocRsp needs to point to the IEs
364 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
365 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
366 (unsigned int)pFTAssocRsp[0],
367 (unsigned int)pFTAssocRsp[1]);
368
369 // We need to send the IEs to the supplicant.
370 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700371 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700373 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700374 return;
375 }
376
377 // Send the Assoc Resp, the supplicant needs this for initial Auth.
378 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700379 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700380 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700381 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700382 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
383
384 kfree(buff);
385}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700386#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700387
388#ifdef WLAN_FEATURE_VOWIFI_11R
389
390/*---------------------------------------------------
391 *
392 * Send the FTIEs, RIC IEs during FT. This is eventually
393 * used to send the FT events to the supplicant
394 *
395 * At the reception of Auth2 we send the RIC followed
396 * by the auth response IEs to the supplicant.
397 * Once both are received in the supplicant, an FT
398 * event is generated to the supplicant.
399 *
400 *---------------------------------------------------
401 */
402void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
403{
Jeff Johnson295189b2012-06-20 16:38:30 -0700404 tANI_U16 auth_resp_len = 0;
405 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700406 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
407
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530408#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700409 struct cfg80211_ft_event_params ftEvent;
410 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
411 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
412 struct net_device *dev = pAdapter->dev;
413#else
414 char *buff;
415 union iwreq_data wrqu;
416 tANI_U16 str_len;
417#endif
418
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530419#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530420 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
421 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700422
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530423 sme_GetRICIEs( pHddCtx->hHal, (u8 *)ricIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800424 DOT11F_IE_FTINFO_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530425 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700426 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530427 hddLog(LOGW,
428 "%s: RIC IEs is of length 0 not sending RIC Information for now",
429 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700430 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700431
432 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530433 ftEvent.ric_ies_len = ric_ies_length;
434 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700435
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530436 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800437 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700438
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530439 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700440 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530441 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700442 return;
443 }
444
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530445 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530446
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530447 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700448
449 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
450 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
451
Jeff Johnson59a121e2013-11-30 09:46:08 -0800452 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
453 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
454 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530455 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800456 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
457 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
458 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700459
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530460 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700461
462#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530463 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -0700464 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530465 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700466 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530467 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700468 return;
469 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530470 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700471
Shailender Karmuchia734f332013-04-19 14:02:48 -0700472 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -0700473 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530474 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800475 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530476 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700477 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530478 hddLog(LOGW,
479 "%s: RIC IEs is of length 0 not sending RIC Information for now",
480 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700481 }
482 else
483 {
484 wrqu.data.length = str_len + ric_ies_length;
485 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
486 }
487
488 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530489 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700490 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530491 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
492 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700493
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530494 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700495 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530496 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700497 return;
498 }
499
500 wrqu.data.length = str_len + auth_resp_len;
501 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
502
503 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700504#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700505}
506
507#endif /* WLAN_FEATURE_VOWIFI_11R */
508
509#ifdef FEATURE_WLAN_CCX
510
511/*
512 * Send the CCX required "new AP Channel info" to the supplicant.
513 * (This keeps the supplicant "up to date" on the current channel.)
514 *
515 * The current (new AP) channel information is passed in.
516 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700517static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700518 tCsrRoamInfo *pCsrRoamInfo)
519{
520 union iwreq_data wrqu;
521 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700522
Shailender Karmuchia734f332013-04-19 14:02:48 -0700523
524 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700525 {
526 hddLog(LOGE,
Arif Hussain6d2a3322013-11-17 19:50:10 -0800527 "%s: pCsrRoamInfo->pBssDesc=%p",
Jeff Johnson295189b2012-06-20 16:38:30 -0700528 __func__, descriptor);
529 return;
530 }
531
532 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -0800533 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -0700534 memset(&wrqu, '\0', sizeof(wrqu));
535 wrqu.freq.m = descriptor->channelId;
536 wrqu.freq.e = 0;
537 wrqu.freq.i = 0;
538 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
539}
540
541#endif /* FEATURE_WLAN_CCX */
542
543void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
544{
545 union iwreq_data wrqu;
546 u8 *pBeaconIes;
547 u8 currentLen = 0;
548 char *buff;
549 int totalIeLen = 0, currentOffset = 0, strLen;
550
551 memset(&wrqu, '\0', sizeof(wrqu));
552
553 if (0 == pCsrRoamInfo->nBeaconLength)
554 {
555 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
556 return;
557 }
558 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700559 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700561 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700562 return;
563 }
564
565 // pBeaconIes needs to point to the IEs
566 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
567 (unsigned int)pBeaconIes[0],
568 (unsigned int)pBeaconIes[1]);
569 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700570
Jeff Johnson295189b2012-06-20 16:38:30 -0700571 // We need to send the IEs to the supplicant.
572 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700573 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700574 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700575 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700576 return;
577 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700578 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700579
580 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
581 currentLen = strLen + 1;
582
583 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
584 do
585 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700586 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -0700587 * max size and send it to supplicant. Changes are done in supplicant to handle this */
588 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
589 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
590 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
591 currentOffset += currentLen;
592 totalIeLen -= currentLen;
593 wrqu.data.length = strLen + 1 + currentLen;
594 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700595 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -0700596 else
597 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
598
599 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
600 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
601 } while (totalIeLen > 0);
602
603 kfree(buff);
604}
605
606static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
607{
608 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
609 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
610 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
611 union iwreq_data wrqu;
612 int we_event;
613 char *msg;
614 int type = -1;
615
Shailender Karmuchia734f332013-04-19 14:02:48 -0700616#if defined (WLAN_FEATURE_VOWIFI_11R)
617 // Added to find the auth type on the fly at run time
618 // rather than with cfg to see if FT is enabled
619 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700620 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
621#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700622
Jeff Johnson295189b2012-06-20 16:38:30 -0700623 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -0700624 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700625 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700626
Jeff Johnson295189b2012-06-20 16:38:30 -0700627 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
628 {
629 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
630 type = WLAN_STA_ASSOC_DONE_IND;
631
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700632#ifdef WLAN_FEATURE_P2P_DEBUG
633 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
634 {
635 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
636 {
637 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
638 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
639 "Connecting state to Connected State for 8-way "
640 "Handshake");
641 }
642 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
643 {
644 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
645 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
646 "Connecting state to P2P Client Connection Completed");
647 }
648 }
649#endif
Arif Hussain24bafea2013-11-15 15:10:03 -0800650 pr_info("wlan: connected to " MAC_ADDRESS_STR"\n",
651 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -0700652 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
653
654 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
655 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
656 * and fFTEnable is TRUE */
657#ifdef WLAN_FEATURE_VOWIFI_11R
658 // Send FT Keys to the supplicant when FT is enabled
659 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700660 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Jeff Johnson295189b2012-06-20 16:38:30 -0700661#ifdef FEATURE_WLAN_CCX
662 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
663 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
664#endif
665 )
666 {
667 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
668 }
669#endif
670 }
671 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
672 {
Jeff Johnson4416a782013-03-25 14:17:50 -0700673 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700674 type = WLAN_STA_ASSOC_DONE_IND;
Arif Hussain24bafea2013-11-15 15:10:03 -0800675 pr_info("wlan: new IBSS connection to " MAC_ADDRESS_STR"\n",
676 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -0700677 }
678 else /* Not Associated */
679 {
680 pr_info("wlan: disconnected\n");
681 type = WLAN_STA_DISASSOC_DONE_IND;
682 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
683 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700684 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700685
686 msg = NULL;
687 /*During the WLAN uninitialization,supplicant is stopped before the
688 driver so not sending the status of the connection to supplicant*/
689 if(pHddCtx->isLoadUnloadInProgress != TRUE)
690 {
691 wireless_send_event(dev, we_event, &wrqu, msg);
692#ifdef FEATURE_WLAN_CCX
693 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700694 {
695 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
696 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700697 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
698 }
699#endif
700 }
701 send_btc_nlink_msg(type, 0);
702}
703
704void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
705{
706 // Remove staId, bssId and peerMacAddress
707 pHddStaCtx->conn_info.staId [ 0 ] = 0;
708 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
709 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
710
711 // Clear all security settings
712 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
713 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
714 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
715
716 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -0700717 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -0700718
719 // Set not-connected state
720 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700721 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Jeff Johnson295189b2012-06-20 16:38:30 -0700722
723 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
724}
725/* TODO Revist this function. and data path */
726static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
727{
728 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -0700729 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
730
731 if (WLAN_HDD_IBSS != pAdapter->device_mode)
732 {
733 hdd_disconnect_tx_rx(pAdapter);
734 }
735 else
736 {
737 // Need to cleanup all queues only if the last peer leaves
738 if (eConnectionState_IbssDisconnected == pHddStaCtx->conn_info.connState)
739 {
740 netif_tx_disable(pAdapter->dev);
741 netif_carrier_off(pAdapter->dev);
742 hdd_disconnect_tx_rx(pAdapter);
743 }
744 else
745 {
746 // There is atleast one more peer, do not cleanup all queues
747 hdd_flush_ibss_tx_queues(pAdapter, staId);
748 }
749 }
750
Jeff Johnson295189b2012-06-20 16:38:30 -0700751 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
752 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
753 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530754 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700755 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -0700756 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700757 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 }
759 return( vosStatus );
760}
761
762
763static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
764 tANI_U32 roamId, eRoamCmdStatus roamStatus,
765 eCsrRoamResult roamResult )
766{
767 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700768 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700769 struct net_device *dev = pAdapter->dev;
770 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
771 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -0700772 v_U8_t sta_id;
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700773
774 // Sanity check
775 if(dev == NULL)
776 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700777 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700778 "%s: net_dev is released return", __func__);
779 return eHAL_STATUS_FAILURE;
780 }
781
Jeff Johnson295189b2012-06-20 16:38:30 -0700782 // notify apps that we can't pass traffic anymore
783 netif_tx_disable(dev);
784 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700785
Jeff Johnsone7245742012-09-05 17:12:55 -0700786 INIT_COMPLETION(pAdapter->disconnect_comp_var);
787 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
Jeff Johnson295189b2012-06-20 16:38:30 -0700788 /* If only STA mode is on */
789 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
790 {
791 pHddCtx->isAmpAllowed = VOS_TRUE;
792 }
793 hdd_clearRoamProfileIe( pAdapter );
794
795 // indicate 'disconnect' status to wpa_supplicant...
796 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700797 /* indicate disconnected event to nl80211 */
798 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
799 {
800 /*During the WLAN uninitialization,supplicant is stopped before the
801 driver so not sending the status of the connection to supplicant*/
802 if(pHddCtx->isLoadUnloadInProgress != TRUE)
803 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700804 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
805 "%s: sent disconnected event to nl80211",
Jeff Johnson295189b2012-06-20 16:38:30 -0700806 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700807#ifdef WLAN_FEATURE_P2P_DEBUG
808 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
809 {
810 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
811 {
812 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
813 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
814 "and moved to disconnected state");
815 }
816 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
817 {
818 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
819 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
820 "and moved to inactive state");
821 }
822 }
823#endif
824
Jeff Johnson295189b2012-06-20 16:38:30 -0700825 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
826 if( eCSR_ROAM_LOSTLINK == roamStatus )
827 {
Mohit Khanna99d5fd02012-09-11 14:51:20 -0700828 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700829 }
830 else
831 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700832 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700833 }
834
835 //If the Device Mode is Station
836 // and the P2P Client is Connected
837 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -0700838
839 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -0700840 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -0700841 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -0700842 {
843 //Enable BMPS only of other Session is P2P Client
844 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700845 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -0700846
847 if (NULL != pVosContext)
848 {
849 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
850
851 if(NULL != pHddCtx)
852 {
853 //Only P2P Client is there Enable Bmps back
854 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
Jeff Johnsone7245742012-09-05 17:12:55 -0700855 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700856 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530857 if (pHddCtx->hdd_wlan_suspended)
858 {
859 hdd_set_pwrparams(pHddCtx);
860 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700861 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530862 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700863 }
864 }
865 }
866 }
867 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700868
krunal soni3fc26642013-10-08 22:41:42 -0700869 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
870 {
871 sta_id = IBSS_BROADCAST_STAID;
872 }
873 else
874 {
875 sta_id = pHddStaCtx->conn_info.staId[0];
876 }
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +0530877 hdd_wmm_adapter_clear(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700878 //We should clear all sta register with TL, for now, only one.
krunal soni3fc26642013-10-08 22:41:42 -0700879 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
Jeff Johnson43971f52012-07-17 12:26:56 -0700880 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700881 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530882 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700883 "hdd_roamDeregisterSTA() failed to for staID %d. "
884 "Status= %d [0x%x]",
krunal soni3fc26642013-10-08 22:41:42 -0700885 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -0700886
887 status = eHAL_STATUS_FAILURE;
888 }
889
krunal soni3fc26642013-10-08 22:41:42 -0700890 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -0700891 // Clear saved connection information in HDD
892 hdd_connRemoveConnectInfo( pHddStaCtx );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530893#ifdef WLAN_FEATURE_GTK_OFFLOAD
894 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
895 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
896 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +0530897 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
898 sizeof (tSirGtkOffloadParams));
899 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530900 }
901#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700902
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800903#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -0700904 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
905 {
906 wlan_hdd_tdls_disconnection_callback(pAdapter);
907 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800908#endif
909
Jeff Johnson295189b2012-06-20 16:38:30 -0700910 //Unblock anyone waiting for disconnect to complete
911 complete(&pAdapter->disconnect_comp_var);
912 return( status );
913}
914static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
915 tCsrRoamInfo *pRoamInfo,
916 v_U8_t staId,
917 v_MACADDR_t *pPeerMacAddress,
918 tSirBssDescription *pBssDesc )
919{
920 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
921 WLAN_STADescType staDesc = {0};
922 eCsrEncryptionType connectedCipherAlgo;
923 v_BOOL_t fConnected;
924 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
925 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -0700926 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700927
928 if ( NULL == pBssDesc)
929 {
930 return VOS_STATUS_E_FAILURE;
931 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700932 // Get the Station ID from the one saved during the assocation.
933 staDesc.ucSTAId = staId;
934
935 if ( pHddStaCtx->conn_info.connDot11DesiredBssType == eMib_dot11DesiredBssType_infrastructure)
Jeff Johnson295189b2012-06-20 16:38:30 -0700936 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700937 staDesc.wSTAType = WLAN_STA_INFRA;
938
939 // grab the bssid from the connection info in the adapter structure and hand that
940 // over to TL when registering.
941 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) );
942 }
943 else
944 {
945 // for an IBSS 'connect', setup the Station Descriptor for TL.
Jeff Johnson295189b2012-06-20 16:38:30 -0700946 staDesc.wSTAType = WLAN_STA_IBSS;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700947
Jeff Johnson295189b2012-06-20 16:38:30 -0700948 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
949 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
950 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
951 // pass when making an Infrastructure connection.
952 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) );
953 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
954 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700955
Jeff Johnson295189b2012-06-20 16:38:30 -0700956 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
957
958 // set the QoS field appropriately
959 if (hdd_wmm_is_active(pAdapter))
960 {
961 staDesc.ucQosEnabled = 1;
962 }
963 else
964 {
965 staDesc.ucQosEnabled = 0;
966 }
967
968 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
969 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
970 {
971 staDesc.ucProtectedFrame = 1;
972 }
973 else
974 {
975 staDesc.ucProtectedFrame = 0;
976
977 }
978
979#ifdef FEATURE_WLAN_CCX
980 staDesc.ucIsCcxSta = pRoamInfo->isCCXAssoc;
981#endif //FEATURE_WLAN_CCX
982
983#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
984 /* check whether replay check is valid for the station or not */
985 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
986 {
987 /* Encryption mode is either TKIP or AES
988 and replay check is valid for only these
989 two encryption modes */
990 staDesc.ucIsReplayCheckValid = VOS_TRUE;
991 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
992 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
993 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700994
Jeff Johnson295189b2012-06-20 16:38:30 -0700995 else
996 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700997 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -0700998 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700999 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001000 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1001 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
1002 }
1003#endif
1004
1005#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001006 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 if (pAdapter->wapi_info.fIsWapiSta)
1008 {
1009 staDesc.ucIsWapiSta = 1;
1010 }
1011 else
1012 {
1013 staDesc.ucIsWapiSta = 0;
1014 }
1015#endif /* FEATURE_WLAN_WAPI */
1016
1017 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
1018 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
1019
Jeff Johnson295189b2012-06-20 16:38:30 -07001020 // UMA is Not ready yet, Xlation will be done by TL
1021 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07001022 staDesc.ucSwFrameRXXlation = 1;
1023 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001024 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07001025 staDesc.ucQosEnabled );
1026 // Initialize signatures and state
1027 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1028 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1029 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
1030 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001031 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08001032 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 -07001033 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1034 hdd_rx_packet_cbk,
1035 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001036 hdd_tx_fetch_packet_cbk, &staDesc,
1037 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001038
Jeff Johnson295189b2012-06-20 16:38:30 -07001039 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1040 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001041 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001042 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001044 return vosStatus;
1045 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001046
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001047 if ( cfg_param->dynSplitscan &&
1048 ( VOS_TIMER_STATE_RUNNING !=
1049 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1050 {
1051 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1052 cfg_param->trafficMntrTmrForSplitScan);
1053 }
1054
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301055 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1056 // then go to 'authenticated'. For all other authentication types
1057 // (those that donot require upper layer authentication) we can put
1058 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001059 if (staDesc.wSTAType != WLAN_STA_IBSS)
1060 VOS_ASSERT( fConnected );
1061
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301062 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001063 {
1064 // Connections that do not need Upper layer auth, transition TL directly
1065 // to 'Authenticated' state.
1066 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1067 WLANTL_STA_AUTHENTICATED );
1068
1069 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1070 }
1071 else
1072 {
1073 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301074 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1075 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001076 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301077 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001078 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1079 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001080 return( vosStatus );
1081}
1082
Jeff Johnson295189b2012-06-20 16:38:30 -07001083static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1084 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1085{
1086 unsigned int len = 0;
1087 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001088 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001089 tANI_U32 rspRsnLength = 0;
1090 struct ieee80211_channel *chan;
1091
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001092 if (!rspRsnIe)
1093 {
1094 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001095 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001096 }
1097
Jeff Johnson295189b2012-06-20 16:38:30 -07001098 if (pCsrRoamInfo == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001099 {
1100 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1101 goto done;
1102 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001103
1104 if (pCsrRoamInfo->nAssocRspLength == 0)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001105 {
1106 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1107 goto done;
1108 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001109
1110 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1111 pCsrRoamInfo->nAssocReqLength);
1112 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001113 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001114
1115 //pFTAssocRsp needs to point to the IEs
1116 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08001117 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07001118 (unsigned int)pFTAssocRsp[0],
1119 (unsigned int)pFTAssocRsp[1]);
1120
1121 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001122 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001123 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001124 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001125 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001126
1127 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1128 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1129 reqRsnIe, reqRsnLength,
1130 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001131
1132done:
1133 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001134}
Jeff Johnson295189b2012-06-20 16:38:30 -07001135
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301136void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1137{
1138 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1139 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1140 tCsrRoamInfo roamInfo;
1141 roamInfo.fAuthRequired = FALSE;
1142 vos_mem_copy(roamInfo.bssid,
1143 pHddStaCtx->roam_info.bssid,
1144 WNI_CFG_BSSID_LEN);
1145 vos_mem_copy(roamInfo.peerMac,
1146 pHddStaCtx->roam_info.peerMac,
1147 WNI_CFG_BSSID_LEN);
1148
1149 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1150 &roamInfo,
1151 pHddStaCtx->roam_info.roamId,
1152 pHddStaCtx->roam_info.roamStatus,
1153 eCSR_ROAM_RESULT_AUTHENTICATED);
1154 if (halStatus != eHAL_STATUS_SUCCESS)
1155 {
1156 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1157 }
1158 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1159}
1160
Shailender Karmuchia734f332013-04-19 14:02:48 -07001161static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1162 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001163 eCsrRoamResult roamResult )
1164{
1165 struct net_device *dev = pAdapter->dev;
1166 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1167 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1168 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001169 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1170 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001171#if defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001172 int ft_carrier_on = FALSE;
1173#endif
1174 int status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001175
Jeff Johnson295189b2012-06-20 16:38:30 -07001176 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1177 {
1178 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1179
1180 // Save the connection info from CSR...
1181 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1182#ifdef FEATURE_WLAN_WAPI
1183 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1184 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1185 {
1186 pAdapter->wapi_info.fIsWapiSta = 1;
1187 }
1188 else
1189 {
1190 pAdapter->wapi_info.fIsWapiSta = 0;
1191 }
1192#endif /* FEATURE_WLAN_WAPI */
1193
1194 // indicate 'connect' status to userspace
1195 hdd_SendAssociationEvent(dev,pRoamInfo);
1196
1197
Shailender Karmuchia734f332013-04-19 14:02:48 -07001198 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 INIT_COMPLETION(pAdapter->linkup_event_var);
1200
1201 /*
1202 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1203 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 -07001204 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001205 know that the device is getting activated properly.
1206 */
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001207#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001208 if (pHddStaCtx->ft_carrier_on == FALSE)
1209 {
1210#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001211 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001212 pAdapter->isLinkUpSvcNeeded = TRUE;
1213
Shailender Karmuchia734f332013-04-19 14:02:48 -07001214 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001215 pAdapter->isLinkUpSvcNeeded = TRUE;
1216
1217 // Switch on the Carrier to activate the device
1218 netif_carrier_on(dev);
1219
1220 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1221 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1222 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001223 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001224 {
1225 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1226 }
1227
1228 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1229 pAdapter->isLinkUpSvcNeeded = FALSE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001230#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001231 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001232 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001233 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001234 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001235 }
1236#endif
1237 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1238
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001239#ifdef FEATURE_WLAN_TDLS
1240 wlan_hdd_tdls_connection_callback(pAdapter);
1241#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 //For reassoc, the station is already registered, all we need is to change the state
1243 //of the STA in TL.
1244 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
1245 if( !pRoamInfo->fReassocReq )
1246 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001247 struct cfg80211_bss *bss;
1248#ifdef WLAN_FEATURE_VOWIFI_11R
1249 u8 *pFTAssocRsp = NULL;
1250 unsigned int assocRsplen = 0;
1251 u8 *pFTAssocReq = NULL;
1252 unsigned int assocReqlen = 0;
1253 struct ieee80211_channel *chan;
1254#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001255 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001256 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001257
1258 /* add bss_id to cfg80211 data base */
1259 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1260 if (NULL == bss)
1261 {
1262 pr_err("wlan: Not able to create BSS entry\n");
1263 return eHAL_STATUS_FAILURE;
1264 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001265#ifdef WLAN_FEATURE_VOWIFI_11R
1266 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001267 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001268 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001269
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001270 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001271 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001272 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001273 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001274 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001275 // pFTAssocRsp needs to point to the IEs
1276 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1277 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1278 (unsigned int)pFTAssocRsp[0],
1279 (unsigned int)pFTAssocRsp[1]);
1280 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001281 }
1282 else
1283 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001284 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1285 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001286 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001287
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001288 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001289 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001290 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001291 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001292 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001293 if(!ft_carrier_on)
1294 {
1295 // pFTAssocReq needs to point to the IEs
1296 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1297 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1298 (unsigned int)pFTAssocReq[0],
1299 (unsigned int)pFTAssocReq[1]);
1300 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1301 }
1302 else
1303 {
1304 /* This should contain only the FTIEs */
1305 assocReqlen = pRoamInfo->nAssocReqLength;
1306 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001307 }
1308 else
1309 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001310 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1311 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001312 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001313
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001314 if(ft_carrier_on)
1315 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001316 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001317 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001318 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1319 (int)pRoamInfo->pBssDesc->channelId);
Arif Hussain6d2a3322013-11-17 19:50:10 -08001320 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001321 assocRsplen);
1322 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
1323 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1324 GFP_KERNEL);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301325 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1326 {
1327 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1328 pRoamInfo->fAuthRequired = FALSE;
1329
1330 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1331 pRoamInfo->bssid,
1332 HDD_MAC_ADDR_LEN);
1333 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1334 pRoamInfo->peerMac,
1335 HDD_MAC_ADDR_LEN);
1336 pHddStaCtx->roam_info.roamId = roamId;
1337 pHddStaCtx->roam_info.roamStatus = roamStatus;
1338 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1339 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001340 }
1341 else
1342 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001343 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08001344 "indication", __FUNCTION__, ft_carrier_on);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001345 cfg80211_connect_result(dev, pRoamInfo->bssid,
1346 pFTAssocReq, assocReqlen,
1347 pFTAssocRsp, assocRsplen,
1348 WLAN_STATUS_SUCCESS,
1349 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001350 }
1351 }
1352 else
1353#endif
1354 {
1355 /* wpa supplicant expecting WPA/RSN IE in connect result */
1356 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1357 pAdapter->sessionId,
1358 &reqRsnLength,
1359 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001360
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001361 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1362 pAdapter->sessionId,
1363 &rspRsnLength,
1364 rspRsnIe);
1365#if defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1366 if(ft_carrier_on)
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001367 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001368 else
1369#endif /* FEATURE_WLAN_CCX */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001370
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001371 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001372 /* inform connect result to nl80211 */
1373 cfg80211_connect_result(dev, pRoamInfo->bssid,
1374 reqRsnIe, reqRsnLength,
1375 rspRsnIe, rspRsnLength,
1376 WLAN_STATUS_SUCCESS,
1377 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001378 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001379 }
Yue Maf49ba872013-08-19 12:04:25 -07001380 cfg80211_put_bss(
1381#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1382 pHddCtx->wiphy,
1383#endif
1384 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001385 // Register the Station with TL after associated...
1386 vosStatus = hdd_roamRegisterSTA( pAdapter,
1387 pRoamInfo,
1388 pHddStaCtx->conn_info.staId[ 0 ],
1389 NULL,
1390 pRoamInfo->pBssDesc );
1391 }
1392 else
1393 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001394 /* wpa supplicant expecting WPA/RSN IE in connect result */
1395 /* in case of reassociation also need to indicate it to supplicant */
1396 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1397 pAdapter->sessionId,
1398 &reqRsnLength,
1399 reqRsnIe);
1400
1401 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001402 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301403 if( pRoamInfo->fAuthRequired )
1404 {
1405 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1406 pHddStaCtx->conn_info.staId[ 0 ],
1407 WLANTL_STA_CONNECTED );
1408 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1409 }
1410 else
1411 {
1412 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1413 "%s: staId: %d Changing TL state to AUTHENTICATED",
1414 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1415 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1416 pHddStaCtx->conn_info.staId[ 0 ],
1417 WLANTL_STA_AUTHENTICATED );
1418 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1419 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001420 }
1421
1422 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1423 {
1424 // perform any WMM-related association processing
1425 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1426 }
1427 else
1428 {
1429 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001430 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001431 vosStatus, vosStatus );
1432 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001433#ifdef WLAN_FEATURE_11W
1434 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1435 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1436#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001437 // Start the Queue
1438 netif_tx_wake_all_queues(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001439 }
1440 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001441 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001442 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1443
1444 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001445 if (pRoamInfo)
Arif Hussain24bafea2013-11-15 15:10:03 -08001446 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1447 " reason:%d and Status:%d\n",
1448 MAC_ADDR_ARRAY(pRoamInfo->bssid),
1449 roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001450 else
Arif Hussain24bafea2013-11-15 15:10:03 -08001451 pr_info("wlan: connection failed with " MAC_ADDRESS_STR
1452 " reason:%d and Status:%d\n",
1453 MAC_ADDR_ARRAY(pWextState->req_bssId),
1454 roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001455
1456 /*Handle all failure conditions*/
1457 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1458 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
1459 {
1460 pHddCtx->isAmpAllowed = VOS_TRUE;
1461 }
1462
1463 //If the Device Mode is Station
1464 // and the P2P Client is Connected
1465 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001466
1467 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001468 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001469 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1470 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001471 (vos_concurrent_sessions_running()))
1472 {
1473 //Enable BMPS only of other Session is P2P Client
1474 hdd_context_t *pHddCtx = NULL;
1475 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1476
1477 if (NULL != pVosContext)
1478 {
1479 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1480
1481 if(NULL != pHddCtx)
1482 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301483 //Only P2P Client is there Enable Bmps back
1484 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
1485 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
1486 {
1487 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001488 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301489 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001490 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301491 hdd_enable_bmps_imps(pHddCtx);
1492 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001493 }
1494 }
1495 }
1496
James Zmudafbf5ffc2013-03-25 12:45:35 -07001497 /* CR465478: Only send up a connection failure result when CSR has
James Zmuda7019bb32013-10-25 10:29:37 -07001498 * completed operation - with a ASSOCIATION_FAILURE status.
1499 * or an ASSOCIATION_COMPLETION with RESULT_NOT_ASSOCIATED */
1500 if (( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus ) ||
1501 (( eCSR_ROAM_ASSOCIATION_COMPLETION == roamStatus )
1502 && ( eCSR_ROAM_RESULT_NOT_ASSOCIATED == roamResult )))
Jeff Johnsone7245742012-09-05 17:12:55 -07001503 {
James Zmudafbf5ffc2013-03-25 12:45:35 -07001504 /* inform association failure event to nl80211 */
1505 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1506 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001507 if (pRoamInfo)
1508 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1509 NULL, 0, NULL, 0,
1510 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1511 GFP_KERNEL );
1512 else
1513 cfg80211_connect_result ( dev, pWextState->req_bssId,
1514 NULL, 0, NULL, 0,
1515 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1516 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001517 }
1518 else
1519 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001520 if (pRoamInfo)
1521 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1522 NULL, 0, NULL, 0,
1523 WLAN_STATUS_UNSPECIFIED_FAILURE,
1524 GFP_KERNEL );
1525 else
1526 cfg80211_connect_result ( dev, pWextState->req_bssId,
1527 NULL, 0, NULL, 0,
1528 WLAN_STATUS_UNSPECIFIED_FAILURE,
1529 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001530 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001531 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001532
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001533 /*Clear the roam profile*/
1534 hdd_clearRoamProfileIe( pAdapter );
1535
Jeff Johnson295189b2012-06-20 16:38:30 -07001536 netif_tx_disable(dev);
1537 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001538
Jeff Johnson295189b2012-06-20 16:38:30 -07001539 }
1540
1541 return eHAL_STATUS_SUCCESS;
1542}
1543
1544/**============================================================================
1545 *
Jeff Johnson81c17882013-05-03 09:53:35 -07001546 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07001547 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07001548
Jeff Johnson295189b2012-06-20 16:38:30 -07001549 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07001550static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
1551 tCsrRoamInfo *pRoamInfo,
1552 tANI_U32 roamId,
1553 eRoamCmdStatus roamStatus,
1554 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07001555{
Jeff Johnson81c17882013-05-03 09:53:35 -07001556 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
1557 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
1558
Jeff Johnson295189b2012-06-20 16:38:30 -07001559 switch( roamResult )
1560 {
1561 // both IBSS Started and IBSS Join should come in here.
1562 case eCSR_ROAM_RESULT_IBSS_STARTED:
1563 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001564 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07001565 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001566 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1567 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001568
Jeff Johnson81c17882013-05-03 09:53:35 -07001569 if (NULL == pRoamInfo)
1570 {
1571 VOS_ASSERT(0);
1572 return;
1573 }
1574
1575 /* When IBSS Started comes from CSR, we need to move
1576 * connection state to IBSS Disconnected (meaning no peers
1577 * are in the IBSS).
1578 */
1579 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
1580 eConnectionState_IbssDisconnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001581 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1582 hdd_roamRegisterSTA (pAdapter, pRoamInfo,
1583 IBSS_BROADCAST_STAID,
1584 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001585
Jeff Johnson81c17882013-05-03 09:53:35 -07001586 if (pRoamInfo->pBssDesc)
1587 {
1588 struct cfg80211_bss *bss;
1589
1590 /* we created the IBSS, notify supplicant */
1591 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
1592 MAC_ADDRESS_STR,
1593 __func__, pAdapter->dev->name,
1594 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
1595
1596 /* we must first give cfg80211 the BSS information */
1597 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1598 if (NULL == bss)
1599 {
1600 hddLog(VOS_TRACE_LEVEL_ERROR,
1601 "%s: %s: unable to create IBSS entry",
1602 __func__, pAdapter->dev->name);
1603 return;
1604 }
1605
1606 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07001607 cfg80211_put_bss(
1608#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1609 pHddCtx->wiphy,
1610#endif
1611 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07001612 }
1613
Jeff Johnson295189b2012-06-20 16:38:30 -07001614 break;
1615 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001616
Jeff Johnson295189b2012-06-20 16:38:30 -07001617 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
1618 {
Jeff Johnson81c17882013-05-03 09:53:35 -07001619 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
1620 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07001621 break;
1622 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001623
Jeff Johnson295189b2012-06-20 16:38:30 -07001624 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07001625 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
1626 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001627 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001628 }
1629
Jeff Johnson81c17882013-05-03 09:53:35 -07001630 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001631}
1632
1633/**============================================================================
1634 *
1635 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
1636 This information is passed to iwconfig later. The peer that joined
1637 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001638 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001639 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001640
Jeff Johnson295189b2012-06-20 16:38:30 -07001641 ===========================================================================*/
1642static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
1643{
1644 int fSuccess = FALSE;
1645 int idx = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001646
Jeff Johnson295189b2012-06-20 16:38:30 -07001647 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1648 {
1649 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
1650 {
1651 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001652
Jeff Johnson295189b2012-06-20 16:38:30 -07001653 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001654
Jeff Johnson295189b2012-06-20 16:38:30 -07001655 fSuccess = TRUE;
1656 break;
1657 }
1658 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001659
1660 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07001661}
1662/**============================================================================
1663 *
1664 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001665 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001666 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001667
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07001669static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07001670{
1671 int fSuccess = FALSE;
1672 int idx = 0;
1673 v_U8_t valid_idx = 0;
1674 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07001675 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001676 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001677
Jeff Johnson295189b2012-06-20 16:38:30 -07001678 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1679 {
1680 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
1681 {
1682 pHddStaCtx->conn_info.staId[ idx ] = 0;
1683
1684 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
1685
1686 fSuccess = TRUE;
Ravi Joshi8a934352013-09-25 16:46:58 -07001687
Jeff Johnson295189b2012-06-20 16:38:30 -07001688 // Note the deleted Index, if its 0 we need special handling
1689 del_idx = idx;
Ravi Joshi8a934352013-09-25 16:46:58 -07001690
1691 empty_slots++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001692 }
1693 else
1694 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001695 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001696 {
1697 valid_idx = idx;
1698 }
Ravi Joshi8a934352013-09-25 16:46:58 -07001699 else
1700 {
1701 // Found an empty slot
1702 empty_slots++;
1703 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001704 }
1705 }
1706
Ravi Joshi8a934352013-09-25 16:46:58 -07001707 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
1708 {
1709 // Last peer departed, set the IBSS state appropriately
1710 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07001711 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07001712 "Last IBSS Peer Departed!!!" );
1713 }
1714
Jeff Johnson295189b2012-06-20 16:38:30 -07001715 // Find next active staId, to have a valid sta trigger for TL.
1716 if (fSuccess == TRUE)
1717 {
1718 if (del_idx == 0)
1719 {
1720 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
1721 {
1722 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
1723 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
1724 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
1725
1726 pHddStaCtx->conn_info.staId[valid_idx] = 0;
1727 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
1728 }
1729 }
1730 }
1731 return( fSuccess );
1732}
1733
1734/**============================================================================
1735 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001736 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07001737 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001738
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 ===========================================================================*/
1740static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
1741{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001742 struct cfg80211_bss *bss;
Jeff Johnson295189b2012-06-20 16:38:30 -07001743 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "IBSS Connect Indication from SME!!!" );
1744 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
1745 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
1746
1747 // Save the connection info from CSR...
1748 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
1749
1750 // Send the bssid address to the wext.
1751 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001752 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001753 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1754 if (NULL == bss)
1755 {
1756 hddLog(VOS_TRACE_LEVEL_ERROR,
1757 "%s: %s: unable to create IBSS entry",
1758 __func__, pAdapter->dev->name);
1759 return eHAL_STATUS_FAILURE;
1760 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001761 /* send ibss join indication to nl80211 */
1762 cfg80211_ibss_joined(pAdapter->dev, &pRoamInfo->bssid[0], GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07001763 cfg80211_put_bss(
1764#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1765 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
1766#endif
1767 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001768
1769 return( eHAL_STATUS_SUCCESS );
1770}
1771/**============================================================================
1772 *
1773 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001774
Jeff Johnson295189b2012-06-20 16:38:30 -07001775 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001776static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1777 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001778 eCsrRoamResult roamResult )
1779{
1780 eCsrEncryptionType connectedCipherAlgo;
1781 v_BOOL_t fConnected = FALSE;
1782 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1783 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1784 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1785 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07001786
1787 if (NULL == pRoamInfo)
1788 {
1789 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
1790 return eHAL_STATUS_FAILURE;
1791 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001792 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001793 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07001794 // not require upper layer authentication) we can put TL directly into 'authenticated'
1795 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001796 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1797 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
1798 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001799
Jeff Johnson295189b2012-06-20 16:38:30 -07001800 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1801 if( fConnected )
1802 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001803 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
1804 {
1805 v_U8_t staId;
1806
1807 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
1808
1809 if ( 0 == memcmp( pRoamInfo->peerMac,
1810 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
1811 {
1812 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1813 IBSS_BROADCAST_STAID);
1814 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1815 }
1816 else
1817 {
1818 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
1819 (v_MACADDR_t*)pRoamInfo->peerMac,
1820 &staId);
1821 if ( VOS_STATUS_SUCCESS == vosStatus )
1822 {
1823 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1824 "WLAN TL STA Ptk Installed for STAID=%d", staId);
1825 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1826 staId);
1827 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1828 }
1829 }
1830 }
1831 else
1832 {
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301833 // TODO: Considering getting a state machine in HDD later.
1834 // This routine is invoked twice. 1)set PTK 2)set GTK.
1835 // The folloing if statement will be TRUE when setting GTK.
1836 // At this time we don't handle the state in detail.
1837 // Related CR: 174048 - TL not in authenticated state
1838 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
1839 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
1840 {
1841 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
1842 "for StaId= %d. Changing TL state to AUTHENTICATED",
1843 pHddStaCtx->conn_info.staId[ 0 ] );
1844
1845 // Connections that do not need Upper layer authentication,
1846 // transition TL to 'Authenticated' state after the keys are set.
1847 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1848 pHddStaCtx->conn_info.staId[ 0 ],
1849 WLANTL_STA_AUTHENTICATED );
1850
1851 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1852 }
1853 else
1854 {
1855 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1856 pHddStaCtx->conn_info.staId[ 0 ]);
1857 }
1858
1859 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001861 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301862 else
1863 {
1864 // possible disassoc after issuing set key and waiting set key complete
1865 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1866 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001867
Jeff Johnson295189b2012-06-20 16:38:30 -07001868 EXIT();
1869 return( eHAL_STATUS_SUCCESS );
1870}
1871/**============================================================================
1872 *
1873 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
1874 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001875static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07001876 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07001877{
Jeff Johnson295189b2012-06-20 16:38:30 -07001878 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1879
1880 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
1881 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
1882 {
1883 struct iw_michaelmicfailure msg;
1884 union iwreq_data wreq;
1885 memset(&msg, '\0', sizeof(msg));
1886 msg.src_addr.sa_family = ARPHRD_ETHER;
1887 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08001888 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
1889 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001890
Jeff Johnson295189b2012-06-20 16:38:30 -07001891 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
1892 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001893 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001894 msg.flags = IW_MICFAILURE_PAIRWISE;
1895 memset(&wreq, 0, sizeof(wreq));
1896 wreq.data.length = sizeof(msg);
1897 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07001898 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001899 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001900 pRoamInfo->u.pMICFailureInfo->taMacAddr,
1901 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
1902 NL80211_KEYTYPE_GROUP :
1903 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07001904 pRoamInfo->u.pMICFailureInfo->keyId,
1905 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001907
Jeff Johnson295189b2012-06-20 16:38:30 -07001908 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001909
Jeff Johnson295189b2012-06-20 16:38:30 -07001910 return( eHAL_STATUS_SUCCESS );
1911}
1912
1913/**============================================================================
1914 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001915 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07001916 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001917
Jeff Johnson295189b2012-06-20 16:38:30 -07001918 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001919static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1920 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001921 eCsrRoamResult roamResult )
1922{
1923 VOS_STATUS vosStatus;
1924
1925 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1926 switch( roamResult )
1927 {
1928 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
1929 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001930 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001931 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001932
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001933 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07001934 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
1935 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
1936 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07001937 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001938
Jeff Johnson295189b2012-06-20 16:38:30 -07001939 if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
1940 {
1941 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1942 "New IBSS peer but we already have the max we can handle. Can't register this one" );
1943 break;
1944 }
1945
1946 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1947
Shailender Karmuchia734f332013-04-19 14:02:48 -07001948 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1949 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
1950 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
1951
1952 // Register the Station with TL for the new peer.
Jeff Johnson295189b2012-06-20 16:38:30 -07001953 vosStatus = hdd_roamRegisterSTA( pAdapter,
1954 pRoamInfo,
1955 pRoamInfo->staId,
1956 (v_MACADDR_t *)pRoamInfo->peerMac,
1957 pRoamInfo->pBssDesc );
1958 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1959 {
1960 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001961 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07001962 vosStatus, vosStatus );
1963 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001964 pHddStaCtx->ibss_sta_generation++;
1965 memset(&staInfo, 0, sizeof(staInfo));
1966 staInfo.filled = 0;
1967 staInfo.generation = pHddStaCtx->ibss_sta_generation;
1968
1969 cfg80211_new_sta(pAdapter->dev,
1970 (const u8 *)pRoamInfo->peerMac,
1971 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001972
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001973 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
1974 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
1975 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
1976 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
1977 {
1978 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
1979 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
1980 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
1981
1982 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08001983 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001984 pHddStaCtx->ibss_enc_key.encType);
1985
1986 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
1987 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
1988
1989 if ( VOS_STATUS_SUCCESS != vosStatus )
1990 {
1991 hddLog(VOS_TRACE_LEVEL_ERROR,
1992 "%s: sme_RoamSetKey failed, returned %d",
1993 __func__, vosStatus);
1994 return VOS_STATUS_E_FAILURE;
1995 }
1996 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001997 netif_carrier_on(pAdapter->dev);
1998 netif_tx_start_all_queues(pAdapter->dev);
1999 break;
2000 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002001
Jeff Johnson295189b2012-06-20 16:38:30 -07002002 case eCSR_ROAM_RESULT_IBSS_CONNECT:
2003 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002004
Jeff Johnson295189b2012-06-20 16:38:30 -07002005 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002006
Jeff Johnson295189b2012-06-20 16:38:30 -07002007 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002008 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002009 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
2010 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002011 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002012
Ravi Joshicc57ed42013-10-12 16:31:25 -07002013 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002014 {
2015 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2016 "IBSS peer departed by cannot find peer in our registration table with TL" );
2017 }
2018
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002019 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07002020 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
2021 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
2022 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
2023 pRoamInfo->staId );
2024
Jeff Johnson295189b2012-06-20 16:38:30 -07002025 hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
2026
2027 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002028 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07002029
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002030 cfg80211_del_sta(pAdapter->dev,
2031 (const u8 *)&pRoamInfo->peerMac,
2032 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002033 break;
2034 }
2035 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2036 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002037 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2038 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002039 // Stop only when we are inactive
2040 netif_tx_disable(pAdapter->dev);
2041 netif_carrier_off(pAdapter->dev);
2042 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002043
Jeff Johnson295189b2012-06-20 16:38:30 -07002044 // Send the bssid address to the wext.
2045 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2046 // clean up data path
2047 hdd_disconnect_tx_rx(pAdapter);
2048 break;
2049 }
2050 default:
2051 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002052
Jeff Johnson295189b2012-06-20 16:38:30 -07002053 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002054
Jeff Johnson295189b2012-06-20 16:38:30 -07002055 return( eHAL_STATUS_SUCCESS );
2056}
2057
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002058#ifdef FEATURE_WLAN_TDLS
2059/**============================================================================
2060 *
2061 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2062 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2063 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002064
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002065 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002066VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
2067 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002068{
2069 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002070 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002071 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2072 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002073 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2074 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002075 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2076 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002077
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002078 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2079 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002080 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002081 "%s not connected. ignored", __func__);
2082 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002083 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002084
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002085 /*
2086 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2087 * be peer MAC, here we are wokrking on direct Link
2088 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002089 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002090
2091 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002092
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002093 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002094 sizeof(tSirMacAddr) );
2095
2096 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2097 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2098
2099 /* set the QoS field appropriately ..*/
2100 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2101 : (staDesc.ucQosEnabled = 0) ;
2102
2103 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08002104 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002105
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002106 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002107
2108 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08002109 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002110
Shailender Karmuchia734f332013-04-19 14:02:48 -07002111 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002112 * UMA is ready we inform TL to do frame translation.
2113 */
2114 staDesc.ucSwFrameTXXlation = 1;
2115 staDesc.ucSwFrameRXXlation = 1;
2116 staDesc.ucAddRmvLLC = 1;
2117
2118 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002119 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002120
2121 /* tdls Direct Link do not need bcastSig */
2122 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002123
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002124#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2125 if(staDesc.ucProtectedFrame)
2126 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2127 else
2128 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2129#endif
2130
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302131 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002132
Shailender Karmuchia734f332013-04-19 14:02:48 -07002133 /* Register the Station with TL... */
2134 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2135 hdd_rx_packet_cbk,
2136 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002137 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002138
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002139 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2140 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002141 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002142 "%s: WLANTL_RegisterSTAClient() failed to register. "
2143 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002144 return vosStatus;
2145 }
2146
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002147 if ( cfg_param->dynSplitscan &&
2148 ( VOS_TIMER_STATE_RUNNING !=
2149 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2150 {
2151 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2152 cfg_param->trafficMntrTmrForSplitScan);
2153 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002154 return( vosStatus );
2155}
2156
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002157static VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
2158{
2159 VOS_STATUS vosStatus;
2160 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2161 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2162 {
2163 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2164 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002165 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002166 __func__, staId, vosStatus, vosStatus );
2167 }
2168 return( vosStatus );
2169}
2170
2171
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002172/*
2173 * HDD interface between SME and TL to ensure TDLS client registration with
2174 * TL in case of new TDLS client is added and deregistration at the time
2175 * TDLS client is deleted.
2176 */
2177
Shailender Karmuchia734f332013-04-19 14:02:48 -07002178eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2179 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002180 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002181 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002182 eCsrRoamResult roamResult)
2183{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002184 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002185 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002186 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002187
2188#ifdef WLAN_FEATURE_TDLS_DEBUG
2189 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Arif Hussain24bafea2013-11-15 15:10:03 -08002190 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
2191 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
2192 "ADD_TDLS_PEER" :
2193 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
2194 "DEL_TDLS_PEER" :
2195 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
2196 "DEL_TDLS_PEER_IND" :
2197 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
2198 "DEL_ALL_TDLS_PEER_IND" :
2199 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
2200 "UPDATE_TDLS_PEER" :
2201 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
2202 "LINK_ESTABLISH_REQ_RSP" : "UNKNOWN",
2203 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002204#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002205 switch( roamResult )
2206 {
2207 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2208 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002209 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2210 {
2211 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002212 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002213 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002214 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002215 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002216
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002217 /* check if there is available index for this new TDLS STA */
2218 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2219 {
2220 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2221 {
2222 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2223 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2224
2225 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002226 ("TDLS: STA IDX at %d is %d "
2227 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002228 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002229 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002230
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002231 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002232 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2233 status = eHAL_STATUS_SUCCESS ;
2234 break ;
2235 }
2236 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002237 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002238 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002239 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002240 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2241 "wlan_hdd_tdls_set_sta_id() failed");
2242 return VOS_FALSE;
2243 }
2244
2245 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302246 /* store the ucast signature , if required for further reference. */
2247
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002248 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302249 /* start TDLS client registration with TL */
2250 status = hdd_roamRegisterTDLSSTA( pAdapter,
2251 pRoamInfo->peerMac,
2252 pRoamInfo->staId,
2253 pRoamInfo->ucastSig);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002254 }
2255 else
2256 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002257 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002258 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002259 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002260 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002261 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002262 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002263 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002264 break ;
2265 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002266 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
2267 {
2268 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2269 {
2270 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2271 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
2272 }
2273 /* store the ucast signature which will be used later when
2274 * registering to TL
2275 */
2276 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
2277 complete(&pAdapter->tdls_add_station_comp);
2278 break;
2279 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302280 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
2281 {
2282 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2283 {
2284 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2285 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
2286 }
2287 complete(&pAdapter->tdls_link_establish_req_comp);
2288 break;
2289 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002290 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002291 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002292 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002293 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002294 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002295 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2296 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002297 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002298 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002299 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2300
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302301 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002302 if (NULL != curr_peer && TDLS_IS_CONNECTED(curr_peer))
2303 {
2304 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2305 wlan_hdd_tdls_decrement_peer_count(pAdapter);
2306 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002307 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002308 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = NULL;
2309
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002310 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2311 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
2312 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002313 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002314 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002315 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002316 break ;
2317 }
2318 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002319 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002320 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002321 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002322 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
2323 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002324 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002325 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2326 "%s: Sending teardown to supplicant with reason code %u",
2327 __func__, pRoamInfo->reasonCode);
2328
2329#ifdef CONFIG_TDLS_IMPLICIT
Madan Mohan Koyyalamudi96797442013-10-08 16:04:42 +05302330 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac, TRUE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002331 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002332#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002333 status = eHAL_STATUS_SUCCESS ;
2334 break ;
2335 }
2336 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
2337 {
2338 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002339 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002340 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002341 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2342 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002343 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002344 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08002345 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002346 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08002347 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002348 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
2349 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
2350 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002351
2352 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[staIdx] = NULL;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002353 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002354 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002355 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2356 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002357
2358 status = eHAL_STATUS_SUCCESS ;
2359 }
2360 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05302361 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002362 break ;
2363 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002364 default:
2365 {
2366 break ;
2367 }
2368 }
2369
2370 return status ;
2371}
2372#endif
2373
Shailender Karmuchia734f332013-04-19 14:02:48 -07002374eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002375 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
2376{
2377 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2378 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302379 hdd_wext_state_t *pWextState = NULL;
2380 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002381 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07002382 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002383
2384 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002385 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07002386 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002387
2388 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302389 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002390 {
2391 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302392 "invalid adapter or adapter has invalid magic");
2393 return eHAL_STATUS_FAILURE;
2394 }
2395
2396 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2397 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2398
2399 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2400 {
2401 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2402 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002403 return eHAL_STATUS_FAILURE;
2404 }
2405
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 switch( roamStatus )
2407 {
2408 case eCSR_ROAM_SESSION_OPENED:
2409 if(pAdapter != NULL)
2410 {
2411 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2412 complete(&pAdapter->session_open_comp_var);
2413 }
2414 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002415
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002416#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002417 /* We did pre-auth,then we attempted a 11r or ccx reassoc.
2418 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07002419 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07002420 * interface down */
2421 case eCSR_ROAM_FT_REASSOC_FAILED:
Arif Hussain6d2a3322013-11-17 19:50:10 -08002422 hddLog(LOG1, FL("Reassoc Failed"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002423 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2424 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2425 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002426 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2427 }
2428 pHddStaCtx->ft_carrier_on = FALSE;
2429 break;
2430
2431 case eCSR_ROAM_FT_START:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002432 // When we roam for CCX and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07002434 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07002435 // eCSR_ROAM_SHOULD_ROAM will be received.
2436 // Where in we will not mark the link down
2437 // Also we want to stop tx at this point when we will be
2438 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002439 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002440 {
2441 struct net_device *dev = pAdapter->dev;
2442 netif_tx_disable(dev);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002443 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002444 * Deregister for this STA with TL with the objective to flush
2445 * all the packets for this STA from wmm_tx_queue. If not done here,
2446 * we would run into a race condition (CR390567) wherein TX
2447 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2448 * been deleted. And, these packets get assigned with a STA idx of
2449 * self-sta (since the peer STA has been deleted) and get transmitted
2450 * on the new channel before the reassoc request. Since there will be
2451 * no ACK on the new channel, each packet gets retransmitted which
2452 * takes several seconds before the transmission of reassoc request.
2453 * This leads to reassoc-timeout and roam failure.
2454 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002455 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2456 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2457 {
2458 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2459 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2460 pHddStaCtx->conn_info.staId[0], status, status );
2461 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002462 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002463 }
2464 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002465 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002466 break;
2467#endif
2468
2469 case eCSR_ROAM_SHOULD_ROAM:
2470 // Dont need to do anything
2471 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002472 struct net_device *dev = pAdapter->dev;
2473 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2474 // notify apps that we can't pass traffic anymore
2475 netif_tx_disable(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002476#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002477 if (pHddStaCtx->ft_carrier_on == FALSE)
2478 {
2479#endif
2480 netif_carrier_off(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002481#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002482 }
2483#endif
2484
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002485#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002486 //We should clear all sta register with TL, for now, only one.
2487 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2488 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2489 {
2490 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2491 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2492 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002493 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002494 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002495#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002496 }
2497 break;
2498 case eCSR_ROAM_LOSTLINK:
2499 case eCSR_ROAM_DISASSOCIATED:
2500 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002501 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2502 "****eCSR_ROAM_DISASSOCIATED****");
2503 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2504 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07002505 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2506 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302507 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07002508 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08002509
2510 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
2511 pHddCtx->configuredMcastBcastFilter =
2512 pHddCtx->sus_res_mcastbcast_filter;
2513 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
2514 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302515
Amar Singhald53568e2013-09-26 11:03:45 -07002516 hddLog(VOS_TRACE_LEVEL_INFO,
2517 "offload: disassociation happening, restoring configuredMcastBcastFilter");
2518 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
2519 pHddCtx->configuredMcastBcastFilter);
2520 hddLog(VOS_TRACE_LEVEL_INFO,
2521 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07002522 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2523 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002524#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302525 /* Call to clear any MC Addr List filter applied after
2526 * successful connection.
2527 */
2528 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002529#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002530 }
2531 break;
2532 case eCSR_ROAM_IBSS_LEAVE:
2533 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2534 "****eCSR_ROAM_IBSS_LEAVE****");
2535 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2536 break;
2537 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2538 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2539 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Gopichand Nakkala29149562013-05-10 21:43:41 +05302540 if ( (roamResult != eCSR_ROAM_RESULT_ASSOCIATED) &&
2541 ( (pWextState->roamProfile.EncryptionType.encryptionType[0] ==
2542 eCSR_ENCRYPT_TYPE_WEP40) ||
2543 (pWextState->roamProfile.EncryptionType.encryptionType[0] ==
2544 eCSR_ENCRYPT_TYPE_WEP104)
2545 ) &&
2546 (eCSR_AUTH_TYPE_SHARED_KEY != pWextState->roamProfile.AuthType.authType[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07002547 )
2548 {
2549 v_U32_t roamId = 0;
2550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2551 "****WEP open authentication failed, trying with shared authentication****");
2552 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
2553 pWextState->roamProfile.AuthType.authType[0] = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2554 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
2555 halStatus = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &(pWextState->roamProfile), &roamId);
2556 }
2557 else
2558 {
James Zmuda7019bb32013-10-25 10:29:37 -07002559 // Clear saved connection information in HDD
2560 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07002561 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2562 }
2563
2564 break;
2565 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002566 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002567 pRoamInfo, roamId, roamStatus, roamResult );
2568 break;
2569 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07002570 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
2571 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002572 break;
2573
2574 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2575 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002576 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002577
2578 case eCSR_ROAM_MIC_ERROR_IND:
2579 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2580 break;
2581
2582 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002583 {
2584 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2585
2586 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002587 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
2588 (TRUE == pHddCtx->hdd_wlan_suspended) &&
2589 (eCSR_ROAM_RESULT_NONE == roamResult))
2590 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002591 /* Send DTIM period to the FW; only if the wlan is already
2592 in suspend. This is the case with roaming (reassoc),
2593 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
2594 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
2595 before the ENTER_BMPS_REQ ensures Listen Interval is
2596 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002597 hdd_set_pwrparams(pHddCtx);
2598 pHddStaCtx->hdd_ReassocScenario = VOS_FALSE;
2599
2600 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002601 if due to unexpected scenario, if we are in BMPS,
2602 then trigger Exit and Enter BMPS to take DTIM period
2603 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002604 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
2605 {
2606 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
2607
2608 /* put the device into full power */
2609 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
2610
2611 /* put the device back into BMPS */
2612 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
2613 }
2614 }
2615 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2616 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 break;
2618#ifdef WLAN_FEATURE_VOWIFI_11R
2619 case eCSR_ROAM_FT_RESPONSE:
2620 hdd_SendFTEvent(pAdapter);
2621 break;
2622#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002623#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002624 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002625 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07002626 {
2627 /* Notify the supplicant of a new candidate */
2628 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
2629 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002630 break;
2631#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002632
Yue Maef608272013-04-08 23:09:17 -07002633#ifdef FEATURE_WLAN_LFR_METRICS
2634 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
2635 /* This event is to notify pre-auth initiation */
2636 if (VOS_STATUS_SUCCESS !=
2637 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
2638 {
2639 halStatus = eHAL_STATUS_FAILURE;
2640 }
2641 break;
2642 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
2643 /* This event will notify pre-auth completion in case of success */
2644 if (VOS_STATUS_SUCCESS !=
2645 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2646 pRoamInfo, 1))
2647 {
2648 halStatus = eHAL_STATUS_FAILURE;
2649 }
2650 break;
2651 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
2652 /* This event will notify pre-auth completion in case of failure. */
2653 if (VOS_STATUS_SUCCESS !=
2654 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
2655 pRoamInfo, 0))
2656 {
2657 halStatus = eHAL_STATUS_FAILURE;
2658 }
2659 break;
2660 case eCSR_ROAM_HANDOVER_SUCCESS:
2661 /* This event is to notify handover success.
2662 It will be only invoked on success */
2663 if (VOS_STATUS_SUCCESS !=
2664 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
2665 {
2666 halStatus = eHAL_STATUS_FAILURE;
2667 }
2668 break;
2669#endif
2670
Jeff Johnson295189b2012-06-20 16:38:30 -07002671 case eCSR_ROAM_INDICATE_MGMT_FRAME:
2672 hdd_indicateMgmtFrame( pAdapter,
2673 pRoamInfo->nFrameLength,
2674 pRoamInfo->pbFrames,
2675 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05302676 pRoamInfo->rxChan,
2677 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07002678 break;
2679 case eCSR_ROAM_REMAIN_CHAN_READY:
2680 hdd_remainChanReadyHandler( pAdapter );
2681 break;
2682 case eCSR_ROAM_SEND_ACTION_CNF:
2683 hdd_sendActionCnf( pAdapter,
2684 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
2685 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002686#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08002687 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002688 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08002689 roamId, roamStatus, roamResult );
2690 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002691 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
2692 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
2693 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002694#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002695#ifdef WLAN_FEATURE_11W
2696 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
2697 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
2698 pRoamInfo->pbFrames,
2699 pRoamInfo->frameType);
2700 break;
2701#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002702#if defined(FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
2703 case eCSR_ROAM_TSM_IE_IND:
2704 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
2705 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
2706 break;
2707
2708 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
2709 {
2710 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
2711 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
2712 {
2713 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
2714 }
2715 break;
2716 }
2717
2718 case eCSR_ROAM_CCX_ADJ_AP_REPORT_IND:
2719 {
2720 hdd_indicateCcxAdjApRepInd(pAdapter, pRoamInfo);
2721 break;
2722 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08002723
2724 case eCSR_ROAM_CCX_BCN_REPORT_IND:
2725 {
2726 hdd_indicateCcxBcnReportInd(pAdapter, pRoamInfo);
2727 break;
2728 }
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07002729#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
Jeff Johnson295189b2012-06-20 16:38:30 -07002730 default:
2731 break;
2732 }
2733 return( halStatus );
2734}
Shailender Karmuchia734f332013-04-19 14:02:48 -07002735eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002736{
2737 eCsrAuthType auth_type;
2738 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002739 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002740 {
2741 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002742 } else
2743 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002744 {
2745 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002746 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002747#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07002748 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002749 {
2750 // Check for 11r FT Authentication with PSK
2751 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002752 } else
2753 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002754 {
2755 // Check for 11R FT Authentication with 802.1X
2756 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002757 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002758#endif
2759#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002760 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002761 {
2762 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
2763 } else
2764#endif /* FEATURE_WLAN_CCX */
Chet Lanctot186b5732013-03-18 10:26:30 -07002765#ifdef WLAN_FEATURE_11W
2766 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
2767 {
2768 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
2769 } else
2770#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002771 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002772 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2773 }
2774 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002775}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002776
Shailender Karmuchia734f332013-04-19 14:02:48 -07002777eCsrAuthType
2778hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002779{
2780 eCsrAuthType auth_type;
2781 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002782 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002783 {
2784 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002785 } else
2786 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002787 {
2788 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002789 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002790#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002791 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002792 {
2793 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002794 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002795#endif /* FEATURE_WLAN_CCX */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002796 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002797 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2798 }
2799 hddLog(LOG1, FL("auth_type: %d"), auth_type);
2800 return auth_type;
2801}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002802
Shailender Karmuchia734f332013-04-19 14:02:48 -07002803eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07002804hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002805{
2806 eCsrEncryptionType cipher_type;
2807 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002808 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002809 {
2810 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002811 }
2812 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002813 {
2814 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002815 }
2816 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002817 {
2818 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002819 }
2820 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002821 {
2822 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002823 }
2824 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
2825 {
2826 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2827 }
2828 else
2829 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002830 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2831 }
2832 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2833 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002834}
Jeff Johnson295189b2012-06-20 16:38:30 -07002835/* To find if the MAC address is NULL */
2836static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
2837{
2838 int i;
2839 for (i = 0; i < length; i++)
2840 {
2841 if (0x00 != (macAddr[i]))
2842 {
2843 return FALSE;
2844 }
2845 }
2846 return TRUE;
2847} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08002848
Shailender Karmuchia734f332013-04-19 14:02:48 -07002849eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07002850hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002851{
2852 eCsrEncryptionType cipher_type;
2853 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002854 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002855 {
2856 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002857 } else
2858 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002859 {
2860 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002861 } else
2862 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002863 {
2864 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002865 } else
2866 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002867 {
2868 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002869 } else
2870 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002871 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002872 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2873 } else
2874 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002875 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2876 }
2877 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2878 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002879}
Jeff Johnson295189b2012-06-20 16:38:30 -07002880
Shailender Karmuchia734f332013-04-19 14:02:48 -07002881static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
2882 struct ether_addr *pBssid,
2883 eCsrEncryptionType *pEncryptType,
2884 eCsrEncryptionType *mcEncryptType,
2885 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07002886#ifdef WLAN_FEATURE_11W
2887 u_int8_t *pMfpRequired,
2888 u_int8_t *pMfpCapable,
2889#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002890 u_int16_t gen_ie_len,
2891 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07002892{
2893 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002894 eHalStatus result;
2895 tDot11fIERSN dot11RSNIE;
2896 tDot11fIEWPA dot11WPAIE;
2897 tANI_U32 i;
2898 tANI_U8 *pRsnIe;
2899 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002900 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07002901 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002902
2903 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
2904 flag to 0 */
2905 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
2906 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
2907
2908 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07002909 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
2910 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002911 return -EINVAL;
2912 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07002913 if ( gen_ie[0] == DOT11F_EID_RSN)
2914 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002915 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07002916 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002917 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
2918 {
2919 return -EINVAL;
2920 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002921 // Skip past the EID byte and length byte
2922 pRsnIe = gen_ie + 2;
2923 RSNIeLen = gen_ie_len - 2;
2924 // Unpack the RSN IE
2925 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
2926 pRsnIe,
2927 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07002928 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002929 // Copy out the encryption and authentication types
2930 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002931 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002932 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002933 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002934 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07002935 but probably I suspect we can do something different*/
2936 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07002937 // Just translate the FIRST one
2938 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
2939 //dot11RSNIE.pwise_cipher_suite_count
2940 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
2941 //dot11RSNIE.gp_cipher_suite_count
2942 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07002943#ifdef WLAN_FEATURE_11W
2944 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
2945 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
2946#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002947 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07002948 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002949 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002950 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002951 {
2952 break;
2953 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07002954 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07002955 {
2956 break;
2957 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07002958 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002959 // For right now, I assume setASSOCIATE() has passed in the bssid.
2960 vos_mem_copy(PMKIDCache[i].BSSID,
2961 pBssid, ETHER_ADDR_LEN);
2962 vos_mem_copy(PMKIDCache[i].PMKID,
2963 dot11RSNIE.pmkid[i],
2964 CSR_RSN_PMKID_SIZE);
2965 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07002966
2967 if (updatePMKCache)
2968 {
2969 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002970 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002971 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07002972 // Finally set the PMKSA ID Cache in CSR
2973 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
2974 PMKIDCache,
2975 dot11RSNIE.pmkid_count );
2976 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002977 }
2978 else if (gen_ie[0] == DOT11F_EID_WPA)
2979 {
2980 // Validity checks
2981 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
2982 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
2983 {
2984 return -EINVAL;
2985 }
2986 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07002987 pRsnIe = gen_ie + 2 + 4;
2988 RSNIeLen = gen_ie_len - (2 + 4);
2989 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07002990 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
2991 pRsnIe,
2992 RSNIeLen,
2993 &dot11WPAIE);
2994 // Copy out the encryption and authentication types
2995 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002996 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07002997 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002998 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07002999 //dot11WPAIE.auth_suite_count
3000 // Just translate the FIRST one
3001 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
3002 //dot11WPAIE.unicast_cipher_count
3003 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
3004 //dot11WPAIE.unicast_cipher_count
3005 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
3006 }
3007 else
3008 {
3009 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003010 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003011 }
3012 return 0;
3013}
3014int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
3015{
3016 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3017 v_U32_t status = 0;
3018 eCsrEncryptionType RSNEncryptType;
3019 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003020#ifdef WLAN_FEATURE_11W
3021 u_int8_t RSNMfpRequired;
3022 u_int8_t RSNMfpCapable;
3023#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003024 struct ether_addr bSsid; // MAC address of assoc peer
3025 // MAC address of assoc peer
3026 // But, this routine is only called when we are NOT associated.
3027 vos_mem_copy(bSsid.ether_addr_octet,
3028 pWextState->roamProfile.BSSIDs.bssid,
3029 sizeof(bSsid.ether_addr_octet));
3030 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
3031 {
3032 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07003033 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003034 else
3035 {
3036 return 0;
3037 }
3038 // The actual processing may eventually be more extensive than this.
3039 // Right now, just consume any PMKIDs that are sent in by the app.
3040 status = hdd_ProcessGENIE(pAdapter,
3041 &bSsid, // MAC address of assoc peer
3042 &RSNEncryptType,
3043 &mcRSNEncryptType,
3044 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07003045#ifdef WLAN_FEATURE_11W
3046 &RSNMfpRequired,
3047 &RSNMfpCapable,
3048#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07003049 pWextState->WPARSNIE[1]+2,
3050 pWextState->WPARSNIE);
3051 if (status == 0)
3052 {
3053 // Now copy over all the security attributes you have parsed out
3054 pWextState->roamProfile.EncryptionType.numEntries = 1;
3055 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003056
Jeff Johnson295189b2012-06-20 16:38:30 -07003057 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
3058 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07003059
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003060 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
3061 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
3062 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
3063 {
3064 /*For wpa none supplicant sends the WPA IE with unicast cipher as
3065 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
3066 either AES/TKIP based on group cipher configuration
3067 mentioned in the wpa_supplicant.conf.*/
3068
3069 /*Set the unicast cipher same as multicast cipher*/
3070 pWextState->roamProfile.EncryptionType.encryptionType[0]
3071 = mcRSNEncryptType;
3072 }
3073
Chet Lanctot186b5732013-03-18 10:26:30 -07003074#ifdef WLAN_FEATURE_11W
3075 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
3076 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
3077#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003078 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07003079 }
3080 return 0;
3081}
3082int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
3083{
3084 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3085 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
3086 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3087 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003088
Jeff Johnson295189b2012-06-20 16:38:30 -07003089 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08003090 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003091
Jeff Johnson295189b2012-06-20 16:38:30 -07003092 switch( pHddStaCtx->conn_info.authType)
3093 {
3094 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3095#ifdef FEATURE_WLAN_CCX
3096 case eCSR_AUTH_TYPE_CCKM_WPA:
3097 case eCSR_AUTH_TYPE_CCKM_RSN:
3098#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003099 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3100
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003102 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003103 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003104
Jeff Johnson295189b2012-06-20 16:38:30 -07003105#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07003106 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3107 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3108 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003109 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003110 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3111 } else
3112 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003113 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003114 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 } else
3116#endif
3117 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3118 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003119 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3120 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003121 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3122 == IW_AUTH_KEY_MGMT_PSK) {
3123 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003124 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003125 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003126 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003127 }
3128 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
3129#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07003130 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3131 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3132 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003133 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003134 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003136 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003137 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003138 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003139 } else
3140#endif
3141
3142#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003143 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3144 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003145 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003146 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003147 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003148 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003149 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3150 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003151 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 } else
3153#endif
3154
Chet Lanctot186b5732013-03-18 10:26:30 -07003155#ifdef WLAN_FEATURE_11W
3156 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3157 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3158 } else
3159#endif
3160
Shailender Karmuchia734f332013-04-19 14:02:48 -07003161 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003162 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003163 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3164 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003165 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3166 == IW_AUTH_KEY_MGMT_PSK) {
3167 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003168 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003169 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003170 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003171 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003172 break;
3173
Jeff Johnson295189b2012-06-20 16:38:30 -07003174 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003175
3176 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 break;
3178 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003179
Jeff Johnson295189b2012-06-20 16:38:30 -07003180#ifdef FEATURE_WLAN_CCX
Arif Hussain6d2a3322013-11-17 19:50:10 -08003181 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003182#endif /* FEATURE_WLAN_CCX */
3183 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3184 break;
3185 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003186
Jeff Johnson295189b2012-06-20 16:38:30 -07003187 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003188 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003189
Jeff Johnson295189b2012-06-20 16:38:30 -07003190 EXIT();
3191 return 0;
3192}
3193
3194/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003195
3196 \brief iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003197 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07003198 to the CSR roam profile.
3199
Jeff Johnson295189b2012-06-20 16:38:30 -07003200 \param - dev - Pointer to the net device.
3201 - info - Pointer to the iw_request_info.
3202 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003203 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003204 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003205
Jeff Johnson295189b2012-06-20 16:38:30 -07003206 --------------------------------------------------------------------------*/
3207
Shailender Karmuchia734f332013-04-19 14:02:48 -07003208int iw_set_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003209 struct iw_request_info *info,
3210 union iwreq_data *wrqu, char *extra)
3211{
3212 v_U32_t status = 0;
3213 hdd_wext_state_t *pWextState;
3214 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3215 v_U32_t roamId;
3216 tCsrRoamProfile *pRoamProfile;
3217 eMib_dot11DesiredBssType connectedBssType;
3218 eCsrAuthType RSNAuthType;
3219 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3220 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003221
3222 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3223
Jeff Johnson295189b2012-06-20 16:38:30 -07003224 ENTER();
3225
3226 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3227 {
3228 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3229 "%s:LOGP in Progress. Ignore!!!",__func__);
3230 return 0;
3231 }
3232
3233 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
3234 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
3235 return -EBUSY;
3236 }
3237 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
3238 return -EINVAL;
3239 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003240 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003241 {
3242 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
3243 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
3244 {
3245 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003246 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07003247 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3248 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
3249
3250 if(VOS_STATUS_SUCCESS == vosStatus)
3251 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3252 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3253 }
3254 }
3255 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003256 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003257 {
3258 return -EINVAL;
3259 }
3260 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003261 /** when cfg80211 defined, wpa_supplicant wext driver uses
3262 zero-length, null-string ssid for force disconnection.
3263 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07003264 driver MUST return success */
3265 if ( 0 == wrqu->essid.length ) {
3266 return 0;
3267 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003268
3269 status = hdd_wmm_get_uapsd_mask(pAdapter,
3270 &pWextState->roamProfile.uapsd_mask);
3271 if (VOS_STATUS_SUCCESS != status)
3272 {
3273 pWextState->roamProfile.uapsd_mask = 0;
3274 }
3275 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003276
Jeff Johnson295189b2012-06-20 16:38:30 -07003277 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003278
3279 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
3281 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
3282 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003283
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 //set gen ie
3285 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
3286
3287 //set auth
3288 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
3289 }
3290#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003291 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003292 if (pAdapter->wapi_info.nWapiMode)
3293 {
3294 switch (pAdapter->wapi_info.wapiAuthMode)
3295 {
3296 case WAPI_AUTH_MODE_PSK:
3297 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003298 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003299 pRoamProfile->AuthType.numEntries = 1;
3300 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3301 break;
3302 }
3303 case WAPI_AUTH_MODE_CERT:
3304 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003305 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003306 pRoamProfile->AuthType.numEntries = 1;
3307 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3308 break;
3309 }
3310 } // End of switch
3311 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
3312 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
3313 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003314 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003315 pRoamProfile->EncryptionType.numEntries = 1;
3316 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3317 pRoamProfile->mcEncryptionType.numEntries = 1;
3318 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3319 }
3320 }
3321#endif /* FEATURE_WLAN_WAPI */
3322 /* if previous genIE is not NULL, update AssocIE */
3323 if (0 != pWextState->genIE.length)
3324 {
3325 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
3326 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
3327 pWextState->genIE.length);
3328 pWextState->assocAddIE.length = pWextState->genIE.length;
3329 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
3330 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
3331
3332 /* clear previous genIE after use it */
3333 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
3334 }
3335
3336 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
3337 pWextState->roamProfile.bWPSAssociation = FALSE;
3338
3339 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
3340 pWextState->roamProfile.nAddIEAssocLength))
3341 pWextState->roamProfile.bWPSAssociation = TRUE;
3342
3343
3344 // Disable auto BMPS entry by PMC until DHCP is done
3345 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
3346
Shailender Karmuchia734f332013-04-19 14:02:48 -07003347 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003349
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003350 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
3351 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003352 hdd_select_cbmode(pAdapter,
3353 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
3354 }
3355 status = sme_RoamConnect( hHal,pAdapter->sessionId,
3356 &(pWextState->roamProfile), &roamId);
3357 pRoamProfile->ChannelInfo.ChannelList = NULL;
3358 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003359
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003360 EXIT();
3361 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003362}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003363
Jeff Johnson295189b2012-06-20 16:38:30 -07003364/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003365
3366 \brief iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003367 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003368
Jeff Johnson295189b2012-06-20 16:38:30 -07003369 \param - dev - Pointer to the net device.
3370 - info - Pointer to the iw_request_info.
3371 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003372 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003373 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003374
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 --------------------------------------------------------------------------*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003376int iw_get_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003377 struct iw_request_info *info,
3378 struct iw_point *dwrq, char *extra)
3379{
3380 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003381 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003382 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3383 ENTER();
3384
3385 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
3386 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
3387 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
3388 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
3389 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
3390 {
3391 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
3392 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
3393 dwrq->flags = 1;
3394 } else {
3395 memset(extra, 0, dwrq->length);
3396 dwrq->length = 0;
3397 dwrq->flags = 0;
3398 }
3399 EXIT();
3400 return 0;
3401}
3402/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003403
3404 \brief iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003405 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003406
Jeff Johnson295189b2012-06-20 16:38:30 -07003407 \param - dev - Pointer to the net device.
3408 - info - Pointer to the iw_request_info.
3409 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003410 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003411 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003412
Jeff Johnson295189b2012-06-20 16:38:30 -07003413 --------------------------------------------------------------------------*/
3414int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
3415 union iwreq_data *wrqu,char *extra)
3416{
3417 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003418 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003419 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3420 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003421 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 eCsrEncryptionType ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003423
Jeff Johnson295189b2012-06-20 16:38:30 -07003424 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003425
3426 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3427 {
3428 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3429 "%s:LOGP in Progress. Ignore!!!", __func__);
3430 return -EBUSY;
3431 }
3432
Jeff Johnson295189b2012-06-20 16:38:30 -07003433 switch(wrqu->param.flags & IW_AUTH_INDEX)
3434 {
3435 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003436
Jeff Johnson295189b2012-06-20 16:38:30 -07003437 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003438
Jeff Johnson295189b2012-06-20 16:38:30 -07003439 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003440
Jeff Johnson295189b2012-06-20 16:38:30 -07003441 case IW_AUTH_CIPHER_PAIRWISE:
3442 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003443 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003444 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003445 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003446 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3447 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003448 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003449 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
3450 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003451 }
3452
Jeff Johnson295189b2012-06-20 16:38:30 -07003453 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003454
3455 if( (IW_AUTH_KEY_MGMT_802_1X
3456 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
3458 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003459 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07003460 else
3461 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003462 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3463 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003464 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003465
3466 if( ( IW_AUTH_KEY_MGMT_802_1X
3467 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003468 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3469 /*Dynamic WEP key*/
3470 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3471 else
3472 /*Static WEP key*/
3473 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003474
Jeff Johnson295189b2012-06-20 16:38:30 -07003475 }
3476 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003477
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003479 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003480 return -EINVAL;
3481 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003482
Jeff Johnson295189b2012-06-20 16:38:30 -07003483 pRoamProfile->EncryptionType.numEntries = 1;
3484 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003485 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003486 break;
3487 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003488 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003489 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
3490 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3491 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003492
Jeff Johnson295189b2012-06-20 16:38:30 -07003493 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3494 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
3495 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003496
3497 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
3499 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003500
Jeff Johnson295189b2012-06-20 16:38:30 -07003501 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003502
3503 if( ( IW_AUTH_KEY_MGMT_802_1X
3504 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
3505 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3506
Jeff Johnson295189b2012-06-20 16:38:30 -07003507 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003508
3509 else
3510 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003512
3513 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
3514 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003515 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003516 if( ( IW_AUTH_KEY_MGMT_802_1X
3517 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003518 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3519 {
3520 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3521 }
3522 else
3523 {
3524 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3525 }
3526 }
3527 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003528
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003530 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003531 return -EINVAL;
3532 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003533
Jeff Johnson295189b2012-06-20 16:38:30 -07003534 pRoamProfile->mcEncryptionType.numEntries = 1;
3535 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
3536 }
3537 break;
3538
3539 case IW_AUTH_80211_AUTH_ALG:
3540 {
3541 /*Save the auth algo here and set auth type to SME Roam profile
3542 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003543 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003545
Jeff Johnson295189b2012-06-20 16:38:30 -07003546 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
3547 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
3548
3549 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
3550 /*Not supported*/
3551 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3552 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
3553 }
3554 break;
3555
3556 case IW_AUTH_KEY_MGMT:
3557 {
3558#ifdef FEATURE_WLAN_CCX
3559#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
3560 /*Check for CCKM AKM type */
3561 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08003562 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
3563 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003564 /* Set the CCKM bit in authKeyMgmt */
3565 /* Right now, this breaks all ref to authKeyMgmt because our
3566 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07003567 */
3568 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
3569 /*Set the key management to 802.1X*/
3570 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
3571 pWextState->isCCXConnection = eANI_BOOLEAN_TRUE;
3572 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3573 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3574 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
3575 /*Save the key management*/
3576 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
3577 //pWextState->authKeyMgmt = wrqu->param.value;
3578 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3579 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3580 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
3581 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
3582 /*Save the key management anyway*/
3583 pWextState->authKeyMgmt = wrqu->param.value;
3584 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
3585 /*Save the key management*/
3586 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
3587 //pWextState->authKeyMgmt = wrqu->param.value;
3588 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3589 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3590 }
3591#else
3592 /*Save the key management*/
3593 pWextState->authKeyMgmt = wrqu->param.value;
3594#endif /* FEATURE_WLAN_CCX */
3595 }
3596 break;
3597
3598 case IW_AUTH_TKIP_COUNTERMEASURES:
3599 {
3600 if(wrqu->param.value) {
3601 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3602 "Counter Measure started %d", wrqu->param.value);
3603 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
3604 }
3605 else {
3606 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3607 "Counter Measure stopped=%d", wrqu->param.value);
3608 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3609 }
3610 }
3611 break;
3612 case IW_AUTH_DROP_UNENCRYPTED:
3613 case IW_AUTH_WPA_ENABLED:
3614 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3615 case IW_AUTH_ROAMING_CONTROL:
3616 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003617
Jeff Johnson295189b2012-06-20 16:38:30 -07003618 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003619
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003620 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003621 wrqu->param.flags & IW_AUTH_INDEX);
3622 break;
3623 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003624
Jeff Johnson295189b2012-06-20 16:38:30 -07003625 EXIT();
3626 return 0;
3627}
3628/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003629
3630 \brief iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003631 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003632
Jeff Johnson295189b2012-06-20 16:38:30 -07003633 \param - dev - Pointer to the net device.
3634 - info - Pointer to the iw_request_info.
3635 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003636 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003637 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003638
Jeff Johnson295189b2012-06-20 16:38:30 -07003639 --------------------------------------------------------------------------*/
3640int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
3641 union iwreq_data *wrqu,char *extra)
3642{
3643 hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003644 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003645 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3646 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003647
3648 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3649 {
3650 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3651 "%s:LOGP in Progress. Ignore!!!", __func__);
3652 return -EBUSY;
3653 }
3654
Jeff Johnson295189b2012-06-20 16:38:30 -07003655 switch(pRoamProfile->negotiatedAuthType)
3656 {
3657 case eCSR_AUTH_TYPE_WPA_NONE:
3658 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3659 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
3660 break;
3661 case eCSR_AUTH_TYPE_WPA:
3662 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3663 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
3664 break;
3665#ifdef WLAN_FEATURE_VOWIFI_11R
3666 case eCSR_AUTH_TYPE_FT_RSN:
3667#endif
3668 case eCSR_AUTH_TYPE_RSN:
3669 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3670 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
3671 break;
3672 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3673 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3674 break;
3675 case eCSR_AUTH_TYPE_SHARED_KEY:
3676 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
3677 break;
3678 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003679 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003680 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3681 break;
3682 case eCSR_AUTH_TYPE_AUTOSWITCH:
3683 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3684 break;
3685 case eCSR_AUTH_TYPE_WPA_PSK:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003686 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003687 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3688 return -EIO;
3689#ifdef WLAN_FEATURE_VOWIFI_11R
3690 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3691#endif
3692 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07003693#ifdef WLAN_FEATURE_11W
3694 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3695#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003696 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003697 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3698 return -EIO;
3699 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003700 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003701 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3702 return -EIO;
3703 }
3704 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
3705 {
3706 switch(pRoamProfile->negotiatedUCEncryptionType)
3707 {
3708 case eCSR_ENCRYPT_TYPE_NONE:
3709 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3710 break;
3711 case eCSR_ENCRYPT_TYPE_WEP40:
3712 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3713 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3714 break;
3715 case eCSR_ENCRYPT_TYPE_TKIP:
3716 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3717 break;
3718 case eCSR_ENCRYPT_TYPE_WEP104:
3719 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3720 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3721 break;
3722 case eCSR_ENCRYPT_TYPE_AES:
3723 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3724 break;
3725 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003726 hddLog(LOG1, "%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003727 return -EIO;
3728 }
3729 }
3730
Shailender Karmuchia734f332013-04-19 14:02:48 -07003731 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07003732 {
3733 switch(pRoamProfile->negotiatedMCEncryptionType)
3734 {
3735 case eCSR_ENCRYPT_TYPE_NONE:
3736 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3737 break;
3738 case eCSR_ENCRYPT_TYPE_WEP40:
3739 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3740 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3741 break;
3742 case eCSR_ENCRYPT_TYPE_TKIP:
3743 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3744 break;
3745 case eCSR_ENCRYPT_TYPE_WEP104:
3746 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3747 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3748 break;
3749 case eCSR_ENCRYPT_TYPE_AES:
3750 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3751 break;
3752 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003753 hddLog(LOG1, "%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003754 return -EIO;
3755 }
3756 }
3757
3758 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003759 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003760 EXIT();
3761 return 0;
3762}
3763/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003764
3765 \brief iw_set_ap_address() -
3766 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07003767 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003768
Jeff Johnson295189b2012-06-20 16:38:30 -07003769 \param - dev - Pointer to the net device.
3770 - info - Pointer to the iw_request_info.
3771 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003772 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003773 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003774
Jeff Johnson295189b2012-06-20 16:38:30 -07003775 --------------------------------------------------------------------------*/
3776int iw_set_ap_address(struct net_device *dev,
3777 struct iw_request_info *info,
3778 union iwreq_data *wrqu, char *extra)
3779{
3780 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3781 v_U8_t *pMacAddress=NULL;
3782 ENTER();
3783 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08003784 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
3785 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07003786 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
3787 EXIT();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003788
Jeff Johnson295189b2012-06-20 16:38:30 -07003789 return 0;
3790}
3791/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003792
3793 \brief iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003794 This function returns the BSSID to the wpa_supplicant
3795 \param - dev - Pointer to the net device.
3796 - info - Pointer to the iw_request_info.
3797 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003798 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003799 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003800
Jeff Johnson295189b2012-06-20 16:38:30 -07003801 --------------------------------------------------------------------------*/
3802int iw_get_ap_address(struct net_device *dev,
3803 struct iw_request_info *info,
3804 union iwreq_data *wrqu, char *extra)
3805{
3806 //hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3807 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3808
3809 ENTER();
3810
3811 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
3812 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
3813 {
Jeff Johnson4416a782013-03-25 14:17:50 -07003814 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003815 }
3816 else
3817 {
3818 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
3819 }
3820 EXIT();
3821 return 0;
3822}
Jeff Johnsond13512a2012-07-17 11:42:19 -07003823
Chet Lanctot186b5732013-03-18 10:26:30 -07003824#ifdef WLAN_FEATURE_11W
3825/**---------------------------------------------------------------------------
3826
3827 \brief hdd_indicateUnprotMgmtFrame -
3828 This function forwards the unprotected management frame to the supplicant
3829 \param - pAdapter - Pointer to HDD adapter
3830 - nFrameLength - Length of the unprotected frame being passed
3831 - pbFrames - Pointer to the frame buffer
3832 - frameType - 802.11 frame type
3833 \return - nothing
3834
3835 --------------------------------------------------------------------------*/
3836void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
3837 tANI_U32 nFrameLength,
3838 tANI_U8* pbFrames,
3839 tANI_U8 frameType )
3840{
3841 tANI_U8 type = 0;
3842 tANI_U8 subType = 0;
3843
3844 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
3845 __func__, frameType, nFrameLength);
3846
3847 /* Sanity Checks */
3848 if (NULL == pAdapter)
3849 {
3850 hddLog( LOGE, FL("pAdapter is NULL"));
3851 return;
3852 }
3853
3854 if (NULL == pAdapter->dev)
3855 {
3856 hddLog( LOGE, FL("pAdapter->dev is NULL"));
3857 return;
3858 }
3859
3860 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
3861 {
3862 hddLog( LOGE, FL("pAdapter has invalid magic"));
3863 return;
3864 }
3865
3866 if( !nFrameLength )
3867 {
3868 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
3869 return;
3870 }
3871
3872 if (NULL == pbFrames) {
3873 hddLog( LOGE, FL("pbFrames is NULL"));
3874 return;
3875 }
3876
3877 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
3878 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
3879
3880 /* Get pAdapter from Destination mac address of the frame */
3881 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
3882 {
3883 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
3884 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
3885 }
3886 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
3887 {
3888 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
3889 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
3890 }
3891 else
3892 {
3893 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
3894 return;
3895 }
3896}
3897#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003898
3899#if defined (FEATURE_WLAN_CCX) && defined(FEATURE_WLAN_CCX_UPLOAD)
3900void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
3901 tANI_U8 state,
3902 tANI_U16 measInterval )
3903{
3904 union iwreq_data wrqu;
3905 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08003906 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003907
3908 if (NULL == pAdapter)
3909 return;
3910
3911 // create the event
3912 memset(&wrqu, '\0', sizeof(wrqu));
3913 memset(buf, '\0', sizeof(buf));
3914
3915 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
3916 tid, state, measInterval);
3917
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08003918 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003919
3920 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08003921 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003922 // send the event
3923 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3924}
3925
3926void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
3927{
3928 union iwreq_data wrqu;
3929 char buf[IW_CUSTOM_MAX + 1];
3930 char *pos = buf;
3931 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
3932
3933 if ((NULL == pAdapter) || (NULL == pRoamInfo))
3934 return;
3935
3936 // create the event
3937 memset(&wrqu, '\0', sizeof(wrqu));
3938 memset(buf, '\0', sizeof(buf));
3939
3940 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arif Hussain24bafea2013-11-15 15:10:03 -08003941 hddLog(VOS_TRACE_LEVEL_ERROR, "CCXPREAUTHNOTIFY=" MAC_ADDRESS_STR " %lu:%lu",
3942 MAC_ADDR_ARRAY(pRoamInfo->bssid),
3943 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003944
3945 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
3946 pos += nBytes;
3947 freeBytes -= nBytes;
3948
3949 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
3950 pos += WNI_CFG_BSSID_LEN;
3951 freeBytes -= WNI_CFG_BSSID_LEN;
3952
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08003953 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
3954 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003955
3956 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08003957 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003958
3959 // send the event
3960 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3961}
3962
3963void hdd_indicateCcxAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
3964{
3965 union iwreq_data wrqu;
3966 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08003967 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003968
3969 if ((NULL == pAdapter) || (NULL == pRoamInfo))
3970 return;
3971
3972 // create the event
3973 memset(&wrqu, '\0', sizeof(wrqu));
3974 memset(buf, '\0', sizeof(buf));
3975
3976 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
3977
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08003978 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003979
3980 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08003981 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07003982
3983 // send the event
3984 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
3985}
3986
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08003987void hdd_indicateCcxBcnReportInd(const hdd_adapter_t *pAdapter,
3988 const tCsrRoamInfo *pRoamInfo)
3989{
3990 union iwreq_data wrqu;
3991 char buf[IW_CUSTOM_MAX + 1];
3992 char *pos = buf;
3993 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
3994 tANI_U8 i = 0, len = 0;
3995 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
3996 tANI_U8 lastSent = 0, sendBss = 0;
3997 int bcnRepFieldSize = sizeof(pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
3998
3999 if ((NULL == pAdapter) || (NULL == pRoamInfo))
4000 return;
4001
4002 /* Custom event can pass maximum of 256 bytes of data,
4003 based on the IE len we need to identify how many BSS info can
4004 be filled in to custom event data */
4005 /*
4006 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
4007 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
4008 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
4009 */
4010
4011 if ((pRoamInfo->pCcxBcnReportRsp->flag >> 1) && (!pRoamInfo->pCcxBcnReportRsp->numBss))
4012 {
4013 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
4014 /* If the measurement is none and no scan results found,
4015 indicate the supplicant about measurement done */
4016 memset(&wrqu, '\0', sizeof(wrqu));
4017 memset(buf, '\0', sizeof(buf));
4018
4019 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
4020 pRoamInfo->pCcxBcnReportRsp->measurementToken, pRoamInfo->pCcxBcnReportRsp->flag,
4021 pRoamInfo->pCcxBcnReportRsp->numBss, tot_bcn_ieLen);
4022
4023 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d",
4024 pRoamInfo->pCcxBcnReportRsp->measurementToken, pRoamInfo->pCcxBcnReportRsp->flag,
4025 pRoamInfo->pCcxBcnReportRsp->numBss);
4026
4027 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08004028 wrqu.data.length = nBytes;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004029 // send the event
4030 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4031 }
4032 else
4033 {
4034 while (lastSent < pRoamInfo->pCcxBcnReportRsp->numBss)
4035 {
4036 memset(&wrqu, '\0', sizeof(wrqu));
4037 memset(buf, '\0', sizeof(buf));
4038 tot_bcn_ieLen = 0;
4039 sendBss = 0;
4040 pos = buf;
4041 freeBytes = IW_CUSTOM_MAX;
4042
4043 for (i = lastSent; i < pRoamInfo->pCcxBcnReportRsp->numBss; i++)
4044 {
4045 len = bcnRepFieldSize + 1 + pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i].ieLen;
4046 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - 18))
4047 {
4048 break;
4049 }
4050 tot_bcn_ieLen += len;
4051 sendBss++;
4052 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
4053 "IeLength(%d) Length of Ie(%d) totLen(%d)",
4054 i, bcnRepFieldSize, 1,
4055 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i].ieLen,
4056 tot_bcn_ieLen);
4057 }
4058
4059 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
4060 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
4061 pRoamInfo->pCcxBcnReportRsp->measurementToken, pRoamInfo->pCcxBcnReportRsp->flag,
4062 pRoamInfo->pCcxBcnReportRsp->numBss, tot_bcn_ieLen);
4063
4064 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
4065 pRoamInfo->pCcxBcnReportRsp->measurementToken, pRoamInfo->pCcxBcnReportRsp->flag,
4066 pRoamInfo->pCcxBcnReportRsp->numBss);
4067 pos += nBytes;
4068 freeBytes -= nBytes;
4069
4070 /* Copy total Beacon report data length */
4071 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
4072 pos += sizeof(tot_bcn_ieLen);
4073 freeBytes -= sizeof(tot_bcn_ieLen);
4074
4075 for (i = 0; i < sendBss; i++)
4076 {
4077 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
4078 " PhyType(%d) RecvSigPower(%d) ParentTSF(%lu)"
4079 " TargetTSF[0](%lu) TargetTSF[1](%lu) BeaconInterval(%u)"
4080 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
4081 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
4082 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
4083 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
4084 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
4085 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
4086 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
4087 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
4088 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
4089 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
4090 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
4091 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
4092 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
4093 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
4094 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
4095 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
4096 pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
4097
4098 /* bcn report fields are copied */
4099 len = sizeof(pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
4100 vos_mem_copy(pos, (char*)&pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
4101 pos += len;
4102 freeBytes -= len;
4103
4104 /* Add 1 byte of ie len */
4105 len = pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
4106 vos_mem_copy(pos, (char*)&len, sizeof(len));
4107 pos += sizeof(len);
4108 freeBytes -= sizeof(len);
4109
4110 /* copy IE from scan results */
4111 vos_mem_copy(pos, (char*)pRoamInfo->pCcxBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
4112 pos += len;
4113 freeBytes -= len;
4114 }
4115
4116 wrqu.data.pointer = buf;
4117 wrqu.data.length = strlen(buf);
4118
4119 // send the event
4120 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
4121 lastSent += sendBss;
4122 }
4123 }
4124}
4125
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004126#endif /* FEATURE_WLAN_CCX && FEATURE_WLAN_CCX_UPLOAD */
4127