blob: 223ed4c0a3799f3c97aceac8e2c6b38dec483c31 [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
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530128static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
129 tCsrRoamInfo *pRoamInfo,
130 tANI_U32 roamId,
131 eRoamCmdStatus roamStatus,
132 eCsrRoamResult roamResult );
133
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530134v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
135 eConnectionState connState )
136{
137 // save the new connection state
Jeff Johnson295189b2012-06-20 16:38:30 -0700138 pHddStaCtx->conn_info.connState = connState;
139}
140
141// returns FALSE if not connected.
142// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
143// returns the connection state. Can specify NULL if you dont' want to get the actual state.
144
Shailender Karmuchia734f332013-04-19 14:02:48 -0700145static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
146 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700147{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700148 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700149 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700150
Jeff Johnson295189b2012-06-20 16:38:30 -0700151 // get the connection state.
152 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700153 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700154 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700155 eConnectionState_IbssConnected == connState ||
156 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700157 {
158 fConnected = VOS_TRUE;
159 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700160 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700161 {
162 fConnected = VOS_FALSE;
163 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700164
Jeff Johnson295189b2012-06-20 16:38:30 -0700165 if ( pConnState )
166 {
167 *pConnState = connState;
168 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700169
Jeff Johnson295189b2012-06-20 16:38:30 -0700170 return( fConnected );
171}
172
173v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
174{
175 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700176}
Jeff Johnson295189b2012-06-20 16:38:30 -0700177
178//TODO - Not used anyhwere. Can be removed.
179#if 0
180//
181v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
182{
183 v_BOOL_t fConnectedInfra = FALSE;
184 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700185
Jeff Johnson295189b2012-06-20 16:38:30 -0700186 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700187 {
188 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700189 {
190 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700191 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700192 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700193
Jeff Johnson295189b2012-06-20 16:38:30 -0700194 return( fConnectedInfra );
195}
196#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700197
Jeff Johnson295189b2012-06-20 16:38:30 -0700198static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
199{
200 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700201
Jeff Johnson295189b2012-06-20 16:38:30 -0700202 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700203
204 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700205 {
206 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
207 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700208
Jeff Johnson295189b2012-06-20 16:38:30 -0700209 return( fConnected );
210}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700211
Jeff Johnson295189b2012-06-20 16:38:30 -0700212inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
213{
214 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700215
Jeff Johnson295189b2012-06-20 16:38:30 -0700216 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700217
218 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700219 {
220 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
221 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700222
Jeff Johnson295189b2012-06-20 16:38:30 -0700223 return( fConnected );
224}
225
226static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
227{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700228 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700229 {
230 case eCSR_BSS_TYPE_INFRASTRUCTURE:
231 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
232 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700233
Jeff Johnson295189b2012-06-20 16:38:30 -0700234 case eCSR_BSS_TYPE_IBSS:
235 case eCSR_BSS_TYPE_START_IBSS:
236 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
237 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700238
239 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700240 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700241 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700242 default:
243 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700244 break;
245 }
246
Jeff Johnson295189b2012-06-20 16:38:30 -0700247}
248
249void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
250{
251 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
252 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700253
Jeff Johnson295189b2012-06-20 16:38:30 -0700254 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700255
256 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700257 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700258 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700259 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
260 {
261 VOS_ASSERT( pRoamInfo->pBssDesc );
262 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
263
264 // Save the Station ID for this station from the 'Roam Info'.
265 //For IBSS mode, staId is assigned in NEW_PEER_IND
266 //For reassoc, the staID doesn't change and it may be invalid in this structure
267 //so no change here.
268 if( !pRoamInfo->fReassocReq )
269 {
270 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
271 }
272 }
273 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700274 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700276 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700277 else
278 {
279 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
280 // or we can't function.
281 VOS_ASSERT( 0 );
282 }
283
284 // notify WMM
285 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
286
287 if( !pRoamInfo->u.pConnectedProfile )
288 {
289 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
290 }
291 else
292 {
293 // Get Multicast Encryption Type
294 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
295 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
296 // Get Unicast Encrytion Type
297 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
298 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
299
300 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
301
302 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
303
304 // Save the ssid for the connection
305 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530306
307 // Save dot11mode in which STA associated to AP
308 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Jeff Johnson295189b2012-06-20 16:38:30 -0700309 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700310 }
311
Jeff Johnson295189b2012-06-20 16:38:30 -0700312 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700313 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
314
Jeff Johnson295189b2012-06-20 16:38:30 -0700315}
316
317#if defined(WLAN_FEATURE_VOWIFI_11R)
318/*
319 * Send the 11R key information to the supplicant.
320 * Only then can the supplicant generate the PMK-R1.
321 * (BTW, the CCX supplicant also needs the Assoc Resp IEs
322 * for the same purpose.)
323 *
324 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
325 * this contains the R1KHID, R0KHID and the MDID.
326 * For FT, this consists of the Reassoc Rsp FTIEs.
327 * This is the Assoc Response.
328 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700329static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700330 tCsrRoamInfo *pCsrRoamInfo)
331{
332 union iwreq_data wrqu;
333 char *buff;
334 unsigned int len = 0;
335 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700336
337 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700338 {
339 hddLog(LOGE,
340 "%s: pCsrRoamInfo->nAssocRspLength=%d",
341 __func__, (int)pCsrRoamInfo->nAssocRspLength);
342 return;
343 }
344
Shailender Karmuchia734f332013-04-19 14:02:48 -0700345 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700346 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700347 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700348 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700349 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700350 return;
351 }
352
353 // pFTAssocRsp needs to point to the IEs
354 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
355 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
356 (unsigned int)pFTAssocRsp[0],
357 (unsigned int)pFTAssocRsp[1]);
358
359 // We need to send the IEs to the supplicant.
360 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700361 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700362 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700363 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700364 return;
365 }
366
367 // Send the Assoc Resp, the supplicant needs this for initial Auth.
368 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700369 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700370 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700371 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700372 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
373
374 kfree(buff);
375}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700376#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700377
378#ifdef WLAN_FEATURE_VOWIFI_11R
379
380/*---------------------------------------------------
381 *
382 * Send the FTIEs, RIC IEs during FT. This is eventually
383 * used to send the FT events to the supplicant
384 *
385 * At the reception of Auth2 we send the RIC followed
386 * by the auth response IEs to the supplicant.
387 * Once both are received in the supplicant, an FT
388 * event is generated to the supplicant.
389 *
390 *---------------------------------------------------
391 */
392void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
393{
Jeff Johnson295189b2012-06-20 16:38:30 -0700394 tANI_U16 auth_resp_len = 0;
395 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700396 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
397
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530398#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700399 struct cfg80211_ft_event_params ftEvent;
400 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
401 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
402 struct net_device *dev = pAdapter->dev;
403#else
404 char *buff;
405 union iwreq_data wrqu;
406 tANI_U16 str_len;
407#endif
408
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530409#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530410 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
411 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700412
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530413 sme_GetRICIEs( pHddCtx->hHal, (u8 *)ricIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800414 DOT11F_IE_FTINFO_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530415 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700416 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530417 hddLog(LOGW,
418 "%s: RIC IEs is of length 0 not sending RIC Information for now",
419 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700420 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700421
422 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530423 ftEvent.ric_ies_len = ric_ies_length;
424 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700425
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530426 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800427 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700428
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530429 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700430 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530431 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700432 return;
433 }
434
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530435 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530436
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530437 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700438
439 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
440 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
441
442 hddLog(LOG1, "%s ftEvent.ies_len %d",__FUNCTION__, ftEvent.ies_len);
443 hddLog(LOG1, "%s ftEvent.ric_ies_len %d",__FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530444 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800445 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
446 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
447 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700448
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530449 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700450
451#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530452 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -0700453 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530454 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700455 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530456 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700457 return;
458 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530459 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700460
Shailender Karmuchia734f332013-04-19 14:02:48 -0700461 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -0700462 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530463 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800464 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530465 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700466 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530467 hddLog(LOGW,
468 "%s: RIC IEs is of length 0 not sending RIC Information for now",
469 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700470 }
471 else
472 {
473 wrqu.data.length = str_len + ric_ies_length;
474 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
475 }
476
477 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530478 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700479 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530480 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
481 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700482
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530483 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700484 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530485 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700486 return;
487 }
488
489 wrqu.data.length = str_len + auth_resp_len;
490 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
491
492 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700493#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700494}
495
496#endif /* WLAN_FEATURE_VOWIFI_11R */
497
498#ifdef FEATURE_WLAN_CCX
499
500/*
501 * Send the CCX required "new AP Channel info" to the supplicant.
502 * (This keeps the supplicant "up to date" on the current channel.)
503 *
504 * The current (new AP) channel information is passed in.
505 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700506static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700507 tCsrRoamInfo *pCsrRoamInfo)
508{
509 union iwreq_data wrqu;
510 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -0700511
Shailender Karmuchia734f332013-04-19 14:02:48 -0700512
513 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700514 {
515 hddLog(LOGE,
516 "%s: pCsrRoamInfo->pBssDesc=%p\n",
517 __func__, descriptor);
518 return;
519 }
520
521 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
522 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d\n", __func__, descriptor->channelId);
523 memset(&wrqu, '\0', sizeof(wrqu));
524 wrqu.freq.m = descriptor->channelId;
525 wrqu.freq.e = 0;
526 wrqu.freq.i = 0;
527 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
528}
529
530#endif /* FEATURE_WLAN_CCX */
531
532void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
533{
534 union iwreq_data wrqu;
535 u8 *pBeaconIes;
536 u8 currentLen = 0;
537 char *buff;
538 int totalIeLen = 0, currentOffset = 0, strLen;
539
540 memset(&wrqu, '\0', sizeof(wrqu));
541
542 if (0 == pCsrRoamInfo->nBeaconLength)
543 {
544 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
545 return;
546 }
547 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700548 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700549 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700550 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700551 return;
552 }
553
554 // pBeaconIes needs to point to the IEs
555 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
556 (unsigned int)pBeaconIes[0],
557 (unsigned int)pBeaconIes[1]);
558 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700559
Jeff Johnson295189b2012-06-20 16:38:30 -0700560 // We need to send the IEs to the supplicant.
561 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700562 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700563 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700564 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700565 return;
566 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700567 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -0700568
569 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
570 currentLen = strLen + 1;
571
572 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
573 do
574 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700575 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -0700576 * max size and send it to supplicant. Changes are done in supplicant to handle this */
577 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
578 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
579 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
580 currentOffset += currentLen;
581 totalIeLen -= currentLen;
582 wrqu.data.length = strLen + 1 + currentLen;
583 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -0700584 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -0700585 else
586 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
587
588 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
589 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
590 } while (totalIeLen > 0);
591
592 kfree(buff);
593}
594
595static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
596{
597 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
598 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
599 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
600 union iwreq_data wrqu;
601 int we_event;
602 char *msg;
603 int type = -1;
604
Shailender Karmuchia734f332013-04-19 14:02:48 -0700605#if defined (WLAN_FEATURE_VOWIFI_11R)
606 // Added to find the auth type on the fly at run time
607 // rather than with cfg to see if FT is enabled
608 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700609 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
610#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700611
Jeff Johnson295189b2012-06-20 16:38:30 -0700612 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -0700613 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -0700614 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700615
Jeff Johnson295189b2012-06-20 16:38:30 -0700616 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
617 {
618 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
619 type = WLAN_STA_ASSOC_DONE_IND;
620
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700621#ifdef WLAN_FEATURE_P2P_DEBUG
622 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
623 {
624 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
625 {
626 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
627 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
628 "Connecting state to Connected State for 8-way "
629 "Handshake");
630 }
631 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
632 {
633 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
634 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
635 "Connecting state to P2P Client Connection Completed");
636 }
637 }
638#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700639 pr_info("wlan: connected to %02x:%02x:%02x:%02x:%02x:%02x\n",
640 wrqu.ap_addr.sa_data[0],
641 wrqu.ap_addr.sa_data[1],
642 wrqu.ap_addr.sa_data[2],
643 wrqu.ap_addr.sa_data[3],
644 wrqu.ap_addr.sa_data[4],
645 wrqu.ap_addr.sa_data[5]);
646 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
647
648 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
649 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
650 * and fFTEnable is TRUE */
651#ifdef WLAN_FEATURE_VOWIFI_11R
652 // Send FT Keys to the supplicant when FT is enabled
653 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -0700654 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Jeff Johnson295189b2012-06-20 16:38:30 -0700655#ifdef FEATURE_WLAN_CCX
656 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
657 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
658#endif
659 )
660 {
661 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
662 }
663#endif
664 }
665 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
666 {
Jeff Johnson4416a782013-03-25 14:17:50 -0700667 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -0700668 type = WLAN_STA_ASSOC_DONE_IND;
669 pr_info("wlan: new IBSS connection to %02x:%02x:%02x:%02x:%02x:%02x",
670 pHddStaCtx->conn_info.bssId[0],
671 pHddStaCtx->conn_info.bssId[1],
672 pHddStaCtx->conn_info.bssId[2],
673 pHddStaCtx->conn_info.bssId[3],
674 pHddStaCtx->conn_info.bssId[4],
675 pHddStaCtx->conn_info.bssId[5]);
676 }
677 else /* Not Associated */
678 {
679 pr_info("wlan: disconnected\n");
680 type = WLAN_STA_DISASSOC_DONE_IND;
681 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
682 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -0700683 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -0700684
685 msg = NULL;
686 /*During the WLAN uninitialization,supplicant is stopped before the
687 driver so not sending the status of the connection to supplicant*/
688 if(pHddCtx->isLoadUnloadInProgress != TRUE)
689 {
690 wireless_send_event(dev, we_event, &wrqu, msg);
691#ifdef FEATURE_WLAN_CCX
692 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700693 {
694 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
695 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700696 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
697 }
698#endif
699 }
700 send_btc_nlink_msg(type, 0);
701}
702
703void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
704{
705 // Remove staId, bssId and peerMacAddress
706 pHddStaCtx->conn_info.staId [ 0 ] = 0;
707 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
708 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
709
710 // Clear all security settings
711 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
712 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
713 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
714
715 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
716
717 // Set not-connected state
718 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700719 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected );
Jeff Johnson295189b2012-06-20 16:38:30 -0700720
721 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
722}
723/* TODO Revist this function. and data path */
724static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
725{
726 VOS_STATUS vosStatus;
727 hdd_disconnect_tx_rx(pAdapter);
728 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
729 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
730 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530731 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700732 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
733 "Status= %d [0x%08lX]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700734 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -0700735 }
736 return( vosStatus );
737}
738
739
740static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
741 tANI_U32 roamId, eRoamCmdStatus roamStatus,
742 eCsrRoamResult roamResult )
743{
744 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -0700745 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -0700746 struct net_device *dev = pAdapter->dev;
747 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
748 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700749
750 // Sanity check
751 if(dev == NULL)
752 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700753 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson04dd8a82012-06-29 20:41:40 -0700754 "%s: net_dev is released return", __func__);
755 return eHAL_STATUS_FAILURE;
756 }
757
Jeff Johnson295189b2012-06-20 16:38:30 -0700758 // notify apps that we can't pass traffic anymore
759 netif_tx_disable(dev);
760 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700761
Jeff Johnsone7245742012-09-05 17:12:55 -0700762 INIT_COMPLETION(pAdapter->disconnect_comp_var);
763 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
Jeff Johnson295189b2012-06-20 16:38:30 -0700764 /* If only STA mode is on */
765 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
766 {
767 pHddCtx->isAmpAllowed = VOS_TRUE;
768 }
769 hdd_clearRoamProfileIe( pAdapter );
770
771 // indicate 'disconnect' status to wpa_supplicant...
772 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -0700773 /* indicate disconnected event to nl80211 */
774 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
775 {
776 /*During the WLAN uninitialization,supplicant is stopped before the
777 driver so not sending the status of the connection to supplicant*/
778 if(pHddCtx->isLoadUnloadInProgress != TRUE)
779 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700780 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
781 "%s: sent disconnected event to nl80211",
Jeff Johnson295189b2012-06-20 16:38:30 -0700782 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -0700783#ifdef WLAN_FEATURE_P2P_DEBUG
784 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
785 {
786 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
787 {
788 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
789 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
790 "and moved to disconnected state");
791 }
792 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
793 {
794 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
795 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
796 "and moved to inactive state");
797 }
798 }
799#endif
800
Jeff Johnson295189b2012-06-20 16:38:30 -0700801 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
802 if( eCSR_ROAM_LOSTLINK == roamStatus )
803 {
Mohit Khanna99d5fd02012-09-11 14:51:20 -0700804 cfg80211_disconnected(dev, pRoamInfo->reasonCode, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700805 }
806 else
807 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700808 cfg80211_disconnected(dev, WLAN_REASON_UNSPECIFIED, NULL, 0, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -0700809 }
810
811 //If the Device Mode is Station
812 // and the P2P Client is Connected
813 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -0700814
815 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -0700816 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -0700817 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -0700818 {
819 //Enable BMPS only of other Session is P2P Client
820 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700821 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -0700822
823 if (NULL != pVosContext)
824 {
825 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
826
827 if(NULL != pHddCtx)
828 {
829 //Only P2P Client is there Enable Bmps back
830 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
Jeff Johnsone7245742012-09-05 17:12:55 -0700831 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -0700832 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530833 if (pHddCtx->hdd_wlan_suspended)
834 {
835 hdd_set_pwrparams(pHddCtx);
836 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +0530838 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700839 }
840 }
841 }
842 }
843 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700844
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +0530845 hdd_wmm_adapter_clear(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -0700846 //We should clear all sta register with TL, for now, only one.
Jeff Johnson43971f52012-07-17 12:26:56 -0700847 vstatus = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
848 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
Jeff Johnson295189b2012-06-20 16:38:30 -0700849 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +0530850 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -0700851 "hdd_roamDeregisterSTA() failed to for staID %d. "
852 "Status= %d [0x%x]",
853 pHddStaCtx->conn_info.staId[0], status, status );
854
855 status = eHAL_STATUS_FAILURE;
856 }
857
858 pHddCtx->sta_to_adapter[pHddStaCtx->conn_info.staId[0]] = NULL;
859 // Clear saved connection information in HDD
860 hdd_connRemoveConnectInfo( pHddStaCtx );
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530861#ifdef WLAN_FEATURE_GTK_OFFLOAD
862 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
863 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
864 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +0530865 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
866 sizeof (tSirGtkOffloadParams));
867 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +0530868 }
869#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700870
Gopichand Nakkalac3694582013-02-13 20:51:22 -0800871#ifdef FEATURE_WLAN_TDLS
872 wlan_hdd_tdls_disconnection_callback(pAdapter);
873#endif
874
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 //Unblock anyone waiting for disconnect to complete
876 complete(&pAdapter->disconnect_comp_var);
877 return( status );
878}
879static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
880 tCsrRoamInfo *pRoamInfo,
881 v_U8_t staId,
882 v_MACADDR_t *pPeerMacAddress,
883 tSirBssDescription *pBssDesc )
884{
885 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
886 WLAN_STADescType staDesc = {0};
887 eCsrEncryptionType connectedCipherAlgo;
888 v_BOOL_t fConnected;
889 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
890 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -0700891 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700892
893 if ( NULL == pBssDesc)
894 {
895 return VOS_STATUS_E_FAILURE;
896 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700897 // Get the Station ID from the one saved during the assocation.
898 staDesc.ucSTAId = staId;
899
900 if ( pHddStaCtx->conn_info.connDot11DesiredBssType == eMib_dot11DesiredBssType_infrastructure)
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700902 staDesc.wSTAType = WLAN_STA_INFRA;
903
904 // grab the bssid from the connection info in the adapter structure and hand that
905 // over to TL when registering.
906 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,sizeof(pHddStaCtx->conn_info.bssId) );
907 }
908 else
909 {
910 // for an IBSS 'connect', setup the Station Descriptor for TL.
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 staDesc.wSTAType = WLAN_STA_IBSS;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700912
Jeff Johnson295189b2012-06-20 16:38:30 -0700913 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
914 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
915 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
916 // pass when making an Infrastructure connection.
917 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes) );
918 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
919 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700920
Jeff Johnson295189b2012-06-20 16:38:30 -0700921 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
922
923 // set the QoS field appropriately
924 if (hdd_wmm_is_active(pAdapter))
925 {
926 staDesc.ucQosEnabled = 1;
927 }
928 else
929 {
930 staDesc.ucQosEnabled = 0;
931 }
932
933 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
934 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
935 {
936 staDesc.ucProtectedFrame = 1;
937 }
938 else
939 {
940 staDesc.ucProtectedFrame = 0;
941
942 }
943
944#ifdef FEATURE_WLAN_CCX
945 staDesc.ucIsCcxSta = pRoamInfo->isCCXAssoc;
946#endif //FEATURE_WLAN_CCX
947
948#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
949 /* check whether replay check is valid for the station or not */
950 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
951 {
952 /* Encryption mode is either TKIP or AES
953 and replay check is valid for only these
954 two encryption modes */
955 staDesc.ucIsReplayCheckValid = VOS_TRUE;
956 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
957 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
958 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700959
Jeff Johnson295189b2012-06-20 16:38:30 -0700960 else
961 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700962 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -0700963 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700964 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -0700965 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
966 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
967 }
968#endif
969
970#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -0700971 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -0700972 if (pAdapter->wapi_info.fIsWapiSta)
973 {
974 staDesc.ucIsWapiSta = 1;
975 }
976 else
977 {
978 staDesc.ucIsWapiSta = 0;
979 }
980#endif /* FEATURE_WLAN_WAPI */
981
982 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
983 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
984
Jeff Johnson295189b2012-06-20 16:38:30 -0700985 // UMA is Not ready yet, Xlation will be done by TL
986 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -0700987 staDesc.ucSwFrameRXXlation = 1;
988 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700989 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -0700990 staDesc.ucQosEnabled );
991 // Initialize signatures and state
992 staDesc.ucUcastSig = pRoamInfo->ucastSig;
993 staDesc.ucBcastSig = pRoamInfo->bcastSig;
994 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
995 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700996 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -0800997 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 -0700998 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
999 hdd_rx_packet_cbk,
1000 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07001001 hdd_tx_fetch_packet_cbk, &staDesc,
1002 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001003
Jeff Johnson295189b2012-06-20 16:38:30 -07001004 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1005 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001006 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson295189b2012-06-20 16:38:30 -07001007 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08lX]",
1008 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001009 return vosStatus;
1010 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001011
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07001012 if ( cfg_param->dynSplitscan &&
1013 ( VOS_TIMER_STATE_RUNNING !=
1014 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1015 {
1016 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1017 cfg_param->trafficMntrTmrForSplitScan);
1018 }
1019
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301020 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
1021 // then go to 'authenticated'. For all other authentication types
1022 // (those that donot require upper layer authentication) we can put
1023 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001024 if (staDesc.wSTAType != WLAN_STA_IBSS)
1025 VOS_ASSERT( fConnected );
1026
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301027 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001028 {
1029 // Connections that do not need Upper layer auth, transition TL directly
1030 // to 'Authenticated' state.
1031 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
1032 WLANTL_STA_AUTHENTICATED );
1033
1034 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1035 }
1036 else
1037 {
1038 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301039 "ULA auth StaId= %d. Changing TL state to CONNECTED"
1040 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001041 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05301042 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001043 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1044 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001045 return( vosStatus );
1046}
1047
Jeff Johnson295189b2012-06-20 16:38:30 -07001048static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
1049 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
1050{
1051 unsigned int len = 0;
1052 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001053 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07001054 tANI_U32 rspRsnLength = 0;
1055 struct ieee80211_channel *chan;
1056
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001057 if (!rspRsnIe)
1058 {
1059 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07001060 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001061 }
1062
Jeff Johnson295189b2012-06-20 16:38:30 -07001063 if (pCsrRoamInfo == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001064 {
1065 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
1066 goto done;
1067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001068
1069 if (pCsrRoamInfo->nAssocRspLength == 0)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001070 {
1071 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
1072 goto done;
1073 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001074
1075 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
1076 pCsrRoamInfo->nAssocReqLength);
1077 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001078 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07001079
1080 //pFTAssocRsp needs to point to the IEs
1081 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1082 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x\n", __func__,
1083 (unsigned int)pFTAssocRsp[0],
1084 (unsigned int)pFTAssocRsp[1]);
1085
1086 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08001087 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07001089 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001090 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001091
1092 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, (int) pCsrRoamInfo->pBssDesc->channelId);
1093 cfg80211_roamed(dev,chan,pCsrRoamInfo->bssid,
1094 reqRsnIe, reqRsnLength,
1095 rspRsnIe, rspRsnLength,GFP_KERNEL);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07001096
1097done:
1098 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07001099}
Jeff Johnson295189b2012-06-20 16:38:30 -07001100
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301101void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
1102{
1103 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
1104 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1105 tCsrRoamInfo roamInfo;
1106 roamInfo.fAuthRequired = FALSE;
1107 vos_mem_copy(roamInfo.bssid,
1108 pHddStaCtx->roam_info.bssid,
1109 WNI_CFG_BSSID_LEN);
1110 vos_mem_copy(roamInfo.peerMac,
1111 pHddStaCtx->roam_info.peerMac,
1112 WNI_CFG_BSSID_LEN);
1113
1114 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
1115 &roamInfo,
1116 pHddStaCtx->roam_info.roamId,
1117 pHddStaCtx->roam_info.roamStatus,
1118 eCSR_ROAM_RESULT_AUTHENTICATED);
1119 if (halStatus != eHAL_STATUS_SUCCESS)
1120 {
1121 hddLog(LOGE, "%s: Set Key complete failure", __func__);
1122 }
1123 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
1124}
1125
Shailender Karmuchia734f332013-04-19 14:02:48 -07001126static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1127 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 eCsrRoamResult roamResult )
1129{
1130 struct net_device *dev = pAdapter->dev;
1131 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1132 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1133 VOS_STATUS vosStatus;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001134 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
1135 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001136#if defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07001137 int ft_carrier_on = FALSE;
1138#endif
1139 int status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001140
Jeff Johnson295189b2012-06-20 16:38:30 -07001141 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
1142 {
1143 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
1144
1145 // Save the connection info from CSR...
1146 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
1147#ifdef FEATURE_WLAN_WAPI
1148 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
1149 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
1150 {
1151 pAdapter->wapi_info.fIsWapiSta = 1;
1152 }
1153 else
1154 {
1155 pAdapter->wapi_info.fIsWapiSta = 0;
1156 }
1157#endif /* FEATURE_WLAN_WAPI */
1158
1159 // indicate 'connect' status to userspace
1160 hdd_SendAssociationEvent(dev,pRoamInfo);
1161
1162
Shailender Karmuchia734f332013-04-19 14:02:48 -07001163 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001164 INIT_COMPLETION(pAdapter->linkup_event_var);
1165
1166 /*
1167 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
1168 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 -07001169 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07001170 know that the device is getting activated properly.
1171 */
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001172#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001173 if (pHddStaCtx->ft_carrier_on == FALSE)
1174 {
1175#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001176 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 pAdapter->isLinkUpSvcNeeded = TRUE;
1178
Shailender Karmuchia734f332013-04-19 14:02:48 -07001179 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07001180 pAdapter->isLinkUpSvcNeeded = TRUE;
1181
1182 // Switch on the Carrier to activate the device
1183 netif_carrier_on(dev);
1184
1185 // Wait for the Link to up to ensure all the queues are set properly by the kernel
1186 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
1187 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001188 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07001189 {
1190 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
1191 }
1192
1193 // Disable Linkup Event Servicing - no more service required from the net device notifier call
1194 pAdapter->isLinkUpSvcNeeded = FALSE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001195#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07001196 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001197 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07001198 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001199 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07001200 }
1201#endif
1202 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1203
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001204#ifdef FEATURE_WLAN_TDLS
1205 wlan_hdd_tdls_connection_callback(pAdapter);
1206#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001207 //For reassoc, the station is already registered, all we need is to change the state
1208 //of the STA in TL.
1209 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
1210 if( !pRoamInfo->fReassocReq )
1211 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001212 struct cfg80211_bss *bss;
1213#ifdef WLAN_FEATURE_VOWIFI_11R
1214 u8 *pFTAssocRsp = NULL;
1215 unsigned int assocRsplen = 0;
1216 u8 *pFTAssocReq = NULL;
1217 unsigned int assocReqlen = 0;
1218 struct ieee80211_channel *chan;
1219#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001220 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07001222
1223 /* add bss_id to cfg80211 data base */
1224 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1225 if (NULL == bss)
1226 {
1227 pr_err("wlan: Not able to create BSS entry\n");
1228 return eHAL_STATUS_FAILURE;
1229 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001230#ifdef WLAN_FEATURE_VOWIFI_11R
1231 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001232 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07001233 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001234
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001235 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07001236 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001237 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001238 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001239 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001240 // pFTAssocRsp needs to point to the IEs
1241 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
1242 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
1243 (unsigned int)pFTAssocRsp[0],
1244 (unsigned int)pFTAssocRsp[1]);
1245 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001246 }
1247 else
1248 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001249 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
1250 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001251 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001252
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001253 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07001254 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001255 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001256 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001257 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001258 if(!ft_carrier_on)
1259 {
1260 // pFTAssocReq needs to point to the IEs
1261 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
1262 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
1263 (unsigned int)pFTAssocReq[0],
1264 (unsigned int)pFTAssocReq[1]);
1265 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
1266 }
1267 else
1268 {
1269 /* This should contain only the FTIEs */
1270 assocReqlen = pRoamInfo->nAssocReqLength;
1271 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001272 }
1273 else
1274 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001275 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
1276 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001277 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001278
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001279 if(ft_carrier_on)
1280 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001281 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
1282 "indication\n", __FUNCTION__, ft_carrier_on);
1283 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
1284 (int)pRoamInfo->pBssDesc->channelId);
1285 hddLog(LOG1, "assocReqlen %d assocRsplen %d\n", assocReqlen,
1286 assocRsplen);
1287 cfg80211_roamed(dev,chan, pRoamInfo->bssid,
1288 pFTAssocReq, assocReqlen, pFTAssocRsp, assocRsplen,
1289 GFP_KERNEL);
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301290 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
1291 {
1292 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
1293 pRoamInfo->fAuthRequired = FALSE;
1294
1295 vos_mem_copy(pHddStaCtx->roam_info.bssid,
1296 pRoamInfo->bssid,
1297 HDD_MAC_ADDR_LEN);
1298 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
1299 pRoamInfo->peerMac,
1300 HDD_MAC_ADDR_LEN);
1301 pHddStaCtx->roam_info.roamId = roamId;
1302 pHddStaCtx->roam_info.roamStatus = roamStatus;
1303 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
1304 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001305 }
1306 else
1307 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001308 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
1309 "indication\n", __FUNCTION__, ft_carrier_on);
1310 cfg80211_connect_result(dev, pRoamInfo->bssid,
1311 pFTAssocReq, assocReqlen,
1312 pFTAssocRsp, assocRsplen,
1313 WLAN_STATUS_SUCCESS,
1314 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001315 }
1316 }
1317 else
1318#endif
1319 {
1320 /* wpa supplicant expecting WPA/RSN IE in connect result */
1321 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1322 pAdapter->sessionId,
1323 &reqRsnLength,
1324 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001325
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001326 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1327 pAdapter->sessionId,
1328 &rspRsnLength,
1329 rspRsnIe);
1330#if defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
1331 if(ft_carrier_on)
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001332 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001333 else
1334#endif /* FEATURE_WLAN_CCX */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001335
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001336 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001337 /* inform connect result to nl80211 */
1338 cfg80211_connect_result(dev, pRoamInfo->bssid,
1339 reqRsnIe, reqRsnLength,
1340 rspRsnIe, rspRsnLength,
1341 WLAN_STATUS_SUCCESS,
1342 GFP_KERNEL);
1343
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001344 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001345 }
Yue Maf49ba872013-08-19 12:04:25 -07001346 cfg80211_put_bss(
1347#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1348 pHddCtx->wiphy,
1349#endif
1350 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001351 // Register the Station with TL after associated...
1352 vosStatus = hdd_roamRegisterSTA( pAdapter,
1353 pRoamInfo,
1354 pHddStaCtx->conn_info.staId[ 0 ],
1355 NULL,
1356 pRoamInfo->pBssDesc );
1357 }
1358 else
1359 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08001360 /* wpa supplicant expecting WPA/RSN IE in connect result */
1361 /* in case of reassociation also need to indicate it to supplicant */
1362 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
1363 pAdapter->sessionId,
1364 &reqRsnLength,
1365 reqRsnIe);
1366
1367 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07001368 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301369 if( pRoamInfo->fAuthRequired )
1370 {
1371 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1372 pHddStaCtx->conn_info.staId[ 0 ],
1373 WLANTL_STA_CONNECTED );
1374 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
1375 }
1376 else
1377 {
1378 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1379 "%s: staId: %d Changing TL state to AUTHENTICATED",
1380 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
1381 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1382 pHddStaCtx->conn_info.staId[ 0 ],
1383 WLANTL_STA_AUTHENTICATED );
1384 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1385 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001386 }
1387
1388 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
1389 {
1390 // perform any WMM-related association processing
1391 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
1392 }
1393 else
1394 {
1395 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1396 "Cannot register STA with TL. Failed with vosStatus = %d [%08lX]",
1397 vosStatus, vosStatus );
1398 }
Chet Lanctot186b5732013-03-18 10:26:30 -07001399#ifdef WLAN_FEATURE_11W
1400 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
1401 sizeof(pAdapter->hdd_stats.hddPmfStats) );
1402#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001403 // Start the Queue
1404 netif_tx_wake_all_queues(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001405 }
1406 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001407 {
Jeff Johnson295189b2012-06-20 16:38:30 -07001408 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1409
1410 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001411 if (pRoamInfo)
1412 pr_info("wlan: connection failed with %02x:%02x:%02x:%02x:%02x:%02x"
1413 " reason:%d and Status:%d\n", pRoamInfo->bssid[0],
1414 pRoamInfo->bssid[1], pRoamInfo->bssid[2],
1415 pRoamInfo->bssid[3], pRoamInfo->bssid[4],
1416 pRoamInfo->bssid[5], roamResult, roamStatus);
1417 else
1418 pr_info("wlan: connection failed with %02x:%02x:%02x:%02x:%02x:%02x"
Jeff Johnson32d95a32012-09-10 13:15:23 -07001419 " reason:%d and Status:%d\n", pWextState->req_bssId[0],
1420 pWextState->req_bssId[1], pWextState->req_bssId[2],
1421 pWextState->req_bssId[3], pWextState->req_bssId[4],
1422 pWextState->req_bssId[5], roamResult, roamStatus);
Jeff Johnson295189b2012-06-20 16:38:30 -07001423
1424 /*Handle all failure conditions*/
1425 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
1426 if((pHddCtx->concurrency_mode <= 1) && (pHddCtx->no_of_sessions[WLAN_HDD_INFRA_STATION] <=1))
1427 {
1428 pHddCtx->isAmpAllowed = VOS_TRUE;
1429 }
1430
1431 //If the Device Mode is Station
1432 // and the P2P Client is Connected
1433 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001434
1435 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001436 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07001437 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1438 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07001439 (vos_concurrent_sessions_running()))
1440 {
1441 //Enable BMPS only of other Session is P2P Client
1442 hdd_context_t *pHddCtx = NULL;
1443 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
1444
1445 if (NULL != pVosContext)
1446 {
1447 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1448
1449 if(NULL != pHddCtx)
1450 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301451 //Only P2P Client is there Enable Bmps back
1452 if((0 == pHddCtx->no_of_sessions[VOS_STA_SAP_MODE]) &&
1453 (0 == pHddCtx->no_of_sessions[VOS_P2P_GO_MODE]))
1454 {
1455 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001456 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301457 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08001458 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301459 hdd_enable_bmps_imps(pHddCtx);
1460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001461 }
1462 }
1463 }
1464
James Zmudafbf5ffc2013-03-25 12:45:35 -07001465 /* CR465478: Only send up a connection failure result when CSR has
1466 * completed operation - with a ASSOCIATION_FAILURE status. */
1467 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus )
Jeff Johnsone7245742012-09-05 17:12:55 -07001468 {
James Zmudafbf5ffc2013-03-25 12:45:35 -07001469 /* inform association failure event to nl80211 */
1470 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
1471 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001472 if (pRoamInfo)
1473 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1474 NULL, 0, NULL, 0,
1475 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1476 GFP_KERNEL );
1477 else
1478 cfg80211_connect_result ( dev, pWextState->req_bssId,
1479 NULL, 0, NULL, 0,
1480 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
1481 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001482 }
1483 else
1484 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07001485 if (pRoamInfo)
1486 cfg80211_connect_result ( dev, pRoamInfo->bssid,
1487 NULL, 0, NULL, 0,
1488 WLAN_STATUS_UNSPECIFIED_FAILURE,
1489 GFP_KERNEL );
1490 else
1491 cfg80211_connect_result ( dev, pWextState->req_bssId,
1492 NULL, 0, NULL, 0,
1493 WLAN_STATUS_UNSPECIFIED_FAILURE,
1494 GFP_KERNEL );
James Zmudafbf5ffc2013-03-25 12:45:35 -07001495 }
Jeff Johnsone7245742012-09-05 17:12:55 -07001496 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001497
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07001498 /*Clear the roam profile*/
1499 hdd_clearRoamProfileIe( pAdapter );
1500
Jeff Johnson295189b2012-06-20 16:38:30 -07001501 netif_tx_disable(dev);
1502 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001503
Jeff Johnson295189b2012-06-20 16:38:30 -07001504 }
1505
1506 return eHAL_STATUS_SUCCESS;
1507}
1508
1509/**============================================================================
1510 *
Jeff Johnson81c17882013-05-03 09:53:35 -07001511 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07001512 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07001513
Jeff Johnson295189b2012-06-20 16:38:30 -07001514 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07001515static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
1516 tCsrRoamInfo *pRoamInfo,
1517 tANI_U32 roamId,
1518 eRoamCmdStatus roamStatus,
1519 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07001520{
Jeff Johnson81c17882013-05-03 09:53:35 -07001521 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
1522 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
1523
Jeff Johnson295189b2012-06-20 16:38:30 -07001524 switch( roamResult )
1525 {
1526 // both IBSS Started and IBSS Join should come in here.
1527 case eCSR_ROAM_RESULT_IBSS_STARTED:
1528 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001529 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07001530 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001531 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
1532 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001533
Jeff Johnson81c17882013-05-03 09:53:35 -07001534 if (NULL == pRoamInfo)
1535 {
1536 VOS_ASSERT(0);
1537 return;
1538 }
1539
1540 /* When IBSS Started comes from CSR, we need to move
1541 * connection state to IBSS Disconnected (meaning no peers
1542 * are in the IBSS).
1543 */
1544 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
1545 eConnectionState_IbssDisconnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001546 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1547 hdd_roamRegisterSTA (pAdapter, pRoamInfo,
1548 IBSS_BROADCAST_STAID,
1549 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson295189b2012-06-20 16:38:30 -07001550
Jeff Johnson81c17882013-05-03 09:53:35 -07001551 if (pRoamInfo->pBssDesc)
1552 {
1553 struct cfg80211_bss *bss;
1554
1555 /* we created the IBSS, notify supplicant */
1556 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
1557 MAC_ADDRESS_STR,
1558 __func__, pAdapter->dev->name,
1559 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
1560
1561 /* we must first give cfg80211 the BSS information */
1562 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1563 if (NULL == bss)
1564 {
1565 hddLog(VOS_TRACE_LEVEL_ERROR,
1566 "%s: %s: unable to create IBSS entry",
1567 __func__, pAdapter->dev->name);
1568 return;
1569 }
1570
1571 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07001572 cfg80211_put_bss(
1573#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1574 pHddCtx->wiphy,
1575#endif
1576 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07001577 }
1578
Jeff Johnson295189b2012-06-20 16:38:30 -07001579 break;
1580 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001581
Jeff Johnson295189b2012-06-20 16:38:30 -07001582 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
1583 {
Jeff Johnson81c17882013-05-03 09:53:35 -07001584 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
1585 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07001586 break;
1587 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001588
Jeff Johnson295189b2012-06-20 16:38:30 -07001589 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07001590 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
1591 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07001592 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001593 }
1594
Jeff Johnson81c17882013-05-03 09:53:35 -07001595 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07001596}
1597
1598/**============================================================================
1599 *
1600 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
1601 This information is passed to iwconfig later. The peer that joined
1602 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001603 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001604 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001605
Jeff Johnson295189b2012-06-20 16:38:30 -07001606 ===========================================================================*/
1607static int roamSaveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId, v_MACADDR_t *peerMacAddress )
1608{
1609 int fSuccess = FALSE;
1610 int idx = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001611
Jeff Johnson295189b2012-06-20 16:38:30 -07001612 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1613 {
1614 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
1615 {
1616 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001617
Jeff Johnson295189b2012-06-20 16:38:30 -07001618 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001619
Jeff Johnson295189b2012-06-20 16:38:30 -07001620 fSuccess = TRUE;
1621 break;
1622 }
1623 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001624
1625 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07001626}
1627/**============================================================================
1628 *
1629 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001630 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07001631 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001632
Jeff Johnson295189b2012-06-20 16:38:30 -07001633 ===========================================================================*/
1634static int roamRemoveIbssStation( hdd_station_ctx_t *pHddStaCtx, v_U8_t staId )
1635{
1636 int fSuccess = FALSE;
1637 int idx = 0;
1638 v_U8_t valid_idx = 0;
1639 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07001640 v_U8_t empty_slots = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001641
Jeff Johnson295189b2012-06-20 16:38:30 -07001642 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
1643 {
1644 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
1645 {
1646 pHddStaCtx->conn_info.staId[ idx ] = 0;
1647
1648 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
1649
1650 fSuccess = TRUE;
Ravi Joshi8a934352013-09-25 16:46:58 -07001651
Jeff Johnson295189b2012-06-20 16:38:30 -07001652 // Note the deleted Index, if its 0 we need special handling
1653 del_idx = idx;
Ravi Joshi8a934352013-09-25 16:46:58 -07001654
1655 empty_slots++;
Jeff Johnson295189b2012-06-20 16:38:30 -07001656 }
1657 else
1658 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001659 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001660 {
1661 valid_idx = idx;
1662 }
Ravi Joshi8a934352013-09-25 16:46:58 -07001663 else
1664 {
1665 // Found an empty slot
1666 empty_slots++;
1667 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001668 }
1669 }
1670
Ravi Joshi8a934352013-09-25 16:46:58 -07001671 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
1672 {
1673 // Last peer departed, set the IBSS state appropriately
1674 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
1675 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1676 "Last IBSS Peer Departed!!!" );
1677 }
1678
Jeff Johnson295189b2012-06-20 16:38:30 -07001679 // Find next active staId, to have a valid sta trigger for TL.
1680 if (fSuccess == TRUE)
1681 {
1682 if (del_idx == 0)
1683 {
1684 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
1685 {
1686 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
1687 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
1688 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
1689
1690 pHddStaCtx->conn_info.staId[valid_idx] = 0;
1691 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
1692 }
1693 }
1694 }
1695 return( fSuccess );
1696}
1697
1698/**============================================================================
1699 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001700 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07001701 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001702
Jeff Johnson295189b2012-06-20 16:38:30 -07001703 ===========================================================================*/
1704static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
1705{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001706 struct cfg80211_bss *bss;
Jeff Johnson295189b2012-06-20 16:38:30 -07001707 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "IBSS Connect Indication from SME!!!" );
1708 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
1709 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
1710
1711 // Save the connection info from CSR...
1712 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
1713
1714 // Send the bssid address to the wext.
1715 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001716 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001717 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
1718 if (NULL == bss)
1719 {
1720 hddLog(VOS_TRACE_LEVEL_ERROR,
1721 "%s: %s: unable to create IBSS entry",
1722 __func__, pAdapter->dev->name);
1723 return eHAL_STATUS_FAILURE;
1724 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001725 /* send ibss join indication to nl80211 */
1726 cfg80211_ibss_joined(pAdapter->dev, &pRoamInfo->bssid[0], GFP_KERNEL);
Yue Maf49ba872013-08-19 12:04:25 -07001727 cfg80211_put_bss(
1728#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
1729 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
1730#endif
1731 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07001732
1733 return( eHAL_STATUS_SUCCESS );
1734}
1735/**============================================================================
1736 *
1737 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001738
Jeff Johnson295189b2012-06-20 16:38:30 -07001739 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001740static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1741 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001742 eCsrRoamResult roamResult )
1743{
1744 eCsrEncryptionType connectedCipherAlgo;
1745 v_BOOL_t fConnected = FALSE;
1746 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1747 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1748 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1749 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07001750
1751 if (NULL == pRoamInfo)
1752 {
1753 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
1754 return eHAL_STATUS_FAILURE;
1755 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001756 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001757 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07001758 // not require upper layer authentication) we can put TL directly into 'authenticated'
1759 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001760 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1761 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
1762 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08001763
Jeff Johnson295189b2012-06-20 16:38:30 -07001764 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1765 if( fConnected )
1766 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001767 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
1768 {
1769 v_U8_t staId;
1770
1771 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
1772
1773 if ( 0 == memcmp( pRoamInfo->peerMac,
1774 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
1775 {
1776 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1777 IBSS_BROADCAST_STAID);
1778 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1779 }
1780 else
1781 {
1782 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
1783 (v_MACADDR_t*)pRoamInfo->peerMac,
1784 &staId);
1785 if ( VOS_STATUS_SUCCESS == vosStatus )
1786 {
1787 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
1788 "WLAN TL STA Ptk Installed for STAID=%d", staId);
1789 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1790 staId);
1791 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1792 }
1793 }
1794 }
1795 else
1796 {
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301797 // TODO: Considering getting a state machine in HDD later.
1798 // This routine is invoked twice. 1)set PTK 2)set GTK.
1799 // The folloing if statement will be TRUE when setting GTK.
1800 // At this time we don't handle the state in detail.
1801 // Related CR: 174048 - TL not in authenticated state
1802 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
1803 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
1804 {
1805 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
1806 "for StaId= %d. Changing TL state to AUTHENTICATED",
1807 pHddStaCtx->conn_info.staId[ 0 ] );
1808
1809 // Connections that do not need Upper layer authentication,
1810 // transition TL to 'Authenticated' state after the keys are set.
1811 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
1812 pHddStaCtx->conn_info.staId[ 0 ],
1813 WLANTL_STA_AUTHENTICATED );
1814
1815 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1816 }
1817 else
1818 {
1819 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
1820 pHddStaCtx->conn_info.staId[ 0 ]);
1821 }
1822
1823 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001824 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001825 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05301826 else
1827 {
1828 // possible disassoc after issuing set key and waiting set key complete
1829 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
1830 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001831
Jeff Johnson295189b2012-06-20 16:38:30 -07001832 EXIT();
1833 return( eHAL_STATUS_SUCCESS );
1834}
1835/**============================================================================
1836 *
1837 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
1838 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001839static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07001840 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07001841{
Jeff Johnson295189b2012-06-20 16:38:30 -07001842 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1843
1844 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
1845 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
1846 {
1847 struct iw_michaelmicfailure msg;
1848 union iwreq_data wreq;
1849 memset(&msg, '\0', sizeof(msg));
1850 msg.src_addr.sa_family = ARPHRD_ETHER;
1851 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
1852 hddLog(LOG1, "MIC MAC %02x:%02x:%02x:%02x:%02x:%02x",
1853 msg.src_addr.sa_data[0],
1854 msg.src_addr.sa_data[1],
1855 msg.src_addr.sa_data[2],
1856 msg.src_addr.sa_data[3],
1857 msg.src_addr.sa_data[4],
1858 msg.src_addr.sa_data[5]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001859
Jeff Johnson295189b2012-06-20 16:38:30 -07001860 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
1861 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001862 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001863 msg.flags = IW_MICFAILURE_PAIRWISE;
1864 memset(&wreq, 0, sizeof(wreq));
1865 wreq.data.length = sizeof(msg);
1866 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07001867 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001868 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07001869 pRoamInfo->u.pMICFailureInfo->taMacAddr,
1870 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
1871 NL80211_KEYTYPE_GROUP :
1872 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07001873 pRoamInfo->u.pMICFailureInfo->keyId,
1874 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07001875 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001876
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001878
Jeff Johnson295189b2012-06-20 16:38:30 -07001879 return( eHAL_STATUS_SUCCESS );
1880}
1881
1882/**============================================================================
1883 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07001884 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07001885 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07001886
Jeff Johnson295189b2012-06-20 16:38:30 -07001887 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07001888static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1889 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07001890 eCsrRoamResult roamResult )
1891{
1892 VOS_STATUS vosStatus;
1893
1894 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1895 switch( roamResult )
1896 {
1897 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
1898 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001899 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001900 struct station_info staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001901
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001902 pr_info ( "IBSS New Peer indication from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07001903 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
1904 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
1905 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07001906 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001907
Jeff Johnson295189b2012-06-20 16:38:30 -07001908 if ( !roamSaveIbssStation( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), pRoamInfo->staId, (v_MACADDR_t *)pRoamInfo->peerMac ) )
1909 {
1910 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1911 "New IBSS peer but we already have the max we can handle. Can't register this one" );
1912 break;
1913 }
1914
1915 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
1916
Shailender Karmuchia734f332013-04-19 14:02:48 -07001917 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
1918 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
1919 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
1920
1921 // Register the Station with TL for the new peer.
Jeff Johnson295189b2012-06-20 16:38:30 -07001922 vosStatus = hdd_roamRegisterSTA( pAdapter,
1923 pRoamInfo,
1924 pRoamInfo->staId,
1925 (v_MACADDR_t *)pRoamInfo->peerMac,
1926 pRoamInfo->pBssDesc );
1927 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1928 {
1929 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1930 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08lX]",
1931 vosStatus, vosStatus );
1932 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001933 pHddStaCtx->ibss_sta_generation++;
1934 memset(&staInfo, 0, sizeof(staInfo));
1935 staInfo.filled = 0;
1936 staInfo.generation = pHddStaCtx->ibss_sta_generation;
1937
1938 cfg80211_new_sta(pAdapter->dev,
1939 (const u8 *)pRoamInfo->peerMac,
1940 &staInfo, GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001941
Shailender Karmuchi642e9812013-05-30 14:34:49 -07001942 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
1943 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
1944 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
1945 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
1946 {
1947 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
1948 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
1949 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
1950
1951 VOS_TRACE( VOS_MODULE_ID_HDD,
1952 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d\n",
1953 pHddStaCtx->ibss_enc_key.encType);
1954
1955 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
1956 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
1957
1958 if ( VOS_STATUS_SUCCESS != vosStatus )
1959 {
1960 hddLog(VOS_TRACE_LEVEL_ERROR,
1961 "%s: sme_RoamSetKey failed, returned %d",
1962 __func__, vosStatus);
1963 return VOS_STATUS_E_FAILURE;
1964 }
1965 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001966 netif_carrier_on(pAdapter->dev);
1967 netif_tx_start_all_queues(pAdapter->dev);
1968 break;
1969 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001970
Jeff Johnson295189b2012-06-20 16:38:30 -07001971 case eCSR_ROAM_RESULT_IBSS_CONNECT:
1972 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001973
Jeff Johnson295189b2012-06-20 16:38:30 -07001974 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07001975
Jeff Johnson295189b2012-06-20 16:38:30 -07001976 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001977 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001978 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
1979 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001980 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001981
Shailender Karmuchia734f332013-04-19 14:02:48 -07001982 if ( !roamRemoveIbssStation( pHddStaCtx, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001983 {
1984 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
1985 "IBSS peer departed by cannot find peer in our registration table with TL" );
1986 }
1987
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001988 pr_info ( "IBSS Peer Departed from SME "
Shailender Karmuchia734f332013-04-19 14:02:48 -07001989 "with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
1990 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
1991 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
1992 pRoamInfo->staId );
1993
Jeff Johnson295189b2012-06-20 16:38:30 -07001994 hdd_roamDeregisterSTA( pAdapter, pRoamInfo->staId );
1995
1996 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07001997 pHddStaCtx->ibss_sta_generation++;
1998 cfg80211_del_sta(pAdapter->dev,
1999 (const u8 *)&pRoamInfo->peerMac,
2000 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002001
2002 break;
2003 }
2004 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
2005 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002006 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2007 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07002008 // Stop only when we are inactive
2009 netif_tx_disable(pAdapter->dev);
2010 netif_carrier_off(pAdapter->dev);
2011 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002012
Jeff Johnson295189b2012-06-20 16:38:30 -07002013 // Send the bssid address to the wext.
2014 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
2015 // clean up data path
2016 hdd_disconnect_tx_rx(pAdapter);
2017 break;
2018 }
2019 default:
2020 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002021
Jeff Johnson295189b2012-06-20 16:38:30 -07002022 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002023
Jeff Johnson295189b2012-06-20 16:38:30 -07002024 return( eHAL_STATUS_SUCCESS );
2025}
2026
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002027#ifdef FEATURE_WLAN_TDLS
2028/**============================================================================
2029 *
2030 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
2031 TL the new STA. This is called as part of ADD_STA in the TDLS setup
2032 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07002033
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002034 ===========================================================================*/
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002035VOS_STATUS hdd_roamRegisterTDLSSTA( hdd_adapter_t *pAdapter,
2036 tANI_U8 *peerMac, tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002037{
2038 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002039 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002040 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2041 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002042 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
2043 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002044 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2045 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002046
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002047 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2048 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002049 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002050 "%s not connected. ignored", __func__);
2051 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002052 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002053
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002054 /*
2055 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
2056 * be peer MAC, here we are wokrking on direct Link
2057 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002058 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002059
2060 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002061
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002062 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002063 sizeof(tSirMacAddr) );
2064
2065 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
2066 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2067
2068 /* set the QoS field appropriately ..*/
2069 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
2070 : (staDesc.ucQosEnabled = 0) ;
2071
2072 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
2073 TL QoS_enabled=%d\n", staDesc.ucQosEnabled );
2074
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002075 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002076
2077 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2078 "HDD register TL Sec_enabled= %d.\n", staDesc.ucProtectedFrame );
2079
Shailender Karmuchia734f332013-04-19 14:02:48 -07002080 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002081 * UMA is ready we inform TL to do frame translation.
2082 */
2083 staDesc.ucSwFrameTXXlation = 1;
2084 staDesc.ucSwFrameRXXlation = 1;
2085 staDesc.ucAddRmvLLC = 1;
2086
2087 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002088 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002089
2090 /* tdls Direct Link do not need bcastSig */
2091 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002092
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002093#ifdef VOLANS_ENABLE_SW_REPLAY_CHECK
2094 if(staDesc.ucProtectedFrame)
2095 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2096 else
2097 staDesc.ucIsReplayCheckValid = VOS_FALSE;
2098#endif
2099
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302100 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002101
Shailender Karmuchia734f332013-04-19 14:02:48 -07002102 /* Register the Station with TL... */
2103 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
2104 hdd_rx_packet_cbk,
2105 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002106 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002107
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002108 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2109 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002110 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002111 "%s: WLANTL_RegisterSTAClient() failed to register. \
2112 Status= %d [0x%08lX]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002113 return vosStatus;
2114 }
2115
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002116 if ( cfg_param->dynSplitscan &&
2117 ( VOS_TIMER_STATE_RUNNING !=
2118 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
2119 {
2120 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2121 cfg_param->trafficMntrTmrForSplitScan);
2122 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002123 return( vosStatus );
2124}
2125
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08002126static VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
2127{
2128 VOS_STATUS vosStatus;
2129 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
2130 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2131 {
2132 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2133 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
2134 "Status= %d [0x%08lX]",
2135 __func__, staId, vosStatus, vosStatus );
2136 }
2137 return( vosStatus );
2138}
2139
2140
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002141/*
2142 * HDD interface between SME and TL to ensure TDLS client registration with
2143 * TL in case of new TDLS client is added and deregistration at the time
2144 * TDLS client is deleted.
2145 */
2146
Shailender Karmuchia734f332013-04-19 14:02:48 -07002147eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
2148 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002149 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002150 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002151 eCsrRoamResult roamResult)
2152{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002153 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002154 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002155 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002156
2157#ifdef WLAN_FEATURE_TDLS_DEBUG
2158 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Leee6bfe942013-02-05 15:01:19 -08002159 ("hdd_tdlsStatusUpdate: %s staIdx %d %02x:%02x:%02x:%02x:%02x:%02x \n"),
2160 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ? "ADD_TDLS_PEER" :
2161 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ? "DEL_TDLS_PEER" :
2162 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ? "DEL_TDLS_PEER_IND" :
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002163 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND? "DEL_ALL_TDLS_PEER_IND" :
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002164 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER? "UPDATE_TDLS_PEER" :
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302165 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP? "LINK_ESTABLISH_REQ_RSP" :
Hoonki Leee6bfe942013-02-05 15:01:19 -08002166 "UNKNOWN",
2167 pRoamInfo->staId,
2168 pRoamInfo->peerMac[0],
2169 pRoamInfo->peerMac[1],
2170 pRoamInfo->peerMac[2],
2171 pRoamInfo->peerMac[3],
2172 pRoamInfo->peerMac[4],
2173 pRoamInfo->peerMac[5]) ;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08002174#endif
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002175 switch( roamResult )
2176 {
2177 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
2178 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002179 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2180 {
2181 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002182 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08002183 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002184 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002185 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002186
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002187 /* check if there is available index for this new TDLS STA */
2188 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
2189 {
2190 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
2191 {
2192 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
2193 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
2194
2195 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002196 ("TDLS: STA IDX at %d is %d "
2197 "of mac %02x:%02x:%02x:%02x:%02x:%02x"),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002198 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
2199 pRoamInfo->peerMac[0],
2200 pRoamInfo->peerMac[1],
2201 pRoamInfo->peerMac[2],
2202 pRoamInfo->peerMac[3],
2203 pRoamInfo->peerMac[4],
2204 pRoamInfo->peerMac[5]) ;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002205
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002206 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002207 (v_MACADDR_t *)pRoamInfo->peerMac) ;
2208 status = eHAL_STATUS_SUCCESS ;
2209 break ;
2210 }
2211 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002212 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002213 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002214 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002215 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2216 "wlan_hdd_tdls_set_sta_id() failed");
2217 return VOS_FALSE;
2218 }
2219
2220 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302221 /* store the ucast signature , if required for further reference. */
2222
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002223 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05302224 /* start TDLS client registration with TL */
2225 status = hdd_roamRegisterTDLSSTA( pAdapter,
2226 pRoamInfo->peerMac,
2227 pRoamInfo->staId,
2228 pRoamInfo->ucastSig);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002229 }
2230 else
2231 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002232 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002233 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07002234 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002235 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002236 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002237 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08002238 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002239 break ;
2240 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08002241 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
2242 {
2243 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2244 {
2245 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2246 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
2247 }
2248 /* store the ucast signature which will be used later when
2249 * registering to TL
2250 */
2251 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
2252 complete(&pAdapter->tdls_add_station_comp);
2253 break;
2254 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05302255 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
2256 {
2257 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
2258 {
2259 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2260 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
2261 }
2262 complete(&pAdapter->tdls_link_establish_req_comp);
2263 break;
2264 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002265 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002266 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002267 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002268 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002269 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002270 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2271 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002272 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002273 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002274 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
2275
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002276 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac);
2277 if (NULL != curr_peer && TDLS_IS_CONNECTED(curr_peer))
2278 {
2279 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
2280 wlan_hdd_tdls_decrement_peer_count(pAdapter);
2281 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002282 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002283 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = NULL;
2284
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002285 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2286 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
2287 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002288 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002289 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002290 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002291 break ;
2292 }
2293 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002294 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002295 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002296 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002297 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
2298 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002299 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08002300 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2301 "%s: Sending teardown to supplicant with reason code %u",
2302 __func__, pRoamInfo->reasonCode);
2303
2304#ifdef CONFIG_TDLS_IMPLICIT
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07002305 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac);
2306 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002307#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002308 status = eHAL_STATUS_SUCCESS ;
2309 break ;
2310 }
2311 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
2312 {
2313 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002314 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002315 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002316 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
2317 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002318 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002319 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002320 ("hdd_tdlsStatusUpdate: staIdx %d %02x:%02x:%02x:%02x:%02x:%02x"),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002321 pHddCtx->tdlsConnInfo[staIdx].staId,
2322 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[0],
2323 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[1],
2324 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[2],
2325 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[3],
2326 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[4],
2327 pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes[5]) ;
2328 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
2329 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
2330 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002331
2332 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[staIdx] = NULL;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002333 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002334 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08002335 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
2336 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08002337
2338 status = eHAL_STATUS_SUCCESS ;
2339 }
2340 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05302341 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08002342 break ;
2343 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002344 default:
2345 {
2346 break ;
2347 }
2348 }
2349
2350 return status ;
2351}
2352#endif
2353
Shailender Karmuchia734f332013-04-19 14:02:48 -07002354eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07002355 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
2356{
2357 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2358 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302359 hdd_wext_state_t *pWextState = NULL;
2360 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002361 VOS_STATUS status = VOS_STATUS_SUCCESS;
Amar Singhal49fdfd52013-08-13 13:25:12 -07002362 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002363
2364 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Shailender Karmuchia734f332013-04-19 14:02:48 -07002365 "CSR Callback: status= %d result= %d roamID=%ld",
2366 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002367
2368 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302369 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002370 {
2371 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05302372 "invalid adapter or adapter has invalid magic");
2373 return eHAL_STATUS_FAILURE;
2374 }
2375
2376 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2377 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2378
2379 if ((NULL == pWextState) || (NULL == pHddStaCtx))
2380 {
2381 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
2382 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002383 return eHAL_STATUS_FAILURE;
2384 }
2385
Jeff Johnson295189b2012-06-20 16:38:30 -07002386 switch( roamStatus )
2387 {
2388 case eCSR_ROAM_SESSION_OPENED:
2389 if(pAdapter != NULL)
2390 {
2391 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
2392 complete(&pAdapter->session_open_comp_var);
2393 }
2394 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002395
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002396#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002397 /* We did pre-auth,then we attempted a 11r or ccx reassoc.
2398 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07002399 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07002400 * interface down */
2401 case eCSR_ROAM_FT_REASSOC_FAILED:
2402 hddLog(LOG1, FL("Reassoc Failed\n"));
2403 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2404 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
2405 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2407 }
2408 pHddStaCtx->ft_carrier_on = FALSE;
2409 break;
2410
2411 case eCSR_ROAM_FT_START:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002412 // When we roam for CCX and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07002413 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07002414 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07002415 // eCSR_ROAM_SHOULD_ROAM will be received.
2416 // Where in we will not mark the link down
2417 // Also we want to stop tx at this point when we will be
2418 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002419 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07002420 {
2421 struct net_device *dev = pAdapter->dev;
2422 netif_tx_disable(dev);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002423 /*
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002424 * Deregister for this STA with TL with the objective to flush
2425 * all the packets for this STA from wmm_tx_queue. If not done here,
2426 * we would run into a race condition (CR390567) wherein TX
2427 * thread would schedule packets from wmm_tx_queue AFTER peer STA has
2428 * been deleted. And, these packets get assigned with a STA idx of
2429 * self-sta (since the peer STA has been deleted) and get transmitted
2430 * on the new channel before the reassoc request. Since there will be
2431 * no ACK on the new channel, each packet gets retransmitted which
2432 * takes several seconds before the transmission of reassoc request.
2433 * This leads to reassoc-timeout and roam failure.
2434 */
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002435 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2436 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2437 {
2438 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2439 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2440 pHddStaCtx->conn_info.staId[0], status, status );
2441 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07002442 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002443 }
2444 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002445 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002446 break;
2447#endif
2448
2449 case eCSR_ROAM_SHOULD_ROAM:
2450 // Dont need to do anything
2451 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002452 struct net_device *dev = pAdapter->dev;
2453 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2454 // notify apps that we can't pass traffic anymore
2455 netif_tx_disable(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002456#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002457 if (pHddStaCtx->ft_carrier_on == FALSE)
2458 {
2459#endif
2460 netif_carrier_off(dev);
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002461#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002462 }
2463#endif
2464
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002465#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_CCX) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07002466 //We should clear all sta register with TL, for now, only one.
2467 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
2468 if ( !VOS_IS_STATUS_SUCCESS(status ) )
2469 {
2470 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
2471 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
2472 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002473 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002474 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07002475#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002476 // Clear saved connection information in HDD
2477 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
2478 }
2479 break;
2480 case eCSR_ROAM_LOSTLINK:
2481 case eCSR_ROAM_DISASSOCIATED:
2482 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002483 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2484 "****eCSR_ROAM_DISASSOCIATED****");
2485 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2486 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07002487 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2488 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302489 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07002490 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
2491 pHddCtx->configuredMcastBcastFilter =
2492 pHddCtx->sus_res_mcastbcast_filter;
Amar Singhald53568e2013-09-26 11:03:45 -07002493 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302494
Amar Singhald53568e2013-09-26 11:03:45 -07002495 hddLog(VOS_TRACE_LEVEL_INFO,
2496 "offload: disassociation happening, restoring configuredMcastBcastFilter");
2497 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
2498 pHddCtx->configuredMcastBcastFilter);
2499 hddLog(VOS_TRACE_LEVEL_INFO,
2500 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07002501 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
2502 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002503#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05302504 /* Call to clear any MC Addr List filter applied after
2505 * successful connection.
2506 */
2507 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07002508#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002509 }
2510 break;
2511 case eCSR_ROAM_IBSS_LEAVE:
2512 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2513 "****eCSR_ROAM_IBSS_LEAVE****");
2514 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2515 break;
2516 case eCSR_ROAM_ASSOCIATION_COMPLETION:
2517 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2518 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Gopichand Nakkala29149562013-05-10 21:43:41 +05302519 if ( (roamResult != eCSR_ROAM_RESULT_ASSOCIATED) &&
2520 ( (pWextState->roamProfile.EncryptionType.encryptionType[0] ==
2521 eCSR_ENCRYPT_TYPE_WEP40) ||
2522 (pWextState->roamProfile.EncryptionType.encryptionType[0] ==
2523 eCSR_ENCRYPT_TYPE_WEP104)
2524 ) &&
2525 (eCSR_AUTH_TYPE_SHARED_KEY != pWextState->roamProfile.AuthType.authType[0])
Jeff Johnson295189b2012-06-20 16:38:30 -07002526 )
2527 {
2528 v_U32_t roamId = 0;
2529 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2530 "****WEP open authentication failed, trying with shared authentication****");
2531 (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
2532 pWextState->roamProfile.AuthType.authType[0] = (WLAN_HDD_GET_STATION_CTX_PTR(pAdapter))->conn_info.authType;
2533 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
2534 halStatus = sme_RoamConnect( WLAN_HDD_GET_HAL_CTX(pAdapter), pAdapter->sessionId, &(pWextState->roamProfile), &roamId);
2535 }
2536 else
2537 {
2538 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2539 }
2540
2541 break;
2542 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002543 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002544 pRoamInfo, roamId, roamStatus, roamResult );
2545 break;
2546 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07002547 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
2548 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07002549 break;
2550
2551 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
2552 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002553 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07002554
2555 case eCSR_ROAM_MIC_ERROR_IND:
2556 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2557 break;
2558
2559 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002560 {
2561 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2562
2563 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002564 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
2565 (TRUE == pHddCtx->hdd_wlan_suspended) &&
2566 (eCSR_ROAM_RESULT_NONE == roamResult))
2567 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002568 /* Send DTIM period to the FW; only if the wlan is already
2569 in suspend. This is the case with roaming (reassoc),
2570 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
2571 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
2572 before the ENTER_BMPS_REQ ensures Listen Interval is
2573 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002574 hdd_set_pwrparams(pHddCtx);
2575 pHddStaCtx->hdd_ReassocScenario = VOS_FALSE;
2576
2577 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07002578 if due to unexpected scenario, if we are in BMPS,
2579 then trigger Exit and Enter BMPS to take DTIM period
2580 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07002581 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
2582 {
2583 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
2584
2585 /* put the device into full power */
2586 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_ACTIVE);
2587
2588 /* put the device back into BMPS */
2589 wlan_hdd_enter_bmps(pAdapter, DRIVER_POWER_MODE_AUTO);
2590 }
2591 }
2592 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
2593 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002594 break;
2595#ifdef WLAN_FEATURE_VOWIFI_11R
2596 case eCSR_ROAM_FT_RESPONSE:
2597 hdd_SendFTEvent(pAdapter);
2598 break;
2599#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07002600#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002601 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07002602 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07002603 {
2604 /* Notify the supplicant of a new candidate */
2605 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
2606 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07002607 break;
2608#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002609
Jeff Johnson295189b2012-06-20 16:38:30 -07002610 case eCSR_ROAM_INDICATE_MGMT_FRAME:
2611 hdd_indicateMgmtFrame( pAdapter,
2612 pRoamInfo->nFrameLength,
2613 pRoamInfo->pbFrames,
2614 pRoamInfo->frameType,
Chilam NG571c65a2013-01-19 12:27:36 +05302615 pRoamInfo->rxChan,
2616 pRoamInfo->rxRssi );
Jeff Johnson295189b2012-06-20 16:38:30 -07002617 break;
2618 case eCSR_ROAM_REMAIN_CHAN_READY:
2619 hdd_remainChanReadyHandler( pAdapter );
2620 break;
2621 case eCSR_ROAM_SEND_ACTION_CNF:
2622 hdd_sendActionCnf( pAdapter,
2623 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
2624 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002625#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08002626 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002627 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08002628 roamId, roamStatus, roamResult );
2629 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08002630 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
2631 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
2632 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08002633#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07002634#ifdef WLAN_FEATURE_11W
2635 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
2636 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
2637 pRoamInfo->pbFrames,
2638 pRoamInfo->frameType);
2639 break;
2640#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002641 default:
2642 break;
2643 }
2644 return( halStatus );
2645}
Shailender Karmuchia734f332013-04-19 14:02:48 -07002646eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002647{
2648 eCsrAuthType auth_type;
2649 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002650 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002651 {
2652 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002653 } else
2654 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 {
2656 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002657 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002658#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07002659 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002660 {
2661 // Check for 11r FT Authentication with PSK
2662 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002663 } else
2664 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002665 {
2666 // Check for 11R FT Authentication with 802.1X
2667 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002668 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002669#endif
2670#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002671 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002672 {
2673 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
2674 } else
2675#endif /* FEATURE_WLAN_CCX */
Chet Lanctot186b5732013-03-18 10:26:30 -07002676#ifdef WLAN_FEATURE_11W
2677 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
2678 {
2679 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
2680 } else
2681#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002682 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002683 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2684 }
2685 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002686}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002687
Shailender Karmuchia734f332013-04-19 14:02:48 -07002688eCsrAuthType
2689hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002690{
2691 eCsrAuthType auth_type;
2692 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002693 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002694 {
2695 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002696 } else
2697 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002698 {
2699 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002700 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002701#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07002702 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002703 {
2704 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002705 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07002706#endif /* FEATURE_WLAN_CCX */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002707 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002708 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
2709 }
2710 hddLog(LOG1, FL("auth_type: %d"), auth_type);
2711 return auth_type;
2712}
Jeff Johnson7dda7772013-02-27 08:36:13 -08002713
Shailender Karmuchia734f332013-04-19 14:02:48 -07002714eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07002715hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002716{
2717 eCsrEncryptionType cipher_type;
2718 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002719 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002720 {
2721 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002722 }
2723 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002724 {
2725 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002726 }
2727 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002728 {
2729 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002730 }
2731 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002732 {
2733 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002734 }
2735 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
2736 {
2737 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2738 }
2739 else
2740 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002741 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2742 }
2743 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2744 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002745}
Jeff Johnson295189b2012-06-20 16:38:30 -07002746/* To find if the MAC address is NULL */
2747static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
2748{
2749 int i;
2750 for (i = 0; i < length; i++)
2751 {
2752 if (0x00 != (macAddr[i]))
2753 {
2754 return FALSE;
2755 }
2756 }
2757 return TRUE;
2758} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08002759
Shailender Karmuchia734f332013-04-19 14:02:48 -07002760eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07002761hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07002762{
2763 eCsrEncryptionType cipher_type;
2764 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07002765 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002766 {
2767 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002768 } else
2769 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002770 {
2771 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002772 } else
2773 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002774 {
2775 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002776 } else
2777 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002778 {
2779 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002780 } else
2781 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07002782 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002783 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
2784 } else
2785 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002786 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
2787 }
2788 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
2789 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002790}
Jeff Johnson295189b2012-06-20 16:38:30 -07002791
Shailender Karmuchia734f332013-04-19 14:02:48 -07002792static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
2793 struct ether_addr *pBssid,
2794 eCsrEncryptionType *pEncryptType,
2795 eCsrEncryptionType *mcEncryptType,
2796 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07002797#ifdef WLAN_FEATURE_11W
2798 u_int8_t *pMfpRequired,
2799 u_int8_t *pMfpCapable,
2800#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002801 u_int16_t gen_ie_len,
2802 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07002803{
2804 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002805 eHalStatus result;
2806 tDot11fIERSN dot11RSNIE;
2807 tDot11fIEWPA dot11WPAIE;
2808 tANI_U32 i;
2809 tANI_U8 *pRsnIe;
2810 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07002811 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07002812 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002813
2814 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
2815 flag to 0 */
2816 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
2817 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
2818
2819 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07002820 if ((gen_ie_len < VOS_MIN(DOT11F_IE_RSN_MIN_LEN, DOT11F_IE_WPA_MIN_LEN)) ||
2821 (gen_ie_len > VOS_MAX(DOT11F_IE_RSN_MAX_LEN, DOT11F_IE_WPA_MAX_LEN)) )
Jeff Johnson295189b2012-06-20 16:38:30 -07002822 return -EINVAL;
2823 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07002824 if ( gen_ie[0] == DOT11F_EID_RSN)
2825 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002826 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07002827 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07002828 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
2829 {
2830 return -EINVAL;
2831 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002832 // Skip past the EID byte and length byte
2833 pRsnIe = gen_ie + 2;
2834 RSNIeLen = gen_ie_len - 2;
2835 // Unpack the RSN IE
2836 dot11fUnpackIeRSN((tpAniSirGlobal) halHandle,
2837 pRsnIe,
2838 RSNIeLen,
Jeff Johnson295189b2012-06-20 16:38:30 -07002839 &dot11RSNIE);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002840 // Copy out the encryption and authentication types
2841 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002842 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002843 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002844 __func__, dot11RSNIE.akm_suite_count);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002845 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07002846 but probably I suspect we can do something different*/
2847 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07002848 // Just translate the FIRST one
2849 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suites[0]);
2850 //dot11RSNIE.pwise_cipher_suite_count
2851 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
2852 //dot11RSNIE.gp_cipher_suite_count
2853 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07002854#ifdef WLAN_FEATURE_11W
2855 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
2856 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
2857#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002858 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07002859 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07002860 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002861 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07002862 {
2863 break;
2864 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07002865 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07002866 {
2867 break;
2868 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07002869 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002870 // For right now, I assume setASSOCIATE() has passed in the bssid.
2871 vos_mem_copy(PMKIDCache[i].BSSID,
2872 pBssid, ETHER_ADDR_LEN);
2873 vos_mem_copy(PMKIDCache[i].PMKID,
2874 dot11RSNIE.pmkid[i],
2875 CSR_RSN_PMKID_SIZE);
2876 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07002877
2878 if (updatePMKCache)
2879 {
2880 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
2881 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %ld."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002882 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07002883 // Finally set the PMKSA ID Cache in CSR
2884 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
2885 PMKIDCache,
2886 dot11RSNIE.pmkid_count );
2887 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002888 }
2889 else if (gen_ie[0] == DOT11F_EID_WPA)
2890 {
2891 // Validity checks
2892 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
2893 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
2894 {
2895 return -EINVAL;
2896 }
2897 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07002898 pRsnIe = gen_ie + 2 + 4;
2899 RSNIeLen = gen_ie_len - (2 + 4);
2900 // Unpack the WPA IE
Jeff Johnson295189b2012-06-20 16:38:30 -07002901 dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
2902 pRsnIe,
2903 RSNIeLen,
2904 &dot11WPAIE);
2905 // Copy out the encryption and authentication types
2906 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002907 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07002908 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002909 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07002910 //dot11WPAIE.auth_suite_count
2911 // Just translate the FIRST one
2912 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
2913 //dot11WPAIE.unicast_cipher_count
2914 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
2915 //dot11WPAIE.unicast_cipher_count
2916 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
2917 }
2918 else
2919 {
2920 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002921 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07002922 }
2923 return 0;
2924}
2925int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
2926{
2927 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2928 v_U32_t status = 0;
2929 eCsrEncryptionType RSNEncryptType;
2930 eCsrEncryptionType mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07002931#ifdef WLAN_FEATURE_11W
2932 u_int8_t RSNMfpRequired;
2933 u_int8_t RSNMfpCapable;
2934#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002935 struct ether_addr bSsid; // MAC address of assoc peer
2936 // MAC address of assoc peer
2937 // But, this routine is only called when we are NOT associated.
2938 vos_mem_copy(bSsid.ether_addr_octet,
2939 pWextState->roamProfile.BSSIDs.bssid,
2940 sizeof(bSsid.ether_addr_octet));
2941 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
2942 {
2943 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07002944 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002945 else
2946 {
2947 return 0;
2948 }
2949 // The actual processing may eventually be more extensive than this.
2950 // Right now, just consume any PMKIDs that are sent in by the app.
2951 status = hdd_ProcessGENIE(pAdapter,
2952 &bSsid, // MAC address of assoc peer
2953 &RSNEncryptType,
2954 &mcRSNEncryptType,
2955 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07002956#ifdef WLAN_FEATURE_11W
2957 &RSNMfpRequired,
2958 &RSNMfpCapable,
2959#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002960 pWextState->WPARSNIE[1]+2,
2961 pWextState->WPARSNIE);
2962 if (status == 0)
2963 {
2964 // Now copy over all the security attributes you have parsed out
2965 pWextState->roamProfile.EncryptionType.numEntries = 1;
2966 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002967
Jeff Johnson295189b2012-06-20 16:38:30 -07002968 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
2969 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07002970
Shailender Karmuchi642e9812013-05-30 14:34:49 -07002971 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
2972 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
2973 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
2974 {
2975 /*For wpa none supplicant sends the WPA IE with unicast cipher as
2976 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
2977 either AES/TKIP based on group cipher configuration
2978 mentioned in the wpa_supplicant.conf.*/
2979
2980 /*Set the unicast cipher same as multicast cipher*/
2981 pWextState->roamProfile.EncryptionType.encryptionType[0]
2982 = mcRSNEncryptType;
2983 }
2984
Chet Lanctot186b5732013-03-18 10:26:30 -07002985#ifdef WLAN_FEATURE_11W
2986 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
2987 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
2988#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002989 hddLog( LOG1, "%s: CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d", __func__, *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Jeff Johnson295189b2012-06-20 16:38:30 -07002990 }
2991 return 0;
2992}
2993int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
2994{
2995 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
2996 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
2997 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2998 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07002999
Jeff Johnson295189b2012-06-20 16:38:30 -07003000 pRoamProfile->AuthType.numEntries = 1;
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003001 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d\n", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003002
Jeff Johnson295189b2012-06-20 16:38:30 -07003003 switch( pHddStaCtx->conn_info.authType)
3004 {
3005 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3006#ifdef FEATURE_WLAN_CCX
3007 case eCSR_AUTH_TYPE_CCKM_WPA:
3008 case eCSR_AUTH_TYPE_CCKM_RSN:
3009#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07003010 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
3011
Jeff Johnson295189b2012-06-20 16:38:30 -07003012 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003013 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003014 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003015
Jeff Johnson295189b2012-06-20 16:38:30 -07003016#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07003017 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
3018 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3019 == IW_AUTH_KEY_MGMT_802_1X)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003020 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.\n", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003021 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
3022 } else
3023 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003024 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.\n", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003025 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07003026 } else
3027#endif
3028 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3029 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003030 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
3031 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003032 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3033 == IW_AUTH_KEY_MGMT_PSK) {
3034 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003035 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003036 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003037 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003038 }
3039 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
3040#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07003041 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
3042 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
3043 == IW_AUTH_KEY_MGMT_802_1X)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003044 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.\n", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003045 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003046 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003047 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003048 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.\n", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003049 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07003050 } else
3051#endif
3052
3053#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07003054 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
3055 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003056 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003057 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07003058 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07003059 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07003060 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3061 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003062 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07003063 } else
3064#endif
3065
Chet Lanctot186b5732013-03-18 10:26:30 -07003066#ifdef WLAN_FEATURE_11W
3067 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
3068 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
3069 } else
3070#endif
3071
Shailender Karmuchia734f332013-04-19 14:02:48 -07003072 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07003073 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003074 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
3075 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07003076 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
3077 == IW_AUTH_KEY_MGMT_PSK) {
3078 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003079 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07003080 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003081 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003082 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003083 break;
3084
Jeff Johnson295189b2012-06-20 16:38:30 -07003085 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003086
3087 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003088 break;
3089 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003090
Jeff Johnson295189b2012-06-20 16:38:30 -07003091#ifdef FEATURE_WLAN_CCX
Shailender Karmuchia734f332013-04-19 14:02:48 -07003092 hddLog( LOG1, "%s: In default, unknown auth type.\n", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003093#endif /* FEATURE_WLAN_CCX */
3094 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
3095 break;
3096 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003097
Jeff Johnson295189b2012-06-20 16:38:30 -07003098 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003099 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003100
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 EXIT();
3102 return 0;
3103}
3104
3105/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003106
3107 \brief iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003108 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07003109 to the CSR roam profile.
3110
Jeff Johnson295189b2012-06-20 16:38:30 -07003111 \param - dev - Pointer to the net device.
3112 - info - Pointer to the iw_request_info.
3113 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003114 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003115 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003116
Jeff Johnson295189b2012-06-20 16:38:30 -07003117 --------------------------------------------------------------------------*/
3118
Shailender Karmuchia734f332013-04-19 14:02:48 -07003119int iw_set_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003120 struct iw_request_info *info,
3121 union iwreq_data *wrqu, char *extra)
3122{
3123 v_U32_t status = 0;
3124 hdd_wext_state_t *pWextState;
3125 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3126 v_U32_t roamId;
3127 tCsrRoamProfile *pRoamProfile;
3128 eMib_dot11DesiredBssType connectedBssType;
3129 eCsrAuthType RSNAuthType;
3130 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
3131 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003132
3133 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3134
Jeff Johnson295189b2012-06-20 16:38:30 -07003135 ENTER();
3136
3137 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3138 {
3139 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3140 "%s:LOGP in Progress. Ignore!!!",__func__);
3141 return 0;
3142 }
3143
3144 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
3145 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
3146 return -EBUSY;
3147 }
3148 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
3149 return -EINVAL;
3150 pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003151 if (pRoamProfile)
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 {
3153 if ( hdd_connGetConnectedBssType( pHddStaCtx, &connectedBssType ) ||
3154 ( eMib_dot11DesiredBssType_independent == pHddStaCtx->conn_info.connDot11DesiredBssType ))
3155 {
3156 VOS_STATUS vosStatus;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003157 // need to issue a disconnect to CSR.
Jeff Johnson295189b2012-06-20 16:38:30 -07003158 INIT_COMPLETION(pAdapter->disconnect_comp_var);
3159 vosStatus = sme_RoamDisconnect( hHal, pAdapter->sessionId, eCSR_DISCONNECT_REASON_UNSPECIFIED );
3160
3161 if(VOS_STATUS_SUCCESS == vosStatus)
3162 wait_for_completion_interruptible_timeout(&pAdapter->disconnect_comp_var,
3163 msecs_to_jiffies(WLAN_WAIT_TIME_DISCONNECT));
3164 }
3165 }
3166 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003167 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003168 {
3169 return -EINVAL;
3170 }
3171 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003172 /** when cfg80211 defined, wpa_supplicant wext driver uses
3173 zero-length, null-string ssid for force disconnection.
3174 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07003175 driver MUST return success */
3176 if ( 0 == wrqu->essid.length ) {
3177 return 0;
3178 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003179
3180 status = hdd_wmm_get_uapsd_mask(pAdapter,
3181 &pWextState->roamProfile.uapsd_mask);
3182 if (VOS_STATUS_SUCCESS != status)
3183 {
3184 pWextState->roamProfile.uapsd_mask = 0;
3185 }
3186 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003187
Jeff Johnson295189b2012-06-20 16:38:30 -07003188 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003189
3190 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07003191 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
3192 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
3193 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003194
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 //set gen ie
3196 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
3197
3198 //set auth
3199 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
3200 }
3201#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003202 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003203 if (pAdapter->wapi_info.nWapiMode)
3204 {
3205 switch (pAdapter->wapi_info.wapiAuthMode)
3206 {
3207 case WAPI_AUTH_MODE_PSK:
3208 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003209 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003210 pRoamProfile->AuthType.numEntries = 1;
3211 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
3212 break;
3213 }
3214 case WAPI_AUTH_MODE_CERT:
3215 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003216 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07003217 pRoamProfile->AuthType.numEntries = 1;
3218 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
3219 break;
3220 }
3221 } // End of switch
3222 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
3223 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
3224 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003225 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003226 pRoamProfile->EncryptionType.numEntries = 1;
3227 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3228 pRoamProfile->mcEncryptionType.numEntries = 1;
3229 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
3230 }
3231 }
3232#endif /* FEATURE_WLAN_WAPI */
3233 /* if previous genIE is not NULL, update AssocIE */
3234 if (0 != pWextState->genIE.length)
3235 {
3236 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
3237 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
3238 pWextState->genIE.length);
3239 pWextState->assocAddIE.length = pWextState->genIE.length;
3240 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
3241 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
3242
3243 /* clear previous genIE after use it */
3244 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
3245 }
3246
3247 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
3248 pWextState->roamProfile.bWPSAssociation = FALSE;
3249
3250 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
3251 pWextState->roamProfile.nAddIEAssocLength))
3252 pWextState->roamProfile.bWPSAssociation = TRUE;
3253
3254
3255 // Disable auto BMPS entry by PMC until DHCP is done
3256 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
3257
Shailender Karmuchia734f332013-04-19 14:02:48 -07003258 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07003259 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003260
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003261 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
3262 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003263 hdd_select_cbmode(pAdapter,
3264 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
3265 }
3266 status = sme_RoamConnect( hHal,pAdapter->sessionId,
3267 &(pWextState->roamProfile), &roamId);
3268 pRoamProfile->ChannelInfo.ChannelList = NULL;
3269 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003270
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003271 EXIT();
3272 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07003273}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07003274
Jeff Johnson295189b2012-06-20 16:38:30 -07003275/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003276
3277 \brief iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003278 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003279
Jeff Johnson295189b2012-06-20 16:38:30 -07003280 \param - dev - Pointer to the net device.
3281 - info - Pointer to the iw_request_info.
3282 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003283 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003284 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003285
Jeff Johnson295189b2012-06-20 16:38:30 -07003286 --------------------------------------------------------------------------*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003287int iw_get_essid(struct net_device *dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003288 struct iw_request_info *info,
3289 struct iw_point *dwrq, char *extra)
3290{
3291 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003292 hdd_wext_state_t *wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003293 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3294 ENTER();
3295
3296 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
3297 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
3298 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
3299 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
3300 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
3301 {
3302 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
3303 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
3304 dwrq->flags = 1;
3305 } else {
3306 memset(extra, 0, dwrq->length);
3307 dwrq->length = 0;
3308 dwrq->flags = 0;
3309 }
3310 EXIT();
3311 return 0;
3312}
3313/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003314
3315 \brief iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003316 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003317
Jeff Johnson295189b2012-06-20 16:38:30 -07003318 \param - dev - Pointer to the net device.
3319 - info - Pointer to the iw_request_info.
3320 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003321 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003322 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003323
Jeff Johnson295189b2012-06-20 16:38:30 -07003324 --------------------------------------------------------------------------*/
3325int iw_set_auth(struct net_device *dev,struct iw_request_info *info,
3326 union iwreq_data *wrqu,char *extra)
3327{
3328 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003329 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3331 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003332 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07003333 eCsrEncryptionType ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003334
Jeff Johnson295189b2012-06-20 16:38:30 -07003335 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003336
3337 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3338 {
3339 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3340 "%s:LOGP in Progress. Ignore!!!", __func__);
3341 return -EBUSY;
3342 }
3343
Jeff Johnson295189b2012-06-20 16:38:30 -07003344 switch(wrqu->param.flags & IW_AUTH_INDEX)
3345 {
3346 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003347
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003349
Jeff Johnson295189b2012-06-20 16:38:30 -07003350 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003351
Jeff Johnson295189b2012-06-20 16:38:30 -07003352 case IW_AUTH_CIPHER_PAIRWISE:
3353 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003354 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003355 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003356 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003357 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3358 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
3361 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003362 }
3363
Jeff Johnson295189b2012-06-20 16:38:30 -07003364 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003365
3366 if( (IW_AUTH_KEY_MGMT_802_1X
3367 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003368 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
3369 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003370 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07003371 else
3372 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003373 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
3374 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003376
3377 if( ( IW_AUTH_KEY_MGMT_802_1X
3378 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003379 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3380 /*Dynamic WEP key*/
3381 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3382 else
3383 /*Static WEP key*/
3384 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003385
Jeff Johnson295189b2012-06-20 16:38:30 -07003386 }
3387 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003388
Jeff Johnson295189b2012-06-20 16:38:30 -07003389 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003390 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003391 return -EINVAL;
3392 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003393
Jeff Johnson295189b2012-06-20 16:38:30 -07003394 pRoamProfile->EncryptionType.numEntries = 1;
3395 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003396 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003397 break;
3398 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003399 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003400 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
3401 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
3402 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003403
Jeff Johnson295189b2012-06-20 16:38:30 -07003404 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
3405 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
3406 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003407
3408 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003409 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
3410 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003411
Jeff Johnson295189b2012-06-20 16:38:30 -07003412 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003413
3414 if( ( IW_AUTH_KEY_MGMT_802_1X
3415 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
3416 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3417
Jeff Johnson295189b2012-06-20 16:38:30 -07003418 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003419
3420 else
3421 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07003422 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003423
3424 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
3425 {
Jeff Johnson295189b2012-06-20 16:38:30 -07003426 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003427 if( ( IW_AUTH_KEY_MGMT_802_1X
3428 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07003429 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
3430 {
3431 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
3432 }
3433 else
3434 {
3435 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
3436 }
3437 }
3438 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003439
Jeff Johnson295189b2012-06-20 16:38:30 -07003440 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003441 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07003442 return -EINVAL;
3443 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003444
Jeff Johnson295189b2012-06-20 16:38:30 -07003445 pRoamProfile->mcEncryptionType.numEntries = 1;
3446 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
3447 }
3448 break;
3449
3450 case IW_AUTH_80211_AUTH_ALG:
3451 {
3452 /*Save the auth algo here and set auth type to SME Roam profile
3453 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003454 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07003455 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003456
Jeff Johnson295189b2012-06-20 16:38:30 -07003457 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
3458 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
3459
3460 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
3461 /*Not supported*/
3462 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
3463 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
3464 }
3465 break;
3466
3467 case IW_AUTH_KEY_MGMT:
3468 {
3469#ifdef FEATURE_WLAN_CCX
3470#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
3471 /*Check for CCKM AKM type */
3472 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003473 //hddLog(VOS_TRACE_LEVEL_INFO_HIGH,"%s: CCKM AKM Set %d\n", __func__, wrqu->param.value);
3474 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d\n", __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003475 /* Set the CCKM bit in authKeyMgmt */
3476 /* Right now, this breaks all ref to authKeyMgmt because our
3477 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07003478 */
3479 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
3480 /*Set the key management to 802.1X*/
3481 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
3482 pWextState->isCCXConnection = eANI_BOOLEAN_TRUE;
3483 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3484 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
3485 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
3486 /*Save the key management*/
3487 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
3488 //pWextState->authKeyMgmt = wrqu->param.value;
3489 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3490 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3491 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
3492 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
3493 /*Save the key management anyway*/
3494 pWextState->authKeyMgmt = wrqu->param.value;
3495 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
3496 /*Save the key management*/
3497 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
3498 //pWextState->authKeyMgmt = wrqu->param.value;
3499 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
3500 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
3501 }
3502#else
3503 /*Save the key management*/
3504 pWextState->authKeyMgmt = wrqu->param.value;
3505#endif /* FEATURE_WLAN_CCX */
3506 }
3507 break;
3508
3509 case IW_AUTH_TKIP_COUNTERMEASURES:
3510 {
3511 if(wrqu->param.value) {
3512 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3513 "Counter Measure started %d", wrqu->param.value);
3514 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
3515 }
3516 else {
3517 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
3518 "Counter Measure stopped=%d", wrqu->param.value);
3519 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
3520 }
3521 }
3522 break;
3523 case IW_AUTH_DROP_UNENCRYPTED:
3524 case IW_AUTH_WPA_ENABLED:
3525 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
3526 case IW_AUTH_ROAMING_CONTROL:
3527 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003528
Jeff Johnson295189b2012-06-20 16:38:30 -07003529 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07003530
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003531 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07003532 wrqu->param.flags & IW_AUTH_INDEX);
3533 break;
3534 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003535
Jeff Johnson295189b2012-06-20 16:38:30 -07003536 EXIT();
3537 return 0;
3538}
3539/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003540
3541 \brief iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003542 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003543
Jeff Johnson295189b2012-06-20 16:38:30 -07003544 \param - dev - Pointer to the net device.
3545 - info - Pointer to the iw_request_info.
3546 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003547 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003548 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003549
Jeff Johnson295189b2012-06-20 16:38:30 -07003550 --------------------------------------------------------------------------*/
3551int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
3552 union iwreq_data *wrqu,char *extra)
3553{
3554 hdd_adapter_t* pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003555 hdd_wext_state_t *pWextState= WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003556 tCsrRoamProfile *pRoamProfile = &pWextState->roamProfile;
3557 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08003558
3559 if ((WLAN_HDD_GET_CTX(pAdapter))->isLogpInProgress)
3560 {
3561 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3562 "%s:LOGP in Progress. Ignore!!!", __func__);
3563 return -EBUSY;
3564 }
3565
Jeff Johnson295189b2012-06-20 16:38:30 -07003566 switch(pRoamProfile->negotiatedAuthType)
3567 {
3568 case eCSR_AUTH_TYPE_WPA_NONE:
3569 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3570 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
3571 break;
3572 case eCSR_AUTH_TYPE_WPA:
3573 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3574 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
3575 break;
3576#ifdef WLAN_FEATURE_VOWIFI_11R
3577 case eCSR_AUTH_TYPE_FT_RSN:
3578#endif
3579 case eCSR_AUTH_TYPE_RSN:
3580 wrqu->param.flags = IW_AUTH_WPA_VERSION;
3581 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
3582 break;
3583 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
3584 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3585 break;
3586 case eCSR_AUTH_TYPE_SHARED_KEY:
3587 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
3588 break;
3589 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003590 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003591 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3592 break;
3593 case eCSR_AUTH_TYPE_AUTOSWITCH:
3594 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3595 break;
3596 case eCSR_AUTH_TYPE_WPA_PSK:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003597 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003598 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3599 return -EIO;
3600#ifdef WLAN_FEATURE_VOWIFI_11R
3601 case eCSR_AUTH_TYPE_FT_RSN_PSK:
3602#endif
3603 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07003604#ifdef WLAN_FEATURE_11W
3605 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
3606#endif
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003607 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003608 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3609 return -EIO;
3610 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003611 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003612 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
3613 return -EIO;
3614 }
3615 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
3616 {
3617 switch(pRoamProfile->negotiatedUCEncryptionType)
3618 {
3619 case eCSR_ENCRYPT_TYPE_NONE:
3620 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3621 break;
3622 case eCSR_ENCRYPT_TYPE_WEP40:
3623 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3624 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3625 break;
3626 case eCSR_ENCRYPT_TYPE_TKIP:
3627 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3628 break;
3629 case eCSR_ENCRYPT_TYPE_WEP104:
3630 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3631 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3632 break;
3633 case eCSR_ENCRYPT_TYPE_AES:
3634 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3635 break;
3636 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003637 hddLog(LOG1, "%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003638 return -EIO;
3639 }
3640 }
3641
Shailender Karmuchia734f332013-04-19 14:02:48 -07003642 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07003643 {
3644 switch(pRoamProfile->negotiatedMCEncryptionType)
3645 {
3646 case eCSR_ENCRYPT_TYPE_NONE:
3647 wrqu->param.value = IW_AUTH_CIPHER_NONE;
3648 break;
3649 case eCSR_ENCRYPT_TYPE_WEP40:
3650 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
3651 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
3652 break;
3653 case eCSR_ENCRYPT_TYPE_TKIP:
3654 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
3655 break;
3656 case eCSR_ENCRYPT_TYPE_WEP104:
3657 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
3658 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
3659 break;
3660 case eCSR_ENCRYPT_TYPE_AES:
3661 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
3662 break;
3663 default:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003664 hddLog(LOG1, "%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003665 return -EIO;
3666 }
3667 }
3668
3669 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07003670 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07003671 EXIT();
3672 return 0;
3673}
3674/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003675
3676 \brief iw_set_ap_address() -
3677 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07003678 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003679
Jeff Johnson295189b2012-06-20 16:38:30 -07003680 \param - dev - Pointer to the net device.
3681 - info - Pointer to the iw_request_info.
3682 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003683 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003684 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003685
Jeff Johnson295189b2012-06-20 16:38:30 -07003686 --------------------------------------------------------------------------*/
3687int iw_set_ap_address(struct net_device *dev,
3688 struct iw_request_info *info,
3689 union iwreq_data *wrqu, char *extra)
3690{
3691 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3692 v_U8_t *pMacAddress=NULL;
3693 ENTER();
3694 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
3695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%02x:%02x:%02x:%02x:%02x:%02x",pMacAddress[0],pMacAddress[1],
3696 pMacAddress[2],pMacAddress[3],pMacAddress[4],pMacAddress[5]);
3697 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
3698 EXIT();
Shailender Karmuchia734f332013-04-19 14:02:48 -07003699
Jeff Johnson295189b2012-06-20 16:38:30 -07003700 return 0;
3701}
3702/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07003703
3704 \brief iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07003705 This function returns the BSSID to the wpa_supplicant
3706 \param - dev - Pointer to the net device.
3707 - info - Pointer to the iw_request_info.
3708 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003709 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07003710 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07003711
Jeff Johnson295189b2012-06-20 16:38:30 -07003712 --------------------------------------------------------------------------*/
3713int iw_get_ap_address(struct net_device *dev,
3714 struct iw_request_info *info,
3715 union iwreq_data *wrqu, char *extra)
3716{
3717 //hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
3718 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(WLAN_HDD_GET_PRIV_PTR(dev));
3719
3720 ENTER();
3721
3722 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
3723 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
3724 {
Jeff Johnson4416a782013-03-25 14:17:50 -07003725 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07003726 }
3727 else
3728 {
3729 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
3730 }
3731 EXIT();
3732 return 0;
3733}
Jeff Johnsond13512a2012-07-17 11:42:19 -07003734
Chet Lanctot186b5732013-03-18 10:26:30 -07003735#ifdef WLAN_FEATURE_11W
3736/**---------------------------------------------------------------------------
3737
3738 \brief hdd_indicateUnprotMgmtFrame -
3739 This function forwards the unprotected management frame to the supplicant
3740 \param - pAdapter - Pointer to HDD adapter
3741 - nFrameLength - Length of the unprotected frame being passed
3742 - pbFrames - Pointer to the frame buffer
3743 - frameType - 802.11 frame type
3744 \return - nothing
3745
3746 --------------------------------------------------------------------------*/
3747void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
3748 tANI_U32 nFrameLength,
3749 tANI_U8* pbFrames,
3750 tANI_U8 frameType )
3751{
3752 tANI_U8 type = 0;
3753 tANI_U8 subType = 0;
3754
3755 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
3756 __func__, frameType, nFrameLength);
3757
3758 /* Sanity Checks */
3759 if (NULL == pAdapter)
3760 {
3761 hddLog( LOGE, FL("pAdapter is NULL"));
3762 return;
3763 }
3764
3765 if (NULL == pAdapter->dev)
3766 {
3767 hddLog( LOGE, FL("pAdapter->dev is NULL"));
3768 return;
3769 }
3770
3771 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
3772 {
3773 hddLog( LOGE, FL("pAdapter has invalid magic"));
3774 return;
3775 }
3776
3777 if( !nFrameLength )
3778 {
3779 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
3780 return;
3781 }
3782
3783 if (NULL == pbFrames) {
3784 hddLog( LOGE, FL("pbFrames is NULL"));
3785 return;
3786 }
3787
3788 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
3789 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
3790
3791 /* Get pAdapter from Destination mac address of the frame */
3792 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
3793 {
3794 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
3795 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
3796 }
3797 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
3798 {
3799 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
3800 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
3801 }
3802 else
3803 {
3804 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
3805 return;
3806 }
3807}
3808#endif