blob: 766e227189a25310fa24e64f726ee622c8867365 [file] [log] [blame]
Jeff Johnson295189b2012-06-20 16:38:30 -07001/*
Abhishek Singhe6137b82019-03-22 20:06:09 +05302 * Copyright (c) 2012-2019 The Linux Foundation. All rights reserved.
Kiet Lam842dad02014-02-18 18:44:02 -08003 *
4 * Previously licensed under the ISC license by Qualcomm Atheros, Inc.
5 *
6 *
7 * Permission to use, copy, modify, and/or distribute this software for
8 * any purpose with or without fee is hereby granted, provided that the
9 * above copyright notice and this permission notice appear in all
10 * copies.
11 *
12 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
13 * WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
14 * WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
15 * AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
16 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
17 * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 * PERFORMANCE OF THIS SOFTWARE.
Gopichand Nakkala92f07d82013-01-08 21:16:34 -080020 */
Kiet Lam842dad02014-02-18 18:44:02 -080021
22/*
23 * This file was originally distributed by Qualcomm Atheros, Inc.
24 * under proprietary terms before Copyright ownership was assigned
25 * to the Linux Foundation.
26 */
27
Jeff Johnson295189b2012-06-20 16:38:30 -070028/**========================================================================
29
30 \file wlan_hdd_assoc.c
31 \brief WLAN Host Device Driver implementation
Shailender Karmuchia734f332013-04-19 14:02:48 -070032
Jeff Johnson295189b2012-06-20 16:38:30 -070033 ========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070034/**=========================================================================
35 EDIT HISTORY FOR FILE
36
37
38 This section contains comments describing changes made to the module.
39 Notice that changes are listed in reverse chronological order.
40
41
42 $Header:$ $DateTime: $ $Author: $
43
44
45 when who what, where, why
Jeff Johnson295189b2012-06-20 16:38:30 -070046 -------- --- --------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -070047 05/06/09 Shailender Created module.
Jeff Johnson295189b2012-06-20 16:38:30 -070048 ==========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -070049
Jeff Johnson295189b2012-06-20 16:38:30 -070050#include "wlan_hdd_includes.h"
51#include <aniGlobal.h>
52#include "dot11f.h"
53#include "wlan_nlink_common.h"
54#include "wlan_btc_svc.h"
55#include "wlan_hdd_power.h"
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +053056#include "wlan_hdd_trace.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070057#include <linux/ieee80211.h>
58#include <linux/wireless.h>
59#include <net/cfg80211.h>
60#include "wlan_hdd_cfg80211.h"
61#include "csrInsideApi.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070062#include "wlan_hdd_p2p.h"
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +053063#include <vos_sched.h>
Mohit Khanna698ba2a2012-12-04 15:08:18 -080064#include "wlan_hdd_tdls.h"
Jeff Johnson295189b2012-06-20 16:38:30 -070065#include "sme_Api.h"
Sushant Kaushikba6764e2014-06-30 19:52:09 +053066#include "wlan_hdd_hostapd.h"
Mukul Sharma84f27252014-07-14 18:11:42 +053067#include "vos_utils.h"
Siddharth Bhalda0d1622015-04-24 15:47:49 +053068#include <wlan_hdd_wext.h>
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +053069#include "sapInternal.h"
Mukul Sharma84f27252014-07-14 18:11:42 +053070
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +053071#if defined CFG80211_ROAMED_API_UNIFIED || \
72 (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0))
73/**
74 * hdd_send_roamed_ind() - send roamed indication to cfg80211
75 * @dev: network device
76 * @bss: cfg80211 roamed bss pointer
77 * @req_ie: IEs used in reassociation request
78 * @req_ie_len: Length of the @req_ie
79 * @resp_ie: IEs received in successful reassociation response
80 * @resp_ie_len: Length of @resp_ie
81 *
82 * Return: none
83 */
84static void hdd_send_roamed_ind(struct net_device *dev,
85 struct cfg80211_bss *bss, const uint8_t *req_ie,
86 size_t req_ie_len, const uint8_t *resp_ie,
87 size_t resp_ie_len)
88{
89 struct cfg80211_roam_info info = {0};
90
91 info.bss = bss;
92 info.req_ie = req_ie;
93 info.req_ie_len = req_ie_len;
94 info.resp_ie = resp_ie;
95 info.resp_ie_len = resp_ie_len;
96
97 cfg80211_roamed(dev, &info, GFP_KERNEL);
98}
99#else
100/**
101 * hdd_send_roamed_ind() - send roamed indication to cfg80211
102 * @dev: network device
103 * @bss: cfg80211 roamed bss pointer
104 * @req_ie: IEs used in reassociation request
105 * @req_ie_len: Length of the @req_ie
106 * @resp_ie: IEs received in successful reassociation response
107 * @resp_ie_len: Length of @resp_ie
108 *
109 * Return: none
110 */
111static inline void hdd_send_roamed_ind(struct net_device *dev,
112 struct cfg80211_bss *bss,
113 const uint8_t *req_ie, size_t req_ie_len,
114 const uint8_t *resp_ie,
115 size_t resp_ie_len)
116{
117 cfg80211_roamed_bss(dev, bss, req_ie, req_ie_len, resp_ie, resp_ie_len,
118 GFP_KERNEL);
119}
120#endif
121
Jeff Johnson295189b2012-06-20 16:38:30 -0700122v_BOOL_t mibIsDot11DesiredBssTypeInfrastructure( hdd_adapter_t *pAdapter );
123
Shailender Karmuchia734f332013-04-19 14:02:48 -0700124struct ether_addr
Jeff Johnson295189b2012-06-20 16:38:30 -0700125{
126 u_char ether_addr_octet[6];
127};
128// These are needed to recognize WPA and RSN suite types
129#define HDD_WPA_OUI_SIZE 4
130v_U8_t ccpWpaOui00[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x00 };
131v_U8_t ccpWpaOui01[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x01 };
132v_U8_t ccpWpaOui02[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x02 };
133v_U8_t ccpWpaOui03[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x03 };
134v_U8_t ccpWpaOui04[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x04 };
135v_U8_t ccpWpaOui05[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x50, 0xf2, 0x05 };
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800136#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700137v_U8_t ccpWpaOui06[ HDD_WPA_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800138#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -0700139#define HDD_RSN_OUI_SIZE 4
140v_U8_t ccpRSNOui00[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x00 }; // group cipher
141v_U8_t ccpRSNOui01[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x01 }; // WEP-40 or RSN
142v_U8_t ccpRSNOui02[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x02 }; // TKIP or RSN-PSK
143v_U8_t ccpRSNOui03[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x03 }; // Reserved
144v_U8_t ccpRSNOui04[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x04 }; // AES-CCMP
145v_U8_t ccpRSNOui05[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 }; // WEP-104
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800146#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -0700147v_U8_t ccpRSNOui06[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x40, 0x96, 0x00 }; // CCKM
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800148#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -0700149#ifdef WLAN_FEATURE_11W
150v_U8_t ccpRSNOui07[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x06 }; // RSN-PSK-SHA256
Abhishek Singhae408032014-09-25 17:22:04 +0530151/* RSN-8021X-SHA256 */
152v_U8_t ccpRSNOui08[ HDD_RSN_OUI_SIZE ] = { 0x00, 0x0F, 0xAC, 0x05 };
Chet Lanctot186b5732013-03-18 10:26:30 -0700153#endif
Jeff Johnson295189b2012-06-20 16:38:30 -0700154
Shailender Karmuchia734f332013-04-19 14:02:48 -0700155#if defined(WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -0700156// Offset where the EID-Len-IE, start.
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700157#define FT_ASSOC_RSP_IES_OFFSET 6 /* Capability(2) + AID(2) + Status Code(2)*/
158#define FT_ASSOC_REQ_IES_OFFSET 4 /* Capability(2) + LI(2) */
Jeff Johnson295189b2012-06-20 16:38:30 -0700159#endif
160
161#define BEACON_FRAME_IES_OFFSET 12
162
Abhishek Singh78c691f2017-11-30 13:48:44 +0530163/* The time after add bss, in which SAP should start ECSA to move to SCC */
164#define ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL 1500
Abhishek Singh10e17cf2018-03-12 14:34:22 +0530165/*
166 * Time in ms after disconnect, in which the SAP should move to non DFS channel.
167 * This will avoid multiple SAP channel switch if disconnet is followed by
168 * connect.
169 */
170#define ECSA_DFS_CHAN_CHANGE_DEFER_TIME 200
Abhishek Singh78c691f2017-11-30 13:48:44 +0530171
Chet Lanctot186b5732013-03-18 10:26:30 -0700172#ifdef WLAN_FEATURE_11W
173void hdd_indicateUnprotMgmtFrame(hdd_adapter_t *pAdapter,
174 tANI_U32 nFrameLength,
175 tANI_U8* pbFrames,
176 tANI_U8 frameType );
177#endif
178
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800179#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700180static void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
181 tANI_U8 state,
182 tANI_U16 measInterval );
183static void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800184static void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo);
185static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter, const tCsrRoamInfo *pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700186
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800187#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -0700188
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530189static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter,
190 tCsrRoamInfo *pRoamInfo,
191 tANI_U32 roamId,
192 eRoamCmdStatus roamStatus,
193 eCsrRoamResult roamResult );
194
Madan Mohan Koyyalamudid5acbf52012-11-28 01:45:08 +0530195v_VOID_t hdd_connSetConnectionState( hdd_station_ctx_t *pHddStaCtx,
196 eConnectionState connState )
197{
198 // save the new connection state
Arun Kumar Khandavalli94a2bb02013-12-28 19:17:25 +0530199 hddLog(LOG1, FL("ConnectionState Changed from oldState:%d to State:%d"),
200 pHddStaCtx->conn_info.connState,connState);
Jeff Johnson295189b2012-06-20 16:38:30 -0700201 pHddStaCtx->conn_info.connState = connState;
202}
203
204// returns FALSE if not connected.
205// returns TRUE for the two 'connected' states (Infra Associated or IBSS Connected ).
206// returns the connection state. Can specify NULL if you dont' want to get the actual state.
207
Shailender Karmuchia734f332013-04-19 14:02:48 -0700208static inline v_BOOL_t hdd_connGetConnectionState( hdd_station_ctx_t *pHddStaCtx,
209 eConnectionState *pConnState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700210{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700211 v_BOOL_t fConnected;
Jeff Johnson295189b2012-06-20 16:38:30 -0700212 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700213
Jeff Johnson295189b2012-06-20 16:38:30 -0700214 // get the connection state.
215 connState = pHddStaCtx->conn_info.connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700216 // Set the fConnected return variable based on the Connected State.
Jeff Johnson295189b2012-06-20 16:38:30 -0700217 if ( eConnectionState_Associated == connState ||
Shailender Karmuchi642e9812013-05-30 14:34:49 -0700218 eConnectionState_IbssConnected == connState ||
219 eConnectionState_IbssDisconnected == connState)
Jeff Johnson295189b2012-06-20 16:38:30 -0700220 {
221 fConnected = VOS_TRUE;
222 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700223 else
Jeff Johnson295189b2012-06-20 16:38:30 -0700224 {
225 fConnected = VOS_FALSE;
226 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700227
Jeff Johnson295189b2012-06-20 16:38:30 -0700228 if ( pConnState )
229 {
230 *pConnState = connState;
231 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700232
Jeff Johnson295189b2012-06-20 16:38:30 -0700233 return( fConnected );
234}
235
236v_BOOL_t hdd_connIsConnected( hdd_station_ctx_t *pHddStaCtx )
237{
238 return( hdd_connGetConnectionState( pHddStaCtx, NULL ) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700239}
Jeff Johnson295189b2012-06-20 16:38:30 -0700240
Agarwal Ashish450ffde2014-04-08 19:53:00 +0530241eCsrBand hdd_connGetConnectedBand( hdd_station_ctx_t *pHddStaCtx )
242{
243 v_U8_t staChannel = 0;
244
245 if ( eConnectionState_Associated == pHddStaCtx->conn_info.connState )
246 {
247 staChannel = pHddStaCtx->conn_info.operationChannel;
248 }
249
250 if ( staChannel > 0 && staChannel < 14 )
251 return eCSR_BAND_24;
252 else if (staChannel >= 36 && staChannel <= 165 )
253 return eCSR_BAND_5G;
254 else /* If station is not connected return as eCSR_BAND_ALL */
255 return eCSR_BAND_ALL;
256}
257
258
Jeff Johnson295189b2012-06-20 16:38:30 -0700259//TODO - Not used anyhwere. Can be removed.
260#if 0
261//
262v_BOOL_t hdd_connIsConnectedInfra( hdd_adapter_t *pAdapter )
263{
264 v_BOOL_t fConnectedInfra = FALSE;
265 eConnectionState connState;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700266
Jeff Johnson295189b2012-06-20 16:38:30 -0700267 if ( hdd_connGetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), &connState ) )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700268 {
269 if ( eConnectionState_Associated == connState )
Jeff Johnson295189b2012-06-20 16:38:30 -0700270 {
271 fConnectedInfra = TRUE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700272 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700273 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700274
Jeff Johnson295189b2012-06-20 16:38:30 -0700275 return( fConnectedInfra );
276}
277#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -0700278
Jeff Johnson295189b2012-06-20 16:38:30 -0700279static inline v_BOOL_t hdd_connGetConnectedCipherAlgo( hdd_station_ctx_t *pHddStaCtx, eCsrEncryptionType *pConnectedCipherAlgo )
280{
281 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700282
Jeff Johnson295189b2012-06-20 16:38:30 -0700283 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700284
285 if ( pConnectedCipherAlgo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700286 {
287 *pConnectedCipherAlgo = pHddStaCtx->conn_info.ucEncryptionType;
288 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700289
Jeff Johnson295189b2012-06-20 16:38:30 -0700290 return( fConnected );
291}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700292
Jeff Johnson295189b2012-06-20 16:38:30 -0700293inline v_BOOL_t hdd_connGetConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eMib_dot11DesiredBssType *pConnectedBssType )
294{
295 v_BOOL_t fConnected = VOS_FALSE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700296
Jeff Johnson295189b2012-06-20 16:38:30 -0700297 fConnected = hdd_connGetConnectionState( pHddStaCtx, NULL );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700298
299 if ( pConnectedBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700300 {
301 *pConnectedBssType = pHddStaCtx->conn_info.connDot11DesiredBssType;
302 }
Shailender Karmuchia734f332013-04-19 14:02:48 -0700303
Jeff Johnson295189b2012-06-20 16:38:30 -0700304 return( fConnected );
305}
306
307static inline void hdd_connSaveConnectedBssType( hdd_station_ctx_t *pHddStaCtx, eCsrRoamBssType csrRoamBssType )
308{
Shailender Karmuchia734f332013-04-19 14:02:48 -0700309 switch( csrRoamBssType )
Jeff Johnson295189b2012-06-20 16:38:30 -0700310 {
311 case eCSR_BSS_TYPE_INFRASTRUCTURE:
312 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_infrastructure;
313 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700314
Jeff Johnson295189b2012-06-20 16:38:30 -0700315 case eCSR_BSS_TYPE_IBSS:
316 case eCSR_BSS_TYPE_START_IBSS:
317 pHddStaCtx->conn_info.connDot11DesiredBssType = eMib_dot11DesiredBssType_independent;
318 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700319
320 /** We will never set the BssType to 'any' when attempting a connection
Jeff Johnson295189b2012-06-20 16:38:30 -0700321 so CSR should never send this back to us.*/
Shailender Karmuchia734f332013-04-19 14:02:48 -0700322 case eCSR_BSS_TYPE_ANY:
Jeff Johnson295189b2012-06-20 16:38:30 -0700323 default:
324 VOS_ASSERT( 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700325 break;
326 }
327
Jeff Johnson295189b2012-06-20 16:38:30 -0700328}
329
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530330/**
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530331 * hdd_copy_ht_caps()- Populate kernel HT caps structure object
332 * @hdd_ht_cap: HT capabilities of kernel type
333 * @roam_ht_cap: HT capabilities maintained locally within driver
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530334 *
335 * Return: None
336 */
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530337void hdd_copy_ht_caps(struct ieee80211_ht_cap *hdd_ht_cap,
338 tDot11fIEHTCaps *roam_ht_cap)
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530339{
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530340 uint32_t i, temp_ht_cap;
341
342 vos_mem_zero(hdd_ht_cap, sizeof(struct ieee80211_ht_cap));
343
344 if (roam_ht_cap->advCodingCap)
345 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LDPC_CODING;
346 if (roam_ht_cap->supportedChannelWidthSet)
347 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SUP_WIDTH_20_40;
348 temp_ht_cap = roam_ht_cap->mimoPowerSave &
349 (IEEE80211_HT_CAP_SM_PS >> IEEE80211_HT_CAP_SM_PS_SHIFT);
350 if (temp_ht_cap)
351 hdd_ht_cap->cap_info |=
352 temp_ht_cap << IEEE80211_HT_CAP_SM_PS_SHIFT;
353 if (roam_ht_cap->greenField)
354 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_GRN_FLD;
355 if (roam_ht_cap->shortGI20MHz)
356 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_20;
357 if (roam_ht_cap->shortGI40MHz)
358 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_SGI_40;
359 if (roam_ht_cap->txSTBC)
360 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_TX_STBC;
361 temp_ht_cap = roam_ht_cap->rxSTBC & (IEEE80211_HT_CAP_RX_STBC >>
362 IEEE80211_HT_CAP_RX_STBC_SHIFT);
363 if (temp_ht_cap)
364 hdd_ht_cap->cap_info |=
365 temp_ht_cap << IEEE80211_HT_CAP_RX_STBC_SHIFT;
366 if (roam_ht_cap->delayedBA)
367 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DELAY_BA;
368 if (roam_ht_cap->maximalAMSDUsize)
369 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_MAX_AMSDU;
370 if (roam_ht_cap->dsssCckMode40MHz)
371 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_DSSSCCK40;
372 if (roam_ht_cap->psmp)
373 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_RESERVED;
374 if (roam_ht_cap->stbcControlFrame)
375 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_40MHZ_INTOLERANT;
376 if (roam_ht_cap->lsigTXOPProtection)
377 hdd_ht_cap->cap_info |= IEEE80211_HT_CAP_LSIG_TXOP_PROT;
378
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530379 /* 802.11n HT capability AMPDU settings (for ampdu_params_info) */
380 if (roam_ht_cap->maxRxAMPDUFactor)
381 hdd_ht_cap->ampdu_params_info |=
382 IEEE80211_HT_AMPDU_PARM_FACTOR;
383 temp_ht_cap = roam_ht_cap->mpduDensity &
384 (IEEE80211_HT_AMPDU_PARM_DENSITY >>
385 IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT);
386 if (temp_ht_cap)
387 hdd_ht_cap->ampdu_params_info |=
388 temp_ht_cap << IEEE80211_HT_AMPDU_PARM_DENSITY_SHIFT;
389
390 /* 802.11n HT extended capabilities masks */
391 if (roam_ht_cap->pco)
392 hdd_ht_cap->extended_ht_cap_info |=
393 IEEE80211_HT_EXT_CAP_PCO;
394 temp_ht_cap = roam_ht_cap->transitionTime &
395 (IEEE80211_HT_EXT_CAP_PCO_TIME >>
396 IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT);
397 if (temp_ht_cap)
398 hdd_ht_cap->extended_ht_cap_info |=
399 temp_ht_cap << IEEE80211_HT_EXT_CAP_PCO_TIME_SHIFT;
400 temp_ht_cap = roam_ht_cap->mcsFeedback &
401 (IEEE80211_HT_EXT_CAP_MCS_FB >> IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT);
402 if (temp_ht_cap)
403 hdd_ht_cap->extended_ht_cap_info |=
404 temp_ht_cap << IEEE80211_HT_EXT_CAP_MCS_FB_SHIFT;
405
406 /* tx_bf_cap_info capabilities */
407 if (roam_ht_cap->txBF)
408 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_BF;
409 if (roam_ht_cap->rxStaggeredSounding)
410 hdd_ht_cap->tx_BF_cap_info |=
411 TX_BF_CAP_INFO_RX_STAG_RED_SOUNDING;
412 if (roam_ht_cap->txStaggeredSounding)
413 hdd_ht_cap->tx_BF_cap_info |=
414 TX_BF_CAP_INFO_TX_STAG_RED_SOUNDING;
415 if (roam_ht_cap->rxZLF)
416 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_RX_ZFL;
417 if (roam_ht_cap->txZLF)
418 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_TX_ZFL;
419 if (roam_ht_cap->implicitTxBF)
420 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_IMP_TX_BF;
421 temp_ht_cap = roam_ht_cap->calibration &
422 (TX_BF_CAP_INFO_CALIBRATION >> TX_BF_CAP_INFO_CALIBRATION_SHIFT);
423 if (temp_ht_cap)
424 hdd_ht_cap->tx_BF_cap_info |=
425 temp_ht_cap << TX_BF_CAP_INFO_CALIBRATION_SHIFT;
426 if (roam_ht_cap->explicitCSITxBF)
427 hdd_ht_cap->tx_BF_cap_info |= TX_BF_CAP_INFO_EXP_CSIT_BF;
428 if (roam_ht_cap->explicitUncompressedSteeringMatrix)
429 hdd_ht_cap->tx_BF_cap_info |=
430 TX_BF_CAP_INFO_EXP_UNCOMP_STEER_MAT;
431 temp_ht_cap = roam_ht_cap->explicitBFCSIFeedback &
432 (TX_BF_CAP_INFO_EXP_BF_CSI_FB >>
433 TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT);
434 if (temp_ht_cap)
435 hdd_ht_cap->tx_BF_cap_info |=
436 temp_ht_cap << TX_BF_CAP_INFO_EXP_BF_CSI_FB_SHIFT;
437 temp_ht_cap =
438 roam_ht_cap->explicitUncompressedSteeringMatrixFeedback &
439 (TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT >>
440 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT);
441 if (temp_ht_cap)
442 hdd_ht_cap->tx_BF_cap_info |=
443 temp_ht_cap <<
444 TX_BF_CAP_INFO_EXP_UNCMP_STEER_MAT_SHIFT;
445 temp_ht_cap =
446 roam_ht_cap->explicitCompressedSteeringMatrixFeedback &
447 (TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB >>
448 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT);
449 if (temp_ht_cap)
450 hdd_ht_cap->tx_BF_cap_info |=
451 temp_ht_cap <<
452 TX_BF_CAP_INFO_EXP_CMP_STEER_MAT_FB_SHIFT;
453 temp_ht_cap = roam_ht_cap->csiNumBFAntennae &
454 (TX_BF_CAP_INFO_CSI_NUM_BF_ANT >>
455 TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT);
456 if (temp_ht_cap)
457 hdd_ht_cap->tx_BF_cap_info |=
458 temp_ht_cap << TX_BF_CAP_INFO_CSI_NUM_BF_ANT_SHIFT;
459 temp_ht_cap = roam_ht_cap->uncompressedSteeringMatrixBFAntennae &
460 (TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT >>
461 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT);
462 if (temp_ht_cap)
463 hdd_ht_cap->tx_BF_cap_info |=
464 temp_ht_cap <<
465 TX_BF_CAP_INFO_UNCOMP_STEER_MAT_BF_ANT_SHIFT;
466 temp_ht_cap = roam_ht_cap->compressedSteeringMatrixBFAntennae &
467 (TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT >>
468 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT);
469 if (temp_ht_cap)
470 hdd_ht_cap->tx_BF_cap_info |=
471 temp_ht_cap <<
472 TX_BF_CAP_INFO_COMP_STEER_MAT_BF_ANT_SHIFT;
473
474 /* antenna selection */
475 if (roam_ht_cap->antennaSelection)
476 hdd_ht_cap->antenna_selection_info |= ANTENNA_SEL_INFO;
477 if (roam_ht_cap->explicitCSIFeedbackTx)
478 hdd_ht_cap->antenna_selection_info |=
479 ANTENNA_SEL_INFO_EXP_CSI_FB_TX;
480 if (roam_ht_cap->antennaIndicesFeedbackTx)
481 hdd_ht_cap->antenna_selection_info |=
482 ANTENNA_SEL_INFO_ANT_ID_FB_TX;
483 if (roam_ht_cap->explicitCSIFeedback)
484 hdd_ht_cap->antenna_selection_info |=
485 ANTENNA_SEL_INFO_EXP_CSI_FB;
486 if (roam_ht_cap->antennaIndicesFeedback)
487 hdd_ht_cap->antenna_selection_info |=
488 ANTENNA_SEL_INFO_ANT_ID_FB;
489 if (roam_ht_cap->rxAS)
490 hdd_ht_cap->antenna_selection_info |=
491 ANTENNA_SEL_INFO_RX_AS;
492 if (roam_ht_cap->txSoundingPPDUs)
493 hdd_ht_cap->antenna_selection_info |=
494 ANTENNA_SEL_INFO_TX_SOUNDING_PPDU;
495
496 /* mcs data rate */
497 for (i = 0; i < IEEE80211_HT_MCS_MASK_LEN; ++i)
498 hdd_ht_cap->mcs.rx_mask[i] =
499 roam_ht_cap->supportedMCSSet[i];
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530500
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530501 hdd_ht_cap->mcs.rx_highest =
502 ((short) (roam_ht_cap->supportedMCSSet[11]) << 8) |
503 ((short) (roam_ht_cap->supportedMCSSet[10]));
504 hdd_ht_cap->mcs.tx_params =
505 roam_ht_cap->supportedMCSSet[12];
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530506
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530507}
508
509
510#define VHT_CAP_MAX_MPDU_LENGTH_MASK 0x00000003
511#define VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT 2
512#define VHT_CAP_RXSTBC_MASK_SHIFT 8
513#define VHT_CAP_BEAMFORMEE_STS_SHIFT 13
514#define VHT_CAP_BEAMFORMEE_STS_MASK \
515 (0x0000e000 >> VHT_CAP_BEAMFORMEE_STS_SHIFT)
516#define VHT_CAP_SOUNDING_DIMENSIONS_SHIFT 16
517#define VHT_CAP_SOUNDING_DIMENSIONS_MASK \
518 (0x00070000 >> VHT_CAP_SOUNDING_DIMENSIONS_SHIFT)
519#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT 23
520#define VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK \
521 (0x03800000 >> VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT)
522#define VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT 26
523
524/**
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530525 * hdd_copy_vht_caps()- Populate kernel VHT caps structure object
526 * @hdd_ht_cap: VHT capabilities of kernel type
527 * @roam_ht_cap: VHT capabilities maintained locally within driver
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530528 *
529 * Return: None
530 */
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530531void hdd_copy_vht_caps(struct ieee80211_vht_cap *hdd_vht_cap,
532 tDot11fIEVHTCaps *roam_vht_cap)
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530533{
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530534 uint32_t temp_vht_cap;
535
536 vos_mem_zero(hdd_vht_cap, sizeof(struct ieee80211_vht_cap));
537
538 temp_vht_cap = roam_vht_cap->maxMPDULen & VHT_CAP_MAX_MPDU_LENGTH_MASK;
539 hdd_vht_cap->vht_cap_info |= temp_vht_cap;
540 temp_vht_cap = roam_vht_cap->supportedChannelWidthSet &
541 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_MASK >>
542 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT);
543 if (temp_vht_cap)
544 if (roam_vht_cap->supportedChannelWidthSet &
545 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ >>
546 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
547 hdd_vht_cap->vht_cap_info |=
548 temp_vht_cap <<
549 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160MHZ;
550 if (roam_vht_cap->supportedChannelWidthSet &
551 (IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ >>
552 VHT_CAP_SUPP_CHAN_WIDTH_MASK_SHIFT))
553 hdd_vht_cap->vht_cap_info |=
554 temp_vht_cap <<
555 IEEE80211_VHT_CAP_SUPP_CHAN_WIDTH_160_80PLUS80MHZ;
556 if (roam_vht_cap->ldpcCodingCap)
557 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_RXLDPC;
558 if (roam_vht_cap->shortGI80MHz)
559 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_80;
560 if (roam_vht_cap->shortGI160and80plus80MHz)
561 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_SHORT_GI_160;
562 if (roam_vht_cap->txSTBC)
563 hdd_vht_cap->vht_cap_info |= IEEE80211_VHT_CAP_TXSTBC;
564 temp_vht_cap = roam_vht_cap->rxSTBC & (IEEE80211_VHT_CAP_RXSTBC_MASK >>
565 VHT_CAP_RXSTBC_MASK_SHIFT);
566 if (temp_vht_cap)
567 hdd_vht_cap->vht_cap_info |=
568 temp_vht_cap << VHT_CAP_RXSTBC_MASK_SHIFT;
569 if (roam_vht_cap->suBeamFormerCap)
570 hdd_vht_cap->vht_cap_info |=
571 IEEE80211_VHT_CAP_SU_BEAMFORMER_CAPABLE;
572 if (roam_vht_cap->suBeamformeeCap)
573 hdd_vht_cap->vht_cap_info |=
574 IEEE80211_VHT_CAP_SU_BEAMFORMEE_CAPABLE;
575 temp_vht_cap = roam_vht_cap->csnofBeamformerAntSup &
576 (VHT_CAP_BEAMFORMEE_STS_MASK);
577 if (temp_vht_cap)
578 hdd_vht_cap->vht_cap_info |=
579 temp_vht_cap << VHT_CAP_BEAMFORMEE_STS_SHIFT;
580 temp_vht_cap = roam_vht_cap->numSoundingDim &
581 (VHT_CAP_SOUNDING_DIMENSIONS_MASK);
582 if (temp_vht_cap)
583 hdd_vht_cap->vht_cap_info |=
584 temp_vht_cap << VHT_CAP_SOUNDING_DIMENSIONS_SHIFT;
585 if (roam_vht_cap->muBeamformerCap)
586 hdd_vht_cap->vht_cap_info |=
587 IEEE80211_VHT_CAP_MU_BEAMFORMER_CAPABLE;
588 if (roam_vht_cap->muBeamformeeCap)
589 hdd_vht_cap->vht_cap_info |=
590 IEEE80211_VHT_CAP_MU_BEAMFORMEE_CAPABLE;
591 if (roam_vht_cap->vhtTXOPPS)
592 hdd_vht_cap->vht_cap_info |=
593 IEEE80211_VHT_CAP_VHT_TXOP_PS;
594 if (roam_vht_cap->htcVHTCap)
595 hdd_vht_cap->vht_cap_info |=
596 IEEE80211_VHT_CAP_HTC_VHT;
597 temp_vht_cap = roam_vht_cap->maxAMPDULenExp &
598 (VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK);
599 if (temp_vht_cap)
600 hdd_vht_cap->vht_cap_info |=
601 temp_vht_cap <<
602 VHT_CAP_MAX_A_MPDU_LENGTH_EXPONENT_MASK_SHIFT;
603 temp_vht_cap = roam_vht_cap->vhtLinkAdaptCap &
604 (IEEE80211_VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB >>
605 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT);
606 if (temp_vht_cap)
607 hdd_vht_cap->vht_cap_info |= temp_vht_cap <<
608 VHT_CAP_VHT_LINK_ADAPTATION_VHT_MRQ_MFB_SHIFT;
609 if (roam_vht_cap->rxAntPattern)
610 hdd_vht_cap->vht_cap_info |=
611 IEEE80211_VHT_CAP_RX_ANTENNA_PATTERN;
612 if (roam_vht_cap->txAntPattern)
613 hdd_vht_cap->vht_cap_info |=
614 IEEE80211_VHT_CAP_TX_ANTENNA_PATTERN;
615 hdd_vht_cap->supp_mcs.rx_mcs_map = roam_vht_cap->rxMCSMap;
616 hdd_vht_cap->supp_mcs.rx_highest =
617 ((uint16_t)roam_vht_cap->rxHighSupDataRate);
618 hdd_vht_cap->supp_mcs.tx_mcs_map = roam_vht_cap->txMCSMap;
619 hdd_vht_cap->supp_mcs.tx_highest =
620 ((uint16_t)roam_vht_cap->txSupDataRate);
621}
622
623/* ht param */
624#define HT_PARAM_CONTROLLED_ACCESS_ONLY 0x10
625#define HT_PARAM_SERVICE_INT_GRAN 0xe0
626#define HT_PARAM_SERVICE_INT_GRAN_SHIFT 5
627
628/* operatinon mode */
629#define HT_OP_MODE_TX_BURST_LIMIT 0x0008
630
631/* stbc_param */
632#define HT_STBC_PARAM_MCS 0x007f
633
634/**
635 * hdd_copy_ht_operation()- copy HT operation element from roam info to
636 * hdd station context.
637 * @hdd_sta_ctx: pointer to hdd station context
638 * @roam_info: pointer to roam info
639 *
640 * Return: None
641 */
642static void hdd_copy_ht_operation(hdd_station_ctx_t *hdd_sta_ctx,
643 tCsrRoamInfo *roam_info)
644{
645 tDot11fIEHTInfo *roam_ht_ops = &roam_info->ht_operation;
646 struct ieee80211_ht_operation *hdd_ht_ops =
647 &hdd_sta_ctx->conn_info.ht_operation;
648 uint32_t i, temp_ht_ops;
649
650 vos_mem_zero(hdd_ht_ops, sizeof(struct ieee80211_ht_operation));
651
652 hdd_ht_ops->primary_chan = roam_ht_ops->primaryChannel;
653
654 /* HT_PARAMS */
655 temp_ht_ops = roam_ht_ops->secondaryChannelOffset &
656 IEEE80211_HT_PARAM_CHA_SEC_OFFSET;
657 if (temp_ht_ops)
658 hdd_ht_ops->ht_param |= temp_ht_ops;
659 else
660 hdd_ht_ops->ht_param = IEEE80211_HT_PARAM_CHA_SEC_NONE;
661 if (roam_ht_ops->recommendedTxWidthSet)
662 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_CHAN_WIDTH_ANY;
663 if (roam_ht_ops->rifsMode)
664 hdd_ht_ops->ht_param |= IEEE80211_HT_PARAM_RIFS_MODE;
665 if (roam_ht_ops->controlledAccessOnly)
666 hdd_ht_ops->ht_param |= HT_PARAM_CONTROLLED_ACCESS_ONLY;
667 temp_ht_ops = roam_ht_ops->serviceIntervalGranularity &
668 (HT_PARAM_SERVICE_INT_GRAN >> HT_PARAM_SERVICE_INT_GRAN_SHIFT);
669 if (temp_ht_ops)
670 hdd_ht_ops->ht_param |= temp_ht_ops <<
671 HT_PARAM_SERVICE_INT_GRAN_SHIFT;
672
673 /* operation mode */
674 temp_ht_ops = roam_ht_ops->opMode &
675 IEEE80211_HT_OP_MODE_PROTECTION;
676 switch (temp_ht_ops) {
677 case IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER:
678 hdd_ht_ops->operation_mode |=
679 IEEE80211_HT_OP_MODE_PROTECTION_NONMEMBER;
680 break;
681 case IEEE80211_HT_OP_MODE_PROTECTION_20MHZ:
682 hdd_ht_ops->operation_mode |=
683 IEEE80211_HT_OP_MODE_PROTECTION_20MHZ;
684 break;
685 case IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED:
686 hdd_ht_ops->operation_mode |=
687 IEEE80211_HT_OP_MODE_PROTECTION_NONHT_MIXED;
688 break;
689 case IEEE80211_HT_OP_MODE_PROTECTION_NONE:
690 default:
691 hdd_ht_ops->operation_mode |=
692 IEEE80211_HT_OP_MODE_PROTECTION_NONE;
693 }
694 if (roam_ht_ops->nonGFDevicesPresent)
695 hdd_ht_ops->operation_mode |=
696 IEEE80211_HT_OP_MODE_NON_GF_STA_PRSNT;
697 if (roam_ht_ops->transmitBurstLimit)
698 hdd_ht_ops->operation_mode |=
699 HT_OP_MODE_TX_BURST_LIMIT;
700 if (roam_ht_ops->obssNonHTStaPresent)
701 hdd_ht_ops->operation_mode |=
702 IEEE80211_HT_OP_MODE_NON_HT_STA_PRSNT;
703
704 /* stbc_param */
705 temp_ht_ops = roam_ht_ops->basicSTBCMCS &
706 HT_STBC_PARAM_MCS;
707 if (temp_ht_ops)
708 hdd_ht_ops->stbc_param |= temp_ht_ops;
709 if (roam_ht_ops->dualCTSProtection)
710 hdd_ht_ops->stbc_param |=
711 IEEE80211_HT_STBC_PARAM_DUAL_CTS_PROT;
712 if (roam_ht_ops->secondaryBeacon)
713 hdd_ht_ops->stbc_param |=
714 IEEE80211_HT_STBC_PARAM_STBC_BEACON;
715 if (roam_ht_ops->lsigTXOPProtectionFullSupport)
716 hdd_ht_ops->stbc_param |=
717 IEEE80211_HT_STBC_PARAM_LSIG_TXOP_FULLPROT;
718 if (roam_ht_ops->pcoActive)
719 hdd_ht_ops->stbc_param |=
720 IEEE80211_HT_STBC_PARAM_PCO_ACTIVE;
721 if (roam_ht_ops->pcoPhase)
722 hdd_ht_ops->stbc_param |=
723 IEEE80211_HT_STBC_PARAM_PCO_PHASE;
724
725 /* basic MCs set */
726 for (i = 0; i < 16; ++i)
727 hdd_ht_ops->basic_set[i] =
728 roam_ht_ops->basicMCSSet[i];
729}
730
731/**
732 * hdd_copy_vht_operation()- copy VHT operations element from roam info to
733 * hdd station context.
734 * @hdd_sta_ctx: pointer to hdd station context
735 * @roam_info: pointer to roam info
736 *
737 * Return: None
738 */
739static void hdd_copy_vht_operation(hdd_station_ctx_t *hdd_sta_ctx,
740 tCsrRoamInfo *roam_info)
741{
742 tDot11fIEVHTOperation *roam_vht_ops = &roam_info->vht_operation;
743 struct ieee80211_vht_operation *hdd_vht_ops =
744 &hdd_sta_ctx->conn_info.vht_operation;
745
746 vos_mem_zero(hdd_vht_ops, sizeof(struct ieee80211_vht_operation));
747
748 hdd_vht_ops->chan_width = roam_vht_ops->chanWidth;
749 hdd_vht_ops->center_freq_seg1_idx = roam_vht_ops->chanCenterFreqSeg1;
750 hdd_vht_ops->center_freq_seg2_idx = roam_vht_ops->chanCenterFreqSeg2;
751 hdd_vht_ops->basic_mcs_set = roam_vht_ops->basicMCSSet;
752}
753
754
755/**
756 * hdd_save_bss_info() - save connection info in hdd sta ctx
757 * @adapter: Pointer to adapter
758 * @roam_info: pointer to roam info
759 *
760 * Return: None
761 */
762static void hdd_save_bss_info(hdd_adapter_t *adapter,
763 tCsrRoamInfo *roam_info)
764{
765 hdd_station_ctx_t *hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
766
767 hdd_sta_ctx->conn_info.freq = vos_chan_to_freq(
768 hdd_sta_ctx->conn_info.operationChannel);
769 if (roam_info->vht_caps.present) {
770 hdd_sta_ctx->conn_info.conn_flag.vht_present = true;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530771 hdd_copy_vht_caps(&hdd_sta_ctx->conn_info.vht_caps,
772 &roam_info->vht_caps);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530773 } else {
774 hdd_sta_ctx->conn_info.conn_flag.vht_present = false;
775 }
776 if (roam_info->ht_caps.present) {
777 hdd_sta_ctx->conn_info.conn_flag.ht_present = true;
Hanumanth Reddy Pothula57323632017-12-06 17:55:09 +0530778 hdd_copy_ht_caps(&hdd_sta_ctx->conn_info.ht_caps, &roam_info->ht_caps);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530779 } else {
780 hdd_sta_ctx->conn_info.conn_flag.ht_present = false;
781 }
782 if (roam_info->reassoc)
783 hdd_sta_ctx->conn_info.roam_count++;
784 if (roam_info->hs20vendor_ie.present) {
785 hdd_sta_ctx->conn_info.conn_flag.hs20_present = true;
786 vos_mem_copy(&hdd_sta_ctx->conn_info.hs20vendor_ie,
787 &roam_info->hs20vendor_ie,
788 sizeof(roam_info->hs20vendor_ie));
789 } else {
790 hdd_sta_ctx->conn_info.conn_flag.hs20_present = false;
791 }
792 if (roam_info->ht_operation.present) {
793 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = true;
794 hdd_copy_ht_operation(hdd_sta_ctx, roam_info);
795 } else {
796 hdd_sta_ctx->conn_info.conn_flag.ht_op_present = false;
797 }
798 if (roam_info->vht_operation.present) {
799 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = true;
800 hdd_copy_vht_operation(hdd_sta_ctx, roam_info);
801 } else {
802 hdd_sta_ctx->conn_info.conn_flag.vht_op_present = false;
803 }
Ashish Kumar Dhanotiyabb8d2302018-02-22 00:37:26 +0530804 /* Cache last connection info */
805 vos_mem_copy(&hdd_sta_ctx->cache_conn_info, &hdd_sta_ctx->conn_info,
806 sizeof(connection_info_t));
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530807}
808
Jeff Johnson295189b2012-06-20 16:38:30 -0700809void hdd_connSaveConnectInfo( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo, eCsrRoamBssType eBssType )
810{
811 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
812 eCsrEncryptionType encryptType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700813
Jeff Johnson295189b2012-06-20 16:38:30 -0700814 VOS_ASSERT( pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700815
816 if ( pRoamInfo )
Jeff Johnson295189b2012-06-20 16:38:30 -0700817 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700818 // Save the BSSID for the connection...
Jeff Johnson295189b2012-06-20 16:38:30 -0700819 if ( eCSR_BSS_TYPE_INFRASTRUCTURE == eBssType )
820 {
821 VOS_ASSERT( pRoamInfo->pBssDesc );
822 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,6 );
823
824 // Save the Station ID for this station from the 'Roam Info'.
825 //For IBSS mode, staId is assigned in NEW_PEER_IND
826 //For reassoc, the staID doesn't change and it may be invalid in this structure
827 //so no change here.
828 if( !pRoamInfo->fReassocReq )
829 {
830 pHddStaCtx->conn_info.staId [0]= pRoamInfo->staId;
831 }
832 }
833 else if ( eCSR_BSS_TYPE_IBSS == eBssType )
Shailender Karmuchia734f332013-04-19 14:02:48 -0700834 {
Jeff Johnson295189b2012-06-20 16:38:30 -0700835 vos_mem_copy(pHddStaCtx->conn_info.bssId, pRoamInfo->bssid,sizeof(pRoamInfo->bssid) );
Shailender Karmuchia734f332013-04-19 14:02:48 -0700836 }
Jeff Johnson295189b2012-06-20 16:38:30 -0700837 else
838 {
839 // can't happen. We need a valid IBSS or Infra setting in the BSSDescription
840 // or we can't function.
841 VOS_ASSERT( 0 );
842 }
843
844 // notify WMM
845 hdd_wmm_connect(pAdapter, pRoamInfo, eBssType);
846
847 if( !pRoamInfo->u.pConnectedProfile )
848 {
849 VOS_ASSERT( pRoamInfo->u.pConnectedProfile );
850 }
851 else
852 {
853 // Get Multicast Encryption Type
854 encryptType = pRoamInfo->u.pConnectedProfile->mcEncryptionType;
855 pHddStaCtx->conn_info.mcEncryptionType = encryptType;
856 // Get Unicast Encrytion Type
857 encryptType = pRoamInfo->u.pConnectedProfile->EncryptionType;
858 pHddStaCtx->conn_info.ucEncryptionType = encryptType;
859
860 pHddStaCtx->conn_info.authType = pRoamInfo->u.pConnectedProfile->AuthType;
861
862 pHddStaCtx->conn_info.operationChannel = pRoamInfo->u.pConnectedProfile->operationChannel;
863
864 // Save the ssid for the connection
865 vos_mem_copy( &pHddStaCtx->conn_info.SSID.SSID, &pRoamInfo->u.pConnectedProfile->SSID, sizeof( tSirMacSSid ) );
Gopichand Nakkaladacbcb52013-04-18 16:41:54 +0530866
867 // Save dot11mode in which STA associated to AP
868 pHddStaCtx->conn_info.dot11Mode = pRoamInfo->u.pConnectedProfile->dot11Mode;
Deepthi Gowriae6a1662015-10-12 12:59:37 +0530869
870 pHddStaCtx->conn_info.rate_flags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -0700871 }
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +0530872 hdd_save_bss_info(pAdapter, pRoamInfo);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700873 }
874
Jeff Johnson295189b2012-06-20 16:38:30 -0700875 // save the connected BssType
Shailender Karmuchia734f332013-04-19 14:02:48 -0700876 hdd_connSaveConnectedBssType( pHddStaCtx, eBssType );
877
Jeff Johnson295189b2012-06-20 16:38:30 -0700878}
879
880#if defined(WLAN_FEATURE_VOWIFI_11R)
881/*
882 * Send the 11R key information to the supplicant.
883 * Only then can the supplicant generate the PMK-R1.
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -0800884 * (BTW, the ESE supplicant also needs the Assoc Resp IEs
Jeff Johnson295189b2012-06-20 16:38:30 -0700885 * for the same purpose.)
886 *
887 * Mainly the Assoc Rsp IEs are passed here. For the IMDA
888 * this contains the R1KHID, R0KHID and the MDID.
889 * For FT, this consists of the Reassoc Rsp FTIEs.
890 * This is the Assoc Response.
891 */
Shailender Karmuchia734f332013-04-19 14:02:48 -0700892static void hdd_SendFTAssocResponse(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -0700893 tCsrRoamInfo *pCsrRoamInfo)
894{
895 union iwreq_data wrqu;
896 char *buff;
897 unsigned int len = 0;
898 u8 *pFTAssocRsp = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700899
900 if (pCsrRoamInfo->nAssocRspLength == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -0700901 {
902 hddLog(LOGE,
903 "%s: pCsrRoamInfo->nAssocRspLength=%d",
904 __func__, (int)pCsrRoamInfo->nAssocRspLength);
905 return;
906 }
907
Shailender Karmuchia734f332013-04-19 14:02:48 -0700908 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
Jeff Johnson295189b2012-06-20 16:38:30 -0700909 pCsrRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700910 if (pFTAssocRsp == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700911 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700912 hddLog(LOGE, "%s: AssocReq or AssocRsp is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700913 return;
914 }
915
916 // pFTAssocRsp needs to point to the IEs
917 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
918 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
919 (unsigned int)pFTAssocRsp[0],
920 (unsigned int)pFTAssocRsp[1]);
921
922 // We need to send the IEs to the supplicant.
923 buff = kmalloc(IW_GENERIC_IE_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700924 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -0700925 {
Shailender Karmuchia734f332013-04-19 14:02:48 -0700926 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -0700927 return;
928 }
929
930 // Send the Assoc Resp, the supplicant needs this for initial Auth.
931 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Shailender Karmuchia734f332013-04-19 14:02:48 -0700932 wrqu.data.length = len;
Jeff Johnson295189b2012-06-20 16:38:30 -0700933 memset(buff, 0, IW_GENERIC_IE_MAX);
Shailender Karmuchia734f332013-04-19 14:02:48 -0700934 memcpy(buff, pFTAssocRsp, len);
Jeff Johnson295189b2012-06-20 16:38:30 -0700935 wireless_send_event(dev, IWEVASSOCRESPIE, &wrqu, buff);
936
937 kfree(buff);
938}
Shailender Karmuchia734f332013-04-19 14:02:48 -0700939#endif /* WLAN_FEATURE_VOWIFI_11R */
Jeff Johnson295189b2012-06-20 16:38:30 -0700940
941#ifdef WLAN_FEATURE_VOWIFI_11R
942
943/*---------------------------------------------------
944 *
945 * Send the FTIEs, RIC IEs during FT. This is eventually
946 * used to send the FT events to the supplicant
947 *
948 * At the reception of Auth2 we send the RIC followed
949 * by the auth response IEs to the supplicant.
950 * Once both are received in the supplicant, an FT
951 * event is generated to the supplicant.
952 *
953 *---------------------------------------------------
954 */
955void hdd_SendFTEvent(hdd_adapter_t *pAdapter)
956{
Jeff Johnson295189b2012-06-20 16:38:30 -0700957 tANI_U16 auth_resp_len = 0;
958 tANI_U32 ric_ies_length = 0;
Jeff Johnson295189b2012-06-20 16:38:30 -0700959 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
960
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530961#if defined(KERNEL_SUPPORT_11R_CFG80211)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700962 struct cfg80211_ft_event_params ftEvent;
963 v_U8_t ftIe[DOT11F_IE_FTINFO_MAX_LEN];
964 v_U8_t ricIe[DOT11F_IE_RICDESCRIPTOR_MAX_LEN];
965 struct net_device *dev = pAdapter->dev;
966#else
967 char *buff;
968 union iwreq_data wrqu;
969 tANI_U16 str_len;
970#endif
971
Gopichand Nakkala66923aa2013-03-06 23:17:24 +0530972#if defined(KERNEL_SUPPORT_11R_CFG80211)
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530973 vos_mem_zero(ftIe, DOT11F_IE_FTINFO_MAX_LEN);
974 vos_mem_zero(ricIe, DOT11F_IE_RICDESCRIPTOR_MAX_LEN);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700975
Kanchanapally, Vidyullatha31b8d142015-01-30 14:25:18 +0530976 sme_GetRICIEs(pHddCtx->hHal, (u8 *)ricIe,
977 DOT11F_IE_RICDESCRIPTOR_MAX_LEN, &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530978 if (ric_ies_length == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700979 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530980 hddLog(LOGW,
981 "%s: RIC IEs is of length 0 not sending RIC Information for now",
982 __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700983 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700984
985 ftEvent.ric_ies = ricIe;
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530986 ftEvent.ric_ies_len = ric_ies_length;
987 hddLog(LOG1, "%s: RIC IEs is of length %d", __func__, (int)ric_ies_length);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700988
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530989 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)ftIe,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -0800990 DOT11F_IE_FTINFO_MAX_LEN, &auth_resp_len);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700991
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530992 if (auth_resp_len == 0)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700993 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +0530994 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -0700995 return;
996 }
997
Gopichand Nakkala3d295922013-05-07 16:19:14 +0530998 sme_SetFTPreAuthState(pHddCtx->hHal, TRUE);
Gopichand Nakkala356fb102013-03-06 12:34:04 +0530999
Gopichand Nakkala3d295922013-05-07 16:19:14 +05301000 ftEvent.target_ap = ftIe;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001001
1002 ftEvent.ies = (u8 *)(ftIe + SIR_MAC_ADDR_LENGTH);
1003 ftEvent.ies_len = auth_resp_len - SIR_MAC_ADDR_LENGTH;
1004
Jeff Johnson59a121e2013-11-30 09:46:08 -08001005 hddLog(LOG1, "%s ftEvent.ies_len %zu", __FUNCTION__, ftEvent.ies_len);
1006 hddLog(LOG1, "%s ftEvent.ric_ies_len %zu",
1007 __FUNCTION__, ftEvent.ric_ies_len );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301008 hddLog(LOG1, "%s ftEvent.target_ap %2x-%2x-%2x-%2x-%2x-%2x ",
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001009 __FUNCTION__, ftEvent.target_ap[0], ftEvent.target_ap[1],
1010 ftEvent.target_ap[2], ftEvent.target_ap[3], ftEvent.target_ap[4],
1011 ftEvent.target_ap[5]);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001012
Gopichand Nakkala356fb102013-03-06 12:34:04 +05301013 (void)cfg80211_ft_event(dev, &ftEvent);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001014
1015#else
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301016 // We need to send the IEs to the supplicant
Jeff Johnson295189b2012-06-20 16:38:30 -07001017 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301018 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001019 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301020 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001021 return;
1022 }
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301023 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001024
Shailender Karmuchia734f332013-04-19 14:02:48 -07001025 // Sme needs to send the RIC IEs first
Jeff Johnson295189b2012-06-20 16:38:30 -07001026 str_len = strlcpy(buff, "RIC=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301027 sme_GetRICIEs( pHddCtx->hHal, (u8 *)&(buff[str_len]),
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08001028 (IW_CUSTOM_MAX - str_len), &ric_ies_length );
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301029 if (ric_ies_length == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001030 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301031 hddLog(LOGW,
1032 "%s: RIC IEs is of length 0 not sending RIC Information for now",
1033 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001034 }
1035 else
1036 {
1037 wrqu.data.length = str_len + ric_ies_length;
1038 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1039 }
1040
1041 // Sme needs to provide the Auth Resp
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301042 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001043 str_len = strlcpy(buff, "AUTH=", IW_CUSTOM_MAX);
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301044 sme_GetFTPreAuthResponse(pHddCtx->hHal, (u8 *)&buff[str_len],
1045 (IW_CUSTOM_MAX - str_len), &auth_resp_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07001046
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301047 if (auth_resp_len == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07001048 {
Gopichand Nakkalad7d13652013-02-15 01:48:00 +05301049 hddLog(LOGE, "%s: AuthRsp FTIES is of length 0", __func__);
Bhargav Shah8b5b2f72015-07-14 11:53:46 +05301050 kfree(buff);
Jeff Johnson295189b2012-06-20 16:38:30 -07001051 return;
1052 }
1053
1054 wrqu.data.length = str_len + auth_resp_len;
1055 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1056
1057 kfree(buff);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07001058#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001059}
1060
1061#endif /* WLAN_FEATURE_VOWIFI_11R */
1062
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001063#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001064
1065/*
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001066 * Send the ESE required "new AP Channel info" to the supplicant.
Jeff Johnson295189b2012-06-20 16:38:30 -07001067 * (This keeps the supplicant "up to date" on the current channel.)
1068 *
1069 * The current (new AP) channel information is passed in.
1070 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001071static void hdd_SendNewAPChannelInfo(struct net_device *dev, hdd_adapter_t *pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07001072 tCsrRoamInfo *pCsrRoamInfo)
1073{
1074 union iwreq_data wrqu;
1075 tSirBssDescription *descriptor = pCsrRoamInfo->pBssDesc;
Jeff Johnson295189b2012-06-20 16:38:30 -07001076
Shailender Karmuchia734f332013-04-19 14:02:48 -07001077
1078 if (descriptor == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001079 {
1080 hddLog(LOGE,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07001081 "%s: pCsrRoamInfo->pBssDesc=%pK",
Jeff Johnson295189b2012-06-20 16:38:30 -07001082 __func__, descriptor);
1083 return;
1084 }
1085
1086 // Send the Channel event, the supplicant needs this to generate the Adjacent AP report.
Arif Hussain6d2a3322013-11-17 19:50:10 -08001087 hddLog(LOGW, "%s: Sending up an SIOCGIWFREQ, channelId=%d", __func__, descriptor->channelId);
Jeff Johnson295189b2012-06-20 16:38:30 -07001088 memset(&wrqu, '\0', sizeof(wrqu));
1089 wrqu.freq.m = descriptor->channelId;
1090 wrqu.freq.e = 0;
1091 wrqu.freq.i = 0;
1092 wireless_send_event(pAdapter->dev, SIOCGIWFREQ, &wrqu, NULL);
1093}
1094
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001095#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07001096
1097void hdd_SendUpdateBeaconIEsEvent(hdd_adapter_t *pAdapter, tCsrRoamInfo *pCsrRoamInfo)
1098{
1099 union iwreq_data wrqu;
1100 u8 *pBeaconIes;
1101 u8 currentLen = 0;
1102 char *buff;
1103 int totalIeLen = 0, currentOffset = 0, strLen;
1104
1105 memset(&wrqu, '\0', sizeof(wrqu));
1106
1107 if (0 == pCsrRoamInfo->nBeaconLength)
1108 {
1109 hddLog(LOGE, "%s: pCsrRoamInfo->nBeaconFrameLength = 0", __func__);
1110 return;
1111 }
1112 pBeaconIes = (u8 *)(pCsrRoamInfo->pbFrames + BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001113 if (pBeaconIes == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001114 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001115 hddLog(LOGE, "%s: Beacon IEs is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001116 return;
1117 }
1118
1119 // pBeaconIes needs to point to the IEs
1120 hddLog(LOG1, "%s: Beacon IEs is now at %02x%02x", __func__,
1121 (unsigned int)pBeaconIes[0],
1122 (unsigned int)pBeaconIes[1]);
1123 hddLog(LOG1, "%s: Beacon IEs length = %d", __func__, pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001124
Jeff Johnson295189b2012-06-20 16:38:30 -07001125 // We need to send the IEs to the supplicant.
1126 buff = kmalloc(IW_CUSTOM_MAX, GFP_ATOMIC);
Shailender Karmuchia734f332013-04-19 14:02:48 -07001127 if (buff == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07001128 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001129 hddLog(LOGE, "%s: kmalloc unable to allocate memory", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07001130 return;
1131 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001132 vos_mem_zero(buff, IW_CUSTOM_MAX);
Jeff Johnson295189b2012-06-20 16:38:30 -07001133
1134 strLen = strlcpy(buff,"BEACONIEs=", IW_CUSTOM_MAX);
1135 currentLen = strLen + 1;
1136
1137 totalIeLen = pCsrRoamInfo->nBeaconLength - BEACON_FRAME_IES_OFFSET;
1138 do
1139 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07001140 /* If the beacon size exceeds max CUSTOM event size, break it into chunks of CUSTOM event
Jeff Johnson295189b2012-06-20 16:38:30 -07001141 * max size and send it to supplicant. Changes are done in supplicant to handle this */
1142 vos_mem_zero(&buff[strLen + 1], IW_CUSTOM_MAX - (strLen + 1));
1143 currentLen = VOS_MIN(totalIeLen, IW_CUSTOM_MAX - (strLen + 1) - 1);
1144 vos_mem_copy(&buff[strLen + 1], pBeaconIes+currentOffset, currentLen);
1145 currentOffset += currentLen;
1146 totalIeLen -= currentLen;
1147 wrqu.data.length = strLen + 1 + currentLen;
1148 if (totalIeLen)
Shailender Karmuchia734f332013-04-19 14:02:48 -07001149 buff[strLen] = 1; // This tells supplicant more chunks are pending
Jeff Johnson295189b2012-06-20 16:38:30 -07001150 else
1151 buff[strLen] = 0; // For last chunk of beacon IE to supplicant
1152
1153 hddLog(LOG1, "%s: Beacon IEs length to supplicant = %d", __func__, currentLen);
1154 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buff);
1155 } while (totalIeLen > 0);
1156
1157 kfree(buff);
1158}
1159
1160static void hdd_SendAssociationEvent(struct net_device *dev,tCsrRoamInfo *pCsrRoamInfo)
1161{
1162 hdd_adapter_t *pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
1163 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1164 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1165 union iwreq_data wrqu;
1166 int we_event;
1167 char *msg;
1168 int type = -1;
1169
Shailender Karmuchia734f332013-04-19 14:02:48 -07001170#if defined (WLAN_FEATURE_VOWIFI_11R)
1171 // Added to find the auth type on the fly at run time
1172 // rather than with cfg to see if FT is enabled
1173 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001174 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
1175#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07001176
Jeff Johnson295189b2012-06-20 16:38:30 -07001177 memset(&wrqu, '\0', sizeof(wrqu));
Shailender Karmuchia734f332013-04-19 14:02:48 -07001178 wrqu.ap_addr.sa_family = ARPHRD_ETHER;
Jeff Johnson295189b2012-06-20 16:38:30 -07001179 we_event = SIOCGIWAP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001180
Jeff Johnson295189b2012-06-20 16:38:30 -07001181 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
1182 {
Agarwal Ashish51325b52014-06-16 16:50:49 +05301183 /* In case of roaming ; We are not doing disconnect.
1184 * If disconnect is not being done for roam; We will not
1185 * decrease count for Active sessions. We should not increase active
1186 * active session in case of roaming.
1187 */
Padma, Santhosh Kumar87ba40f2014-11-26 19:40:15 +05301188 if((pHddStaCtx->ft_carrier_on == FALSE) && !pCsrRoamInfo->fReassocReq)
Agarwal Ashish51325b52014-06-16 16:50:49 +05301189 {
1190 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
1191 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001192 memcpy(wrqu.ap_addr.sa_data, pCsrRoamInfo->pBssDesc->bssId, sizeof(pCsrRoamInfo->pBssDesc->bssId));
1193 type = WLAN_STA_ASSOC_DONE_IND;
1194
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001195#ifdef WLAN_FEATURE_P2P_DEBUG
1196 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1197 {
1198 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_1)
1199 {
1200 globalP2PConnectionStatus = P2P_CLIENT_CONNECTED_STATE_1;
1201 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
1202 "Connecting state to Connected State for 8-way "
1203 "Handshake");
1204 }
1205 else if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTING_STATE_2)
1206 {
1207 globalP2PConnectionStatus = P2P_CLIENT_COMPLETED_STATE;
1208 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] Changing state from "
1209 "Connecting state to P2P Client Connection Completed");
1210 }
1211 }
1212#endif
Yeshwanth Sriram Guntuka0004c0b2017-12-06 14:43:49 +05301213 hddLog(VOS_TRACE_LEVEL_ERROR, MAC_ADDRESS_STR " connected to "
1214 MAC_ADDRESS_STR,
1215 MAC_ADDR_ARRAY(pAdapter->macAddressCurrent.bytes),
1216 MAC_ADDR_ARRAY(wrqu.ap_addr.sa_data));
Jeff Johnson295189b2012-06-20 16:38:30 -07001217 hdd_SendUpdateBeaconIEsEvent(pAdapter, pCsrRoamInfo);
1218
Bhargav Shahd0715912015-10-01 18:17:37 +05301219 hdd_manage_delack_timer(pHddCtx);
1220
Jeff Johnson295189b2012-06-20 16:38:30 -07001221 /* Send IWEVASSOCRESPIE Event if WLAN_FEATURE_CIQ_METRICS is Enabled Or
1222 * Send IWEVASSOCRESPIE Event if WLAN_FEATURE_VOWIFI_11R is Enabled
1223 * and fFTEnable is TRUE */
1224#ifdef WLAN_FEATURE_VOWIFI_11R
1225 // Send FT Keys to the supplicant when FT is enabled
1226 if ((pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN_PSK) ||
Shailender Karmuchia734f332013-04-19 14:02:48 -07001227 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_FT_RSN)
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001228#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001229 || (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
1230 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA)
1231#endif
1232 )
1233 {
1234 hdd_SendFTAssocResponse(dev, pAdapter, pCsrRoamInfo);
1235 }
1236#endif
1237 }
1238 else if (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState) // IBss Associated
1239 {
Agarwal Ashish51325b52014-06-16 16:50:49 +05301240 wlan_hdd_incr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson4416a782013-03-25 14:17:50 -07001241 memcpy(wrqu.ap_addr.sa_data, pHddStaCtx->conn_info.bssId, ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07001242 type = WLAN_STA_ASSOC_DONE_IND;
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301243
1244 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1245 "wlan: new IBSS connection to " MAC_ADDRESS_STR,
1246 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07001247 }
1248 else /* Not Associated */
1249 {
Deepthi Gowric7591cc2015-12-28 15:43:17 +05301250 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1251 "wlan: disconnected");
gaurank kathpalia51801582019-04-05 13:56:55 +05301252 if (pHddCtx->btCoexModeSet) {
1253 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1254 FL("Wlan disconnected, sending DHCP stop indication"));
1255 pHddCtx->btCoexModeSet = FALSE;
1256 sme_DHCPStopInd(pHddCtx->hHal, pAdapter->device_mode,
1257 pAdapter->sessionId);
1258 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001259 type = WLAN_STA_DISASSOC_DONE_IND;
1260 memset(wrqu.ap_addr.sa_data,'\0',ETH_ALEN);
Bhargav Shahd0715912015-10-01 18:17:37 +05301261
1262 hdd_manage_delack_timer(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001263 }
Sudhir Sattayappa Kohalli90e4c752013-03-21 14:25:04 -07001264 hdd_dump_concurrency_info(pHddCtx);
Jeff Johnson295189b2012-06-20 16:38:30 -07001265
1266 msg = NULL;
1267 /*During the WLAN uninitialization,supplicant is stopped before the
1268 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301269 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001270 {
1271 wireless_send_event(dev, we_event, &wrqu, msg);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08001272#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07001273 if(eConnectionState_Associated == pHddStaCtx->conn_info.connState)/* Associated */
Shailender Karmuchia734f332013-04-19 14:02:48 -07001274 {
1275 if ( (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_RSN) ||
1276 (pRoamProfile->AuthType.authType[0] == eCSR_AUTH_TYPE_CCKM_WPA) )
Jeff Johnson295189b2012-06-20 16:38:30 -07001277 hdd_SendNewAPChannelInfo(dev, pAdapter, pCsrRoamInfo);
1278 }
1279#endif
1280 }
1281 send_btc_nlink_msg(type, 0);
1282}
1283
1284void hdd_connRemoveConnectInfo( hdd_station_ctx_t *pHddStaCtx )
1285{
1286 // Remove staId, bssId and peerMacAddress
1287 pHddStaCtx->conn_info.staId [ 0 ] = 0;
1288 vos_mem_zero( &pHddStaCtx->conn_info.bssId, sizeof( v_MACADDR_t ) );
1289 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[ 0 ], sizeof( v_MACADDR_t ) );
1290
1291 // Clear all security settings
1292 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
1293 pHddStaCtx->conn_info.mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1294 pHddStaCtx->conn_info.ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
1295
1296 vos_mem_zero( &pHddStaCtx->conn_info.Keys, sizeof( tCsrKeys ) );
Ravi Joshib58ca0d2013-10-29 09:50:23 -07001297 vos_mem_zero( &pHddStaCtx->ibss_enc_key, sizeof(tCsrRoamSetKey) );
Jeff Johnson295189b2012-06-20 16:38:30 -07001298
1299 // Set not-connected state
1300 pHddStaCtx->conn_info.connDot11DesiredBssType = eCSR_BSS_TYPE_ANY;
Jeff Johnson295189b2012-06-20 16:38:30 -07001301
1302 vos_mem_zero( &pHddStaCtx->conn_info.SSID, sizeof( tCsrSSIDInfo ) );
1303}
Katya Nigam47528772015-02-11 12:24:49 +05301304
1305VOS_STATUS hdd_ibss_deinit_tx_rx_sta ( hdd_adapter_t *pAdapter, v_U8_t STAId )
1306{
Katya Nigam1fd24402015-02-16 14:52:19 +05301307 v_U8_t ac;
1308 /**Track whether OS TX queue has been disabled.*/
1309 v_BOOL_t txSuspended[NUM_TX_QUEUES];
1310 v_U8_t tlAC;
Katya Nigam47528772015-02-11 12:24:49 +05301311 v_U8_t i;
1312 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1313 hdd_ibss_peer_info_t *pPeerInfo;
1314
1315 if( NULL == pHddStaCtx )
1316 {
1317 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1318 "%s: HDD station context NULL ",__func__);
1319 return VOS_STATUS_E_FAILURE;
1320 }
Katya Nigam1fd24402015-02-16 14:52:19 +05301321
Katya Nigam47528772015-02-11 12:24:49 +05301322 pPeerInfo = &pHddStaCtx->ibss_peer_info;
1323 if (FALSE == pPeerInfo->ibssStaInfo[STAId].isUsed)
1324 {
1325 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1326 "%s: Deinit station not inited %d", __func__, STAId );
1327 return VOS_STATUS_E_FAILURE;
1328 }
1329
1330 hdd_flush_ibss_tx_queues(pAdapter, STAId);
Katya Nigam1fd24402015-02-16 14:52:19 +05301331
1332 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
1333 {
1334 tlAC = hdd_QdiscAcToTlAC[ac];
1335 txSuspended[ac] = pPeerInfo->ibssStaInfo[STAId].txSuspended[tlAC];
1336 }
1337
Katya Nigam47528772015-02-11 12:24:49 +05301338 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
1339
Katya Nigam1fd24402015-02-16 14:52:19 +05301340 /* re-init hdd list, since netdev can still open adapter until
1341 * driver gets unloaded
1342 */
1343 for (i = 0; i < NUM_TX_QUEUES; i ++)
1344 {
1345 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i],
1346 HDD_TX_QUEUE_MAX_LEN);
1347 }
1348
1349 for (ac = HDD_LINUX_AC_VO; ac <= HDD_LINUX_AC_BK; ac++)
1350 {
1351 if (txSuspended[ac])
1352 {
1353 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1354 "%s: TX queue re-enabled", __func__);
1355 netif_wake_subqueue(pAdapter->dev, ac);
1356 }
1357 }
Katya Nigam47528772015-02-11 12:24:49 +05301358 return VOS_STATUS_SUCCESS;
1359}
1360
1361static VOS_STATUS hdd_ibss_DeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
1362{
1363 VOS_STATUS vosStatus;
1364
1365 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
1366 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1367 {
1368 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1369 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
1370 "Status= %d [0x%08X]",
1371 __func__, staId, vosStatus, vosStatus );
1372 }
1373
1374 vosStatus = hdd_ibss_deinit_tx_rx_sta ( pAdapter, staId );
1375 if( VOS_STATUS_E_FAILURE == vosStatus )
1376 {
1377 VOS_TRACE ( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1378 "hdd_ibss_deinit_tx_rx_sta() failed for staID %d. "
1379 "Status = %d [0x%08X]",
1380 staId, vosStatus, vosStatus );
1381 }
1382
1383 return( vosStatus );
1384}
1385
1386VOS_STATUS hdd_ibss_init_tx_rx_sta( hdd_adapter_t *pAdapter, v_U8_t STAId, v_MACADDR_t *pmacAddrSTA)
1387{
1388 v_U8_t i = 0;
1389 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1390 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
1391
1392 if (pPeerInfo->ibssStaInfo[STAId].isUsed)
1393 {
1394 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_ERROR,
1395 "%s: Reinit station %d", __func__, STAId );
1396 return VOS_STATUS_E_FAILURE;
1397 }
1398
1399 vos_mem_zero(&pPeerInfo->ibssStaInfo[STAId], sizeof(hdd_ibss_station_info_t));
1400 for (i = 0; i < NUM_TX_QUEUES; i ++)
1401 {
1402 hdd_list_init(&pPeerInfo->ibssStaInfo[STAId].wmm_tx_queue[i], HDD_TX_QUEUE_MAX_LEN);
1403 }
1404
1405 pPeerInfo->ibssStaInfo[STAId].isUsed = VOS_TRUE;
1406 pPeerInfo->ibssStaInfo[STAId].isDeauthInProgress = VOS_FALSE;
1407 vos_copy_macaddr( &pPeerInfo->ibssStaInfo[STAId].macAddrSTA, pmacAddrSTA);
1408
1409 return VOS_STATUS_SUCCESS;
1410}
1411
1412static VOS_STATUS hdd_ibss_RegisterSTA( hdd_adapter_t *pAdapter,
1413 tCsrRoamInfo *pRoamInfo,
1414 v_U8_t staId,
1415 v_MACADDR_t *pPeerMacAddress,
1416 tSirBssDescription *pBssDesc )
1417{
1418 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
1419 WLAN_STADescType staDesc = {0};
1420 eCsrEncryptionType connectedCipherAlgo;
1421 v_BOOL_t fConnected;
1422 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
1423 hdd_ibss_peer_info_t * pPeerInfo = &pHddStaCtx->ibss_peer_info;
1424 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1425
1426 if ( pPeerInfo->ibssStaInfo[staId].isUsed )
1427 {
1428 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1429 "clean up old entry for STA %d", staId);
1430 hdd_ibss_DeregisterSTA( pAdapter, staId );
1431 }
1432
1433 staDesc.ucSTAId = staId;
1434 staDesc.wSTAType = WLAN_STA_IBSS;
1435
1436 // Note that for IBSS, the STA MAC address and BSSID are goign to be different where
1437 // in infrastructure, they are the same (BSSID is the MAC address of the AP). So,
1438 // for IBSS we have a second field to pass to TL in the STA descriptor that we don't
1439 // pass when making an Infrastructure connection.
1440 vos_mem_copy(staDesc.vSTAMACAddress.bytes, pPeerMacAddress->bytes,sizeof(pPeerMacAddress->bytes));
1441 vos_mem_copy( staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId, 6 );
1442 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
1443
1444 if (hdd_wmm_is_active(pAdapter))
1445 {
1446 staDesc.ucQosEnabled = 1;
1447 }
1448 else
1449 {
1450 staDesc.ucQosEnabled = 0;
1451 }
1452 VOS_TRACE( VOS_MODULE_ID_HDD_DATA, VOS_TRACE_LEVEL_INFO,
1453 "HDD SOFTAP register TL QoS_enabled=%d",
1454 staDesc.ucQosEnabled );
1455
1456 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
1457 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
1458 {
1459 staDesc.ucProtectedFrame = 1;
1460 }
1461 else
1462 {
1463 staDesc.ucProtectedFrame = 0;
1464
1465 }
1466
1467 hdd_ibss_init_tx_rx_sta(pAdapter, staId, &staDesc.vSTAMACAddress);
1468
1469 // UMA is Not ready yet, Xlation will be done by TL
1470 staDesc.ucSwFrameTXXlation = 1;
1471 staDesc.ucSwFrameRXXlation = 1;
1472 staDesc.ucAddRmvLLC = 1;
1473 // Initialize signatures and state
1474 staDesc.ucUcastSig = pRoamInfo->ucastSig;
1475 staDesc.ucBcastSig = pRoamInfo->bcastSig;
1476 staDesc.ucInitState = WLANTL_STA_AUTHENTICATED;
1477
1478 staDesc.ucIsReplayCheckValid = VOS_FALSE;
1479
1480 // Register the Station with TL.
1481 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
1482 hdd_rx_packet_cbk,
1483 hdd_tx_complete_cbk,
1484 hdd_ibss_tx_fetch_packet_cbk, &staDesc,
1485 pBssDesc->rssi );
1486 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1487 {
1488 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1489 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
1490 vosStatus, vosStatus );
1491 return vosStatus;
1492 }
1493
1494 //Timer value should be in milliseconds
1495 if ( pHddCtx->cfg_ini->dynSplitscan &&
1496 ( VOS_TIMER_STATE_RUNNING !=
1497 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
1498 {
1499 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
1500 pHddCtx->cfg_ini->trafficMntrTmrForSplitScan);
1501 }
1502
1503 pPeerInfo->ibssStaInfo[staId].ucSTAId = staId;
1504 pPeerInfo->ibssStaInfo[staId].isQosEnabled = staDesc.ucQosEnabled;
1505
1506 vosStatus = WLANTL_ChangeSTAState( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staDesc.ucSTAId,
1507 WLANTL_STA_AUTHENTICATED );
1508
1509 pPeerInfo->ibssStaInfo[staId].tlSTAState = WLANTL_STA_AUTHENTICATED;
1510 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
1511
1512 return( vosStatus );
1513}
1514
Jeff Johnson295189b2012-06-20 16:38:30 -07001515/* TODO Revist this function. and data path */
1516static VOS_STATUS hdd_roamDeregisterSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
1517{
1518 VOS_STATUS vosStatus;
Ravi Joshif9520d62013-10-18 04:11:46 -07001519
Katya Nigam47528772015-02-11 12:24:49 +05301520 hdd_disconnect_tx_rx(pAdapter);
Ravi Joshif9520d62013-10-18 04:11:46 -07001521
Jeff Johnson295189b2012-06-20 16:38:30 -07001522 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
1523 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
1524 {
Gopichand Nakkalad786fa32013-03-20 23:48:19 +05301525 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson295189b2012-06-20 16:38:30 -07001526 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07001527 "Status= %d [0x%08X]",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07001528 __func__, staId, vosStatus, vosStatus );
Jeff Johnson295189b2012-06-20 16:38:30 -07001529 }
1530 return( vosStatus );
1531}
1532
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05301533/**
1534 * hdd_print_bss_info() - print bss info
1535 * @hdd_sta_ctx: pointer to hdd station context
1536 *
1537 * Return: None
1538 */
1539void hdd_print_bss_info(hdd_station_ctx_t *hdd_sta_ctx)
1540{
1541 uint32_t *cap_info;
1542
1543 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"WIFI DATA LOGGER");
1544 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"channel: %d",
1545 hdd_sta_ctx->conn_info.freq);
1546 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"dot11mode: %d",
1547 hdd_sta_ctx->conn_info.dot11Mode);
1548 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"AKM: %d",
1549 hdd_sta_ctx->conn_info.authType);
1550 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ssid: %.*s",
1551 hdd_sta_ctx->conn_info.SSID.SSID.length,
1552 hdd_sta_ctx->conn_info.SSID.SSID.ssId);
1553 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"roam count: %d",
1554 hdd_sta_ctx->conn_info.roam_count);
1555 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ant_info: %d",
1556 hdd_sta_ctx->conn_info.txrate.nss);
1557 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"datarate legacy %d",
1558 hdd_sta_ctx->conn_info.txrate.legacy);
1559 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"datarate mcs: %d",
1560 hdd_sta_ctx->conn_info.txrate.mcs);
1561 if (hdd_sta_ctx->conn_info.conn_flag.ht_present) {
1562 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.ht_caps;
1563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"ht caps: %x",
1564 *cap_info);
1565 }
1566 if (hdd_sta_ctx->conn_info.conn_flag.vht_present) {
1567 cap_info = (uint32_t *)&hdd_sta_ctx->conn_info.vht_caps;
1568 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"vht caps: %x",
1569 *cap_info);
1570 }
1571 if (hdd_sta_ctx->conn_info.conn_flag.hs20_present)
1572 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"hs20 info: %x",
1573 hdd_sta_ctx->conn_info.hs20vendor_ie.release_num);
1574 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"signal: %d",
1575 hdd_sta_ctx->conn_info.signal);
1576 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,"noise: %d",
1577 hdd_sta_ctx->conn_info.noise);
1578}
1579
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301580/**
1581 * hdd_check_and_move_if_sap_is_on_dfs_chan() - move the sap to non dfs channel
1582 * @hdd_ctx: pointer to hdd context
1583 * @sta_adapter: pointer to sta adapater
1584 *
1585 * This function is used to check if SAP is operating on DFS channel in stand
1586 * alone mode and move it to non dfs channel
1587 *
1588 * Return: void.
1589 */
1590static void hdd_check_and_move_if_sap_is_on_dfs_chan(hdd_context_t *hdd_ctx,
1591 hdd_adapter_t *sta_adapter)
1592{
1593 hdd_adapter_t *sap_adapter;
1594 ptSapContext sap_ctx;
1595 v_CONTEXT_t vos_ctx;
1596 eNVChannelEnabledType chan_state;
1597
1598 if (hdd_is_sta_sap_scc_allowed_on_dfs_chan(hdd_ctx)) {
1599 sap_adapter = hdd_get_adapter(hdd_ctx, WLAN_HDD_SOFTAP);
1600
1601 if (!sap_adapter) {
1602 hddLog(LOG1, FL("SAP not exists, nothing to do"));
1603 return;
1604 }
1605
1606 vos_ctx = hdd_ctx->pvosContext;
1607 if (!vos_ctx) {
1608 hddLog(LOGE, FL("vos_ctx is NULL"));
1609 return;
1610 }
1611 sap_ctx = VOS_GET_SAP_CB(vos_ctx);
1612 if (!sap_ctx) {
1613 hddLog(LOG1, FL("sap_ctx not exists"));
1614 return;
1615 }
1616
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301617 if (sap_ctx->sapsMachine != eSAP_STARTED) {
1618 hddLog(LOG1, FL("SAP is not in eSAP_STARTED state"));
1619 return;
1620 }
1621
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301622 chan_state = vos_nv_getChannelEnabledState(sap_ctx->channel);
1623
1624 hddLog(LOG1, "SAP is operating on channel (%hu), chan_state %d",
1625 sap_ctx->channel, chan_state);
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301626 if (vos_nv_getChannelEnabledState(sap_ctx->channel) !=
1627 NV_CHANNEL_DFS) {
1628 hddLog(LOG1, "SAP is on non DFS channel. nothing to do");
1629 return;
1630 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301631
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301632 hddLog(LOG1, "Schedule workqueue to move the SAP to non DFS channel");
Abhishek Singh10e17cf2018-03-12 14:34:22 +05301633 schedule_delayed_work(&hdd_ctx->ecsa_chan_change_work,
1634 msecs_to_jiffies(ECSA_DFS_CHAN_CHANGE_DEFER_TIME));
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301635 }
1636}
Jeff Johnson295189b2012-06-20 16:38:30 -07001637
1638static eHalStatus hdd_DisConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
1639 tANI_U32 roamId, eRoamCmdStatus roamStatus,
1640 eCsrRoamResult roamResult )
1641{
1642 eHalStatus status = eHAL_STATUS_SUCCESS;
Jeff Johnson43971f52012-07-17 12:26:56 -07001643 VOS_STATUS vstatus;
Jeff Johnson295189b2012-06-20 16:38:30 -07001644 struct net_device *dev = pAdapter->dev;
1645 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1646 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
krunal soni3fc26642013-10-08 22:41:42 -07001647 v_U8_t sta_id;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301648 v_BOOL_t sendDisconInd = TRUE;
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001649
1650 // Sanity check
1651 if(dev == NULL)
1652 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05301653 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnson04dd8a82012-06-29 20:41:40 -07001654 "%s: net_dev is released return", __func__);
1655 return eHAL_STATUS_FAILURE;
1656 }
1657
Jeff Johnson295189b2012-06-20 16:38:30 -07001658 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05301659 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07001660 netif_tx_disable(dev);
1661 netif_carrier_off(dev);
Mukul Sharma09ab4bd2014-11-24 18:07:26 +05301662 //TxTimeoutCount need to reset in case of disconnect handler
1663 pAdapter->hdd_stats.hddTxRxStats.continuousTxTimeoutCount = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001664
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05301665 wlan_hdd_check_and_stop_mon(pAdapter, false);
1666
Jeff Johnsone7245742012-09-05 17:12:55 -07001667 INIT_COMPLETION(pAdapter->disconnect_comp_var);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301668 /* If only STA mode is on */
1669 if((pHddCtx->concurrency_mode <= 1) &&
1670 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <= 1))
1671 {
1672 pHddCtx->isAmpAllowed = VOS_TRUE;
1673 }
1674
Agarwal Ashish47d18112014-08-04 19:55:07 +05301675 /* Need to apply spin lock before decreasing active sessions
1676 * as there can be chance for double decrement if context switch
1677 * Calls wlan_hdd_disconnect.
1678 */
1679
1680 spin_lock_bh(&pAdapter->lock_for_active_session);
Abhishek Singh087de602015-10-21 17:18:55 +05301681
1682 /* HDD has initiated disconnect, do not send disconnect indication
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301683 * to kernel. Sending disconnected event to kernel for userspace
1684 * initiated disconnect will be handled by diconnect handler call
1685 * to cfg80211_disconnected
Abhishek Singh087de602015-10-21 17:18:55 +05301686 */
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301687 if ((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
Abhishek Singhd2ce6802018-05-08 15:21:06 +05301688 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState) ||
1689 (eConnectionState_Connecting == pHddStaCtx->conn_info.connState))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301690 {
1691 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1692 FL(" HDD has initiated a disconnect, no need to send"
1693 " disconnect indication to kernel"));
1694 sendDisconInd = FALSE;
1695 }
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301696 else if (eConnectionState_Associated == pHddStaCtx->conn_info.connState)
Jeff Johnson295189b2012-06-20 16:38:30 -07001697 {
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301698 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singh087de602015-10-21 17:18:55 +05301699 FL("Set HDD connState to eConnectionState_Disconnecting from %d "),
Agarwal Ashish47d18112014-08-04 19:55:07 +05301700 pHddStaCtx->conn_info.connState);
Agarwal Ashishc65b5ca2014-07-28 21:02:57 +05301701 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Disconnecting );
1702 wlan_hdd_decr_active_session(pHddCtx, pAdapter->device_mode);
Jeff Johnson295189b2012-06-20 16:38:30 -07001703 }
Agarwal Ashish47d18112014-08-04 19:55:07 +05301704 spin_unlock_bh(&pAdapter->lock_for_active_session);
Abhishek Singh78c691f2017-11-30 13:48:44 +05301705 vos_flush_delayed_work(&pHddCtx->ecsa_chan_change_work);
Jeff Johnson295189b2012-06-20 16:38:30 -07001706 hdd_clearRoamProfileIe( pAdapter );
Kumar Anand82c009f2014-05-29 00:29:42 -07001707
1708 hdd_wmm_init( pAdapter );
Jeff Johnson295189b2012-06-20 16:38:30 -07001709
1710 // indicate 'disconnect' status to wpa_supplicant...
1711 hdd_SendAssociationEvent(dev,pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07001712 /* indicate disconnected event to nl80211 */
1713 if(roamStatus != eCSR_ROAM_IBSS_LEAVE)
1714 {
1715 /*During the WLAN uninitialization,supplicant is stopped before the
1716 driver so not sending the status of the connection to supplicant*/
Mihir Shete18156292014-03-11 15:38:30 +05301717 if(pHddCtx->isLoadUnloadInProgress == WLAN_HDD_NO_LOAD_UNLOAD_IN_PROGRESS)
Jeff Johnson295189b2012-06-20 16:38:30 -07001718 {
Sushant Kaushik0b343422015-05-25 17:15:55 +05301719 if (sendDisconInd)
1720 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
1721 "%s: sent disconnected event to nl80211",
1722 __func__);
Madan Mohan Koyyalamudi26bd7142012-10-30 18:14:19 -07001723#ifdef WLAN_FEATURE_P2P_DEBUG
1724 if(pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1725 {
1726 if(globalP2PConnectionStatus == P2P_CLIENT_CONNECTED_STATE_1)
1727 {
1728 globalP2PConnectionStatus = P2P_CLIENT_DISCONNECTED_STATE;
1729 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] 8 way Handshake completed "
1730 "and moved to disconnected state");
1731 }
1732 else if(globalP2PConnectionStatus == P2P_CLIENT_COMPLETED_STATE)
1733 {
1734 globalP2PConnectionStatus = P2P_NOT_ACTIVE;
1735 hddLog(VOS_TRACE_LEVEL_ERROR,"[P2P State] P2P Client is removed "
1736 "and moved to inactive state");
1737 }
1738 }
1739#endif
Sushant Kaushikbad61892015-07-10 16:43:28 +05301740 if ((roamStatus == eCSR_ROAM_LOSTLINK) &&
1741 !pRoamInfo->reasonCode)
1742 wlan_hdd_get_frame_logs(pAdapter,
1743 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301744 /*Only send indication to kernel if not initiated by kernel*/
1745 if ( sendDisconInd )
Jeff Johnson295189b2012-06-20 16:38:30 -07001746 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301747 /* To avoid wpa_supplicant sending "HANGED" CMD to ICS UI */
1748 if ( eCSR_ROAM_LOSTLINK == roamStatus )
1749 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301750 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
1751 pRoamInfo->reasonCode);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301752 }
1753 else
1754 {
Mahesh A Saptasagar9ff4bcc2016-06-01 17:17:50 +05301755 wlan_hdd_cfg80211_indicate_disconnect(dev, false,
Mahesh A Saptasagarb5a15142016-05-25 11:27:43 +05301756 WLAN_REASON_UNSPECIFIED);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05301757 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001758 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301759
1760 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
1761 {
1762 hddLog(LOG1,
1763 FL("P2P client is getting removed and we are tryig to re-enable TDLS"));
1764 wlan_hdd_tdls_reenable(pHddCtx);
Masti, Narayanraddifdde4d02015-04-16 14:41:51 +05301765 }
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05301766
Jeff Johnson295189b2012-06-20 16:38:30 -07001767 //If the Device Mode is Station
1768 // and the P2P Client is Connected
1769 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07001770
1771 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07001772 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Sudhir Sattayappa Kohallib1d8c3a2013-06-18 14:47:20 -07001773 if(VOS_STATUS_SUCCESS == hdd_issta_p2p_clientconnected(pHddCtx))
Jeff Johnson295189b2012-06-20 16:38:30 -07001774 {
1775 //Enable BMPS only of other Session is P2P Client
1776 hdd_context_t *pHddCtx = NULL;
Shailender Karmuchia734f332013-04-19 14:02:48 -07001777 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
Jeff Johnson295189b2012-06-20 16:38:30 -07001778
1779 if (NULL != pVosContext)
1780 {
1781 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
1782
1783 if(NULL != pHddCtx)
1784 {
1785 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05301786 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
1787 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Jeff Johnson295189b2012-06-20 16:38:30 -07001788 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301789 if (pHddCtx->hdd_wlan_suspended)
1790 {
1791 hdd_set_pwrparams(pHddCtx);
1792 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001793 hdd_enable_bmps_imps(pHddCtx);
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05301794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07001795 }
1796 }
1797 }
1798 }
1799 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07001800
Madan Mohan Koyyalamudi70c52d32013-08-07 14:42:16 +05301801 hdd_wmm_adapter_clear(pAdapter);
Kapil Guptae6867482016-06-26 13:31:37 +05301802 /* Clear PER based roam stats */
1803#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
1804 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
1805 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
1806 pHddCtx->cfg_ini && pHddCtx->cfg_ini->isPERRoamEnabled &&
1807 pHddCtx->cfg_ini->isPERRoamRxPathEnabled)
1808 sme_unset_per_roam_rxconfig(pHddCtx->hHal);
1809#endif
Mukul Sharmac159c432014-01-15 15:42:46 +05301810#if defined(WLAN_FEATURE_VOWIFI_11R)
1811 sme_FTReset(WLAN_HDD_GET_HAL_CTX(pAdapter));
1812#endif
Katya Nigam63ce1772014-09-26 15:53:49 +05301813
1814 if (eCSR_ROAM_IBSS_LEAVE == roamStatus)
1815 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301816 v_U8_t i;
1817
Katya Nigam63ce1772014-09-26 15:53:49 +05301818 sta_id = IBSS_BROADCAST_STAID;
Katya Nigam47528772015-02-11 12:24:49 +05301819 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Katya Nigam63ce1772014-09-26 15:53:49 +05301820 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1821 {
1822 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301823 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1824 "Status= %d [0x%x]"),
Katya Nigam63ce1772014-09-26 15:53:49 +05301825 sta_id, status, status );
1826
1827 status = eHAL_STATUS_FAILURE;
1828 }
Katya Nigam63ce1772014-09-26 15:53:49 +05301829 pHddCtx->sta_to_adapter[sta_id] = NULL;
1830
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301831 /*Clear all the peer sta register with TL.*/
1832 for (i =0; i < HDD_MAX_NUM_IBSS_STA; i++ )
1833 {
1834 if (0 != pHddStaCtx->conn_info.staId[i])
1835 {
1836 sta_id = pHddStaCtx->conn_info.staId[i];
1837
1838 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
1839 FL("Deregister StaID %d"),sta_id);
Katya Nigam47528772015-02-11 12:24:49 +05301840 vstatus = hdd_ibss_DeregisterSTA( pAdapter, sta_id );
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301841 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1842 {
1843 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1844 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1845 "Status= %d [0x%x]"),
1846 sta_id, status, status );
1847 status = eHAL_STATUS_FAILURE;
1848 }
1849
Nirav Shah7e3c8132015-06-22 23:51:42 +05301850 vstatus = hdd_sta_id_hash_remove_entry(pAdapter,
1851 sta_id, &pHddStaCtx->conn_info.peerMacAddress[i]);
1852 if (vstatus != VOS_STATUS_SUCCESS) {
1853 hddLog(VOS_TRACE_LEVEL_ERROR,
1854 FL("Not able to remove staid hash %d"),
1855 sta_id);
1856 status = eHAL_STATUS_FAILURE;
1857 } else {
1858 hddLog(VOS_TRACE_LEVEL_INFO,
1859 FL("ibss station removed sta_id %d mac:"
1860 MAC_ADDRESS_STR), sta_id,
1861 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[i].bytes));
1862 }
1863
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301864 /*set the staid and peer mac as 0, all other reset are
1865 * done in hdd_connRemoveConnectInfo.
1866 */
1867 pHddStaCtx->conn_info.staId[i]= 0;
1868 vos_mem_zero( &pHddStaCtx->conn_info.peerMacAddress[i], sizeof( v_MACADDR_t ) );
1869
1870 if (sta_id < (WLAN_MAX_STA_COUNT + 3))
1871 pHddCtx->sta_to_adapter[sta_id] = NULL;
1872 }
1873 }
1874
Katya Nigam63ce1772014-09-26 15:53:49 +05301875 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301876 else
Jeff Johnson295189b2012-06-20 16:38:30 -07001877 {
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301878 sta_id = pHddStaCtx->conn_info.staId[0];
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05301879 /* clear scan cache for Link Lost */
1880 if (pRoamInfo && !pRoamInfo->reasonCode &&
1881 (eCSR_ROAM_LOSTLINK == roamStatus)) {
Abhishek Singhe6137b82019-03-22 20:06:09 +05301882 wlan_hdd_cfg80211_unlink_bss(pAdapter,
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05301883 pHddStaCtx->conn_info.bssId);
1884 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
1885 pHddStaCtx->conn_info.bssId);
1886 }
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301887
1888 //We should clear all sta register with TL, for now, only one.
1889 vstatus = hdd_roamDeregisterSTA( pAdapter, sta_id );
1890 if ( !VOS_IS_STATUS_SUCCESS(vstatus ) )
1891 {
1892 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
1893 FL("hdd_roamDeregisterSTA() failed to for staID %d. "
1894 "Status= %d [0x%x]"),
krunal soni3fc26642013-10-08 22:41:42 -07001895 sta_id, status, status );
Jeff Johnson295189b2012-06-20 16:38:30 -07001896
Abhishek Singh06e67ba2014-12-08 17:16:33 +05301897 status = eHAL_STATUS_FAILURE;
1898 }
1899
1900 pHddCtx->sta_to_adapter[sta_id] = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07001901 }
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301902
1903#ifdef WLAN_FEATURE_LINK_LAYER_STATS
1904 if (VOS_STATUS_SUCCESS !=
1905 WLANTL_ClearInterfaceStats((WLAN_HDD_GET_CTX(pAdapter))->pvosContext,
1906 pHddStaCtx->conn_info.staId[0], WIFI_STATS_IFACE_AC))
1907 {
1908 hddLog(VOS_TRACE_LEVEL_ERROR, "%s:"
1909 "WLANTL_ClearInterfaceStats Failed", __func__);
1910 }
1911 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VO] = 0;
1912 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_VI] = 0;
1913 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BE] = 0;
1914 pAdapter->hdd_stats.hddTxRxStats.txMcast[WLANTL_AC_BK] = 0;
1915#endif /* WLAN_FEATURE_LINK_LAYER_STATS */
Sravan Kumar Kairamf9f95122017-01-18 20:54:05 +05301916 pAdapter->dad = false;
Srinivas Dasarideb7ae92014-12-19 15:26:40 +05301917
Jeff Johnson295189b2012-06-20 16:38:30 -07001918 // Clear saved connection information in HDD
1919 hdd_connRemoveConnectInfo( pHddStaCtx );
Abhishek Singhd2ce6802018-05-08 15:21:06 +05301920
1921 /*
1922 * eConnectionState_Connecting state mean that connection is in progress so
1923 * no need to set state to eConnectionState_NotConnected
1924 */
1925 if ((eConnectionState_Connecting != pHddStaCtx->conn_info.connState)) {
1926 hddLog(LOG1, FL("Set HDD connState to eConnectionState_NotConnected"));
1927 hdd_connSetConnectionState(pHddStaCtx, eConnectionState_NotConnected);
1928 }
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301929#ifdef WLAN_FEATURE_GTK_OFFLOAD
1930 if ((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
1931 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
1932 {
Gopichand Nakkalad36ee622013-05-07 14:13:27 +05301933 memset(&pHddStaCtx->gtkOffloadReqParams, 0,
1934 sizeof (tSirGtkOffloadParams));
1935 pHddStaCtx->gtkOffloadReqParams.ulFlags = GTK_OFFLOAD_DISABLE;
Gopichand Nakkala870cbae2013-03-15 21:16:09 +05301936 }
1937#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07001938
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001939#ifdef FEATURE_WLAN_TDLS
krunal soni3fc26642013-10-08 22:41:42 -07001940 if (eCSR_ROAM_IBSS_LEAVE != roamStatus)
1941 {
1942 wlan_hdd_tdls_disconnection_callback(pAdapter);
1943 }
Gopichand Nakkalac3694582013-02-13 20:51:22 -08001944#endif
1945
Jeff Johnson295189b2012-06-20 16:38:30 -07001946 //Unblock anyone waiting for disconnect to complete
1947 complete(&pAdapter->disconnect_comp_var);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05301948 hdd_print_bss_info(pHddStaCtx);
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05301949
1950 hdd_check_and_move_if_sap_is_on_dfs_chan(pHddCtx, pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07001951 return( status );
1952}
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05301953
1954static void hdd_postTLPacketPendingInd(hdd_adapter_t *pAdapter,
1955 v_U8_t staId)
1956{
1957 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
1958 v_SINT_t i;
1959 v_SIZE_t size;
1960 VOS_STATUS status;
1961 v_BOOL_t granted = VOS_FALSE;
1962
1963 if ((pAdapter->device_mode == WLAN_HDD_INFRA_STATION) ||
1964 (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT) ||
1965 (pAdapter->device_mode == WLAN_HDD_P2P_DEVICE))
1966 {
1967 //Indicate to TL that there is pending data if a queue is non empty
1968 for (i = WLANTL_AC_HIGH_PRIO; i>=0; --i)
1969 {
1970 size = 0;
1971 hdd_list_size(&pAdapter->wmm_tx_queue[i], &size);
1972 if (size > 0)
1973 {
1974 if (i != WLANTL_AC_HIGH_PRIO)
1975 {
1976 if (VOS_FALSE ==
1977 pAdapter->hddWmmStatus.wmmAcStatus[i].wmmAcAccessAllowed)
1978 {
1979 hdd_wmm_acquire_access(pAdapter,
1980 (WLANTL_ACEnumType)i, &granted);
1981 pAdapter->psbChanged |= (1 << i);
1982 }
1983 else
1984 granted = VOS_TRUE;
1985 }
1986
1987 if (granted || (i == WLANTL_AC_HIGH_PRIO))
1988 {
1989 status = WLANTL_STAPktPending(pHddCtx->pvosContext,
1990 staId, (WLANTL_ACEnumType)i);
1991 if (!VOS_IS_STATUS_SUCCESS(status))
1992 {
1993 VOS_TRACE(VOS_MODULE_ID_TL, VOS_TRACE_LEVEL_INFO_HIGH,
1994 "%s: Failure in indicating pkt to TL for QID=%d",
1995 __func__, i);
1996 }
1997 }
1998 }
1999 }
2000 }
2001}
2002
Jeff Johnson295189b2012-06-20 16:38:30 -07002003static VOS_STATUS hdd_roamRegisterSTA( hdd_adapter_t *pAdapter,
2004 tCsrRoamInfo *pRoamInfo,
2005 v_U8_t staId,
2006 v_MACADDR_t *pPeerMacAddress,
2007 tSirBssDescription *pBssDesc )
2008{
2009 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
2010 WLAN_STADescType staDesc = {0};
2011 eCsrEncryptionType connectedCipherAlgo;
2012 v_BOOL_t fConnected;
2013 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2014 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002015 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002016
2017 if ( NULL == pBssDesc)
2018 {
2019 return VOS_STATUS_E_FAILURE;
2020 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002021 // Get the Station ID from the one saved during the assocation.
2022 staDesc.ucSTAId = staId;
2023
Katya Nigam47528772015-02-11 12:24:49 +05302024 staDesc.wSTAType = WLAN_STA_INFRA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002025
Katya Nigam47528772015-02-11 12:24:49 +05302026 // grab the bssid from the connection info in the adapter structure and hand that
2027 // over to TL when registering.
2028 vos_mem_copy( staDesc.vSTAMACAddress.bytes, pHddStaCtx->conn_info.bssId,
2029 sizeof(pHddStaCtx->conn_info.bssId) );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002030
Jeff Johnson295189b2012-06-20 16:38:30 -07002031 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
2032
2033 // set the QoS field appropriately
2034 if (hdd_wmm_is_active(pAdapter))
2035 {
2036 staDesc.ucQosEnabled = 1;
2037 }
2038 else
2039 {
2040 staDesc.ucQosEnabled = 0;
2041 }
2042
2043 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
2044 if ( connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE )
2045 {
2046 staDesc.ucProtectedFrame = 1;
2047 }
2048 else
2049 {
2050 staDesc.ucProtectedFrame = 0;
2051
2052 }
2053
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002054#ifdef FEATURE_WLAN_ESE
2055 staDesc.ucIsEseSta = pRoamInfo->isESEAssoc;
2056#endif //FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07002057
Jeff Johnson295189b2012-06-20 16:38:30 -07002058 /* check whether replay check is valid for the station or not */
2059 if( (eCSR_ENCRYPT_TYPE_TKIP == connectedCipherAlgo) || (eCSR_ENCRYPT_TYPE_AES == connectedCipherAlgo))
2060 {
2061 /* Encryption mode is either TKIP or AES
2062 and replay check is valid for only these
2063 two encryption modes */
2064 staDesc.ucIsReplayCheckValid = VOS_TRUE;
2065 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2066 "HDD register TL ucIsReplayCheckValid %d: Replay check is needed for station", staDesc.ucIsReplayCheckValid);
2067 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002068 else
2069 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002070 /* For other encryption modes replay check is
Jeff Johnson295189b2012-06-20 16:38:30 -07002071 not needed */
Shailender Karmuchia734f332013-04-19 14:02:48 -07002072 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002073 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2074 "HDD register TL ucIsReplayCheckValid %d", staDesc.ucIsReplayCheckValid);
2075 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002076
2077#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07002078 hddLog(LOG1, "%s: WAPI STA Registered: %d", __func__, pAdapter->wapi_info.fIsWapiSta);
Jeff Johnson295189b2012-06-20 16:38:30 -07002079 if (pAdapter->wapi_info.fIsWapiSta)
2080 {
2081 staDesc.ucIsWapiSta = 1;
2082 }
2083 else
2084 {
2085 staDesc.ucIsWapiSta = 0;
2086 }
2087#endif /* FEATURE_WLAN_WAPI */
2088
2089 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
2090 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
2091
Jeff Johnson295189b2012-06-20 16:38:30 -07002092 // UMA is Not ready yet, Xlation will be done by TL
2093 staDesc.ucSwFrameTXXlation = 1;
Jeff Johnson295189b2012-06-20 16:38:30 -07002094 staDesc.ucSwFrameRXXlation = 1;
2095 staDesc.ucAddRmvLLC = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002096 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register TL QoS_enabled=%d",
Jeff Johnson295189b2012-06-20 16:38:30 -07002097 staDesc.ucQosEnabled );
2098 // Initialize signatures and state
2099 staDesc.ucUcastSig = pRoamInfo->ucastSig;
2100 staDesc.ucBcastSig = pRoamInfo->bcastSig;
2101 staDesc.ucInitState = pRoamInfo->fAuthRequired ?
2102 WLANTL_STA_CONNECTED : WLANTL_STA_AUTHENTICATED;
Shailender Karmuchia734f332013-04-19 14:02:48 -07002103 // Register the Station with TL...
Tushnim Bhattacharyya39a8f182013-02-20 18:10:30 -08002104 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 -07002105 vosStatus = WLANTL_RegisterSTAClient( pHddCtx->pvosContext,
2106 hdd_rx_packet_cbk,
2107 hdd_tx_complete_cbk,
Jeff Johnson295189b2012-06-20 16:38:30 -07002108 hdd_tx_fetch_packet_cbk, &staDesc,
2109 pBssDesc->rssi );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002110
Jeff Johnson295189b2012-06-20 16:38:30 -07002111 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
2112 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07002113 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002114 "WLANTL_RegisterSTAClient() failed to register. Status= %d [0x%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002115 vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07002116 return vosStatus;
2117 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002118
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07002119 if ( cfg_param->dynSplitscan &&
2120 ( VOS_TIMER_STATE_RUNNING !=
2121 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)))
2122 {
2123 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
2124 cfg_param->trafficMntrTmrForSplitScan);
2125 }
2126
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302127 // if (WPA), tell TL to go to 'connected' and after keys come to the driver,
2128 // then go to 'authenticated'. For all other authentication types
2129 // (those that donot require upper layer authentication) we can put
2130 // TL directly into 'authenticated' state.
Shailender Karmuchia734f332013-04-19 14:02:48 -07002131 if (staDesc.wSTAType != WLAN_STA_IBSS)
2132 VOS_ASSERT( fConnected );
2133
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302134 if ( !pRoamInfo->fAuthRequired )
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002135 {
2136 // Connections that do not need Upper layer auth, transition TL directly
2137 // to 'Authenticated' state.
2138 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
2139 WLANTL_STA_AUTHENTICATED );
2140
2141 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302142
2143 hdd_postTLPacketPendingInd(pAdapter, staDesc.ucSTAId);
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002144 }
2145 else
2146 {
2147 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302148 "ULA auth StaId= %d. Changing TL state to CONNECTED"
2149 "at Join time", pHddStaCtx->conn_info.staId[0] );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002150 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext, staDesc.ucSTAId,
Gopichand Nakkala29149562013-05-10 21:43:41 +05302151 WLANTL_STA_CONNECTED );
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002152 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
2153 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002154 return( vosStatus );
2155}
2156
Jeff Johnson295189b2012-06-20 16:38:30 -07002157static void hdd_SendReAssocEvent(struct net_device *dev, hdd_adapter_t *pAdapter,
2158 tCsrRoamInfo *pCsrRoamInfo, v_U8_t *reqRsnIe, tANI_U32 reqRsnLength)
2159{
2160 unsigned int len = 0;
2161 u8 *pFTAssocRsp = NULL;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002162 v_U8_t *rspRsnIe = kmalloc(IW_GENERIC_IE_MAX, GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07002163 tANI_U32 rspRsnLength = 0;
Abhishek Singh5a597e62016-12-05 15:16:30 +05302164 struct cfg80211_bss* bss;
2165 tCsrRoamConnectedProfile roam_profile;
Jeff Johnson295189b2012-06-20 16:38:30 -07002166 struct ieee80211_channel *chan;
Abhishek Singh5a597e62016-12-05 15:16:30 +05302167 tHalHandle hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07002168
Agarwal Ashish51325b52014-06-16 16:50:49 +05302169 if (!rspRsnIe) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002170 hddLog(LOGE, "%s: Unable to allocate RSN IE", __func__);
Madan Mohan Koyyalamudieeb56b12012-10-31 15:10:04 -07002171 return;
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002172 }
2173
Agarwal Ashish51325b52014-06-16 16:50:49 +05302174 if (pCsrRoamInfo == NULL) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002175 hddLog(LOGE, "%s: Invalid CSR roam info", __func__);
2176 goto done;
2177 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002178
Agarwal Ashish51325b52014-06-16 16:50:49 +05302179 if (pCsrRoamInfo->nAssocRspLength == 0) {
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002180 hddLog(LOGE, "%s: Invalid assoc response length", __func__);
2181 goto done;
2182 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002183
2184 pFTAssocRsp = (u8 *)(pCsrRoamInfo->pbFrames + pCsrRoamInfo->nBeaconLength +
2185 pCsrRoamInfo->nAssocReqLength);
2186 if (pFTAssocRsp == NULL)
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002187 goto done;
Jeff Johnson295189b2012-06-20 16:38:30 -07002188
2189 //pFTAssocRsp needs to point to the IEs
2190 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
Arif Hussain6d2a3322013-11-17 19:50:10 -08002191 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07002192 (unsigned int)pFTAssocRsp[0],
2193 (unsigned int)pFTAssocRsp[1]);
2194
2195 // Send the Assoc Resp, the supplicant needs this for initial Auth.
Madan Mohan Koyyalamudi1bed23d2012-11-13 10:59:48 -08002196 len = pCsrRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Jeff Johnson295189b2012-06-20 16:38:30 -07002197 rspRsnLength = len;
Jeff Johnson295189b2012-06-20 16:38:30 -07002198 memcpy(rspRsnIe, pFTAssocRsp, len);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002199 memset(rspRsnIe + len, 0, IW_GENERIC_IE_MAX - len);
Jeff Johnson295189b2012-06-20 16:38:30 -07002200
Abhishek Singh5a597e62016-12-05 15:16:30 +05302201 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
2202 (int) pCsrRoamInfo->pBssDesc->channelId);
2203 vos_mem_zero(&roam_profile, sizeof(tCsrRoamConnectedProfile));
2204 sme_RoamGetConnectProfile(hHal, pAdapter->sessionId, &roam_profile);
2205 bss = hdd_get_bss_entry(pAdapter->wdev.wiphy,
2206 chan, pCsrRoamInfo->bssid,
2207 &roam_profile.SSID.ssId[0],
2208 roam_profile.SSID.length);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302209 hdd_send_roamed_ind(dev, bss,
Jeff Johnson295189b2012-06-20 16:38:30 -07002210 reqRsnIe, reqRsnLength,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302211 rspRsnIe, rspRsnLength);
Madan Mohan Koyyalamudi8f207c12012-10-30 18:18:38 -07002212
2213done:
2214 kfree(rspRsnIe);
Jeff Johnson295189b2012-06-20 16:38:30 -07002215}
Jeff Johnson295189b2012-06-20 16:38:30 -07002216
Gopichand Nakkala3d295922013-05-07 16:19:14 +05302217void hdd_PerformRoamSetKeyComplete(hdd_adapter_t *pAdapter)
2218{
2219 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
2220 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
2221 tCsrRoamInfo roamInfo;
2222 roamInfo.fAuthRequired = FALSE;
2223 vos_mem_copy(roamInfo.bssid,
2224 pHddStaCtx->roam_info.bssid,
2225 WNI_CFG_BSSID_LEN);
2226 vos_mem_copy(roamInfo.peerMac,
2227 pHddStaCtx->roam_info.peerMac,
2228 WNI_CFG_BSSID_LEN);
2229
2230 halStatus = hdd_RoamSetKeyCompleteHandler(pAdapter,
2231 &roamInfo,
2232 pHddStaCtx->roam_info.roamId,
2233 pHddStaCtx->roam_info.roamStatus,
2234 eCSR_ROAM_RESULT_AUTHENTICATED);
2235 if (halStatus != eHAL_STATUS_SUCCESS)
2236 {
2237 hddLog(LOGE, "%s: Set Key complete failure", __func__);
2238 }
2239 pHddStaCtx->roam_info.deferKeyComplete = FALSE;
2240}
2241
Abhishek Singh78c691f2017-11-30 13:48:44 +05302242/**
2243 * hdd_schedule_ecsa_chan_change_work() - schedule ecsa chan change work
2244 * @hal: hal context
2245 * @sta_session_id: sta session id
2246 *
2247 * Return: void.
2248 */
2249static void
2250hdd_schedule_ecsa_chan_change_work(hdd_context_t *hdd_ctx,
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05302251 uint8_t sta_session_id)
Abhishek Singh78c691f2017-11-30 13:48:44 +05302252{
2253 v_TIME_t conn_start_time;
2254 int32_t time_diff;
2255
2256 conn_start_time = sme_get_connect_strt_time(hdd_ctx->hHal, sta_session_id);
2257 time_diff = vos_timer_get_system_time() - conn_start_time;
2258
2259 if (time_diff < 0)
2260 time_diff = ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL;
2261 else if (time_diff > ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL)
2262 time_diff = 0;
2263 else
2264 time_diff = ECSA_SCC_CHAN_CHANGE_DEFER_INTERVAL - time_diff;
2265
2266 hddLog(LOG1, FL("schedule ecsa_chan_change_work after %d ms"), time_diff);
2267 schedule_delayed_work(&hdd_ctx->ecsa_chan_change_work,
2268 msecs_to_jiffies(time_diff));
2269}
2270
Shailender Karmuchia734f332013-04-19 14:02:48 -07002271static eHalStatus hdd_AssociationCompletionHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
2272 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07002273 eCsrRoamResult roamResult )
2274{
2275 struct net_device *dev = pAdapter->dev;
2276 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
2277 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302278 hdd_adapter_t *pHostapdAdapter = NULL;
Girish Gowli257a7e62014-08-02 15:50:43 +05302279 VOS_STATUS vosStatus = VOS_STATUS_SUCCESS;
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08002280 v_U8_t reqRsnIe[DOT11F_IE_RSN_MAX_LEN];
2281 tANI_U32 reqRsnLength = DOT11F_IE_RSN_MAX_LEN;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002282#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR) || defined (WLAN_FEATURE_VOWIFI_11R)
Jeff Johnson295189b2012-06-20 16:38:30 -07002283 int ft_carrier_on = FALSE;
2284#endif
2285 int status;
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302286 v_BOOL_t hddDisconInProgress = FALSE;
2287
2288 /* HDD has initiated disconnect, do not send connect result indication
2289 * to kernel as it will be handled by __cfg80211_disconnect.
2290 */
Agarwal Ashishc089cec2015-08-10 13:10:04 +05302291 if (((eConnectionState_Disconnecting == pHddStaCtx->conn_info.connState) ||
2292 (eConnectionState_NotConnected == pHddStaCtx->conn_info.connState)) &&
2293 ((eCSR_ROAM_RESULT_ASSOCIATED == roamResult) ||
2294 (eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus)))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302295 {
2296 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2297 FL(" Disconnect from HDD in progress "));
2298 hddDisconInProgress = TRUE;
2299 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002300
Jeff Johnson295189b2012-06-20 16:38:30 -07002301 if ( eCSR_ROAM_RESULT_ASSOCIATED == roamResult )
2302 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302303 if ( !hddDisconInProgress )
2304 {
2305 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
Abhishek Singhf4669da2014-05-26 15:07:49 +05302306 "%s: Set HDD connState to eConnectionState_Associated",
2307 __func__);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302308 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_Associated );
2309 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002310
c_hpothu44ff4e02014-05-08 00:13:57 +05302311 pAdapter->maxRateFlags = pRoamInfo->maxRateFlags;
Jeff Johnson295189b2012-06-20 16:38:30 -07002312 // Save the connection info from CSR...
2313 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE );
Kapil Guptae6867482016-06-26 13:31:37 +05302314
2315#ifdef WLAN_FEATURE_ROAM_SCAN_OFFLOAD
2316 if (sme_IsFeatureSupportedByFW(PER_BASED_ROAMING) &&
2317 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode) &&
2318 !hddDisconInProgress &&
2319 pHddCtx->cfg_ini && pHddCtx->cfg_ini->isPERRoamEnabled &&
2320 pHddCtx->cfg_ini->isPERRoamRxPathEnabled)
2321 sme_set_per_roam_rxconfig(pHddCtx->hHal,
2322 pHddStaCtx->conn_info.staId[0],
2323 pHddCtx->cfg_ini->rateDownThreshold,
2324 pHddCtx->cfg_ini->rateUpThreshold,
2325 pHddCtx->cfg_ini->PERroamTriggerPercent,
2326 pHddCtx->cfg_ini->PERroamRxPktsThreshold,
2327 pHddCtx->cfg_ini->waitPeriodForNextPERScan);
2328#endif
2329
Jeff Johnson295189b2012-06-20 16:38:30 -07002330#ifdef FEATURE_WLAN_WAPI
2331 if ( pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE ||
2332 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_WAPI_WAI_PSK )
2333 {
2334 pAdapter->wapi_info.fIsWapiSta = 1;
2335 }
2336 else
2337 {
2338 pAdapter->wapi_info.fIsWapiSta = 0;
2339 }
2340#endif /* FEATURE_WLAN_WAPI */
2341
2342 // indicate 'connect' status to userspace
2343 hdd_SendAssociationEvent(dev,pRoamInfo);
2344
2345
Shailender Karmuchia734f332013-04-19 14:02:48 -07002346 // Initialize the Linkup event completion variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002347 INIT_COMPLETION(pAdapter->linkup_event_var);
2348
2349 /*
2350 Sometimes Switching ON the Carrier is taking time to activate the device properly. Before allowing any
2351 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 -07002352 kernel. we have registered net device notifier for device change notification. With this we will come to
Jeff Johnson295189b2012-06-20 16:38:30 -07002353 know that the device is getting activated properly.
2354 */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002355#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Katya Nigamb130d572014-11-24 16:38:16 +05302356 if (pHddStaCtx->ft_carrier_on == FALSE && !hddDisconInProgress )
Jeff Johnson295189b2012-06-20 16:38:30 -07002357 {
2358#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002359 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002360 pAdapter->isLinkUpSvcNeeded = TRUE;
2361
Shailender Karmuchia734f332013-04-19 14:02:48 -07002362 // Enable Linkup Event Servicing which allows the net device notifier to set the linkup event variable
Jeff Johnson295189b2012-06-20 16:38:30 -07002363 pAdapter->isLinkUpSvcNeeded = TRUE;
2364
2365 // Switch on the Carrier to activate the device
2366 netif_carrier_on(dev);
2367
2368 // Wait for the Link to up to ensure all the queues are set properly by the kernel
2369 status = wait_for_completion_interruptible_timeout(&pAdapter->linkup_event_var,
2370 msecs_to_jiffies(ASSOC_LINKUP_TIMEOUT));
Shailender Karmuchia734f332013-04-19 14:02:48 -07002371 if(!status)
Jeff Johnson295189b2012-06-20 16:38:30 -07002372 {
2373 hddLog(VOS_TRACE_LEVEL_WARN, "%s: Warning:ASSOC_LINKUP_TIMEOUT", __func__);
2374 }
2375
2376 // Disable Linkup Event Servicing - no more service required from the net device notifier call
2377 pAdapter->isLinkUpSvcNeeded = FALSE;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002378#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07002379 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002380 else {
Jeff Johnson295189b2012-06-20 16:38:30 -07002381 pHddStaCtx->ft_carrier_on = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002382 ft_carrier_on = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07002383 }
2384#endif
Sandeep Puligillad91dccb2014-06-18 11:51:48 +05302385 /* Check for STAID */
2386 if( (WLAN_MAX_STA_COUNT + 3) > pRoamInfo->staId )
2387 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
2388 else
2389 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: Wrong Staid: %d", __func__, pRoamInfo->staId);
Jeff Johnson295189b2012-06-20 16:38:30 -07002390
2391 //For reassoc, the station is already registered, all we need is to change the state
2392 //of the STA in TL.
2393 //If authentication is required (WPA/WPA2/DWEP), change TL to CONNECTED instead of AUTHENTICATED
Mukul Sharma5b2ff502014-11-06 14:43:50 +05302394 //pRoamInfo->fReassocReq will be set only for the reassoc to same ap
Jeff Johnson295189b2012-06-20 16:38:30 -07002395 if( !pRoamInfo->fReassocReq )
2396 {
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002397 struct cfg80211_bss *bss;
2398#ifdef WLAN_FEATURE_VOWIFI_11R
2399 u8 *pFTAssocRsp = NULL;
2400 unsigned int assocRsplen = 0;
2401 u8 *pFTAssocReq = NULL;
2402 unsigned int assocReqlen = 0;
2403 struct ieee80211_channel *chan;
2404#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07002405 v_U8_t rspRsnIe[DOT11F_IE_RSN_MAX_LEN];
Jeff Johnson295189b2012-06-20 16:38:30 -07002406 tANI_U32 rspRsnLength = DOT11F_IE_RSN_MAX_LEN;
Jeff Johnson295189b2012-06-20 16:38:30 -07002407
2408 /* add bss_id to cfg80211 data base */
2409 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2410 if (NULL == bss)
2411 {
Abhishek Singh7ca68f32016-06-28 10:23:10 +05302412 hddLog(LOGE,
2413 FL("Not able to create BSS entry"));
Katya Nigam346d4e92014-09-02 16:16:12 +05302414 netif_carrier_off(dev);
Abhishek Singh7ca68f32016-06-28 10:23:10 +05302415 if (!hddDisconInProgress) {
2416 /*
2417 * Here driver was not able to update cfg80211 database
2418 * this can happen if connected channel is not valid,
2419 * i.e reg domain was changed during connection.
2420 * Queue disconnect for the session if disconnect is
2421 * not in progress.
2422 */
2423 hddLog(LOGE, FL("Disconnecting..."));
2424 sme_RoamDisconnect( WLAN_HDD_GET_HAL_CTX(pAdapter),
2425 pAdapter->sessionId,
2426 eCSR_DISCONNECT_REASON_UNSPECIFIED);
2427 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002428 return eHAL_STATUS_FAILURE;
2429 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002430#ifdef WLAN_FEATURE_VOWIFI_11R
2431 if(pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN ||
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002432 pRoamInfo->u.pConnectedProfile->AuthType == eCSR_AUTH_TYPE_FT_RSN_PSK )
Jeff Johnson295189b2012-06-20 16:38:30 -07002433 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002434
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002435 //Association Response
Shailender Karmuchia734f332013-04-19 14:02:48 -07002436 pFTAssocRsp = (u8 *)(pRoamInfo->pbFrames + pRoamInfo->nBeaconLength +
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002437 pRoamInfo->nAssocReqLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002438 if (pFTAssocRsp != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002439 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002440 // pFTAssocRsp needs to point to the IEs
2441 pFTAssocRsp += FT_ASSOC_RSP_IES_OFFSET;
2442 hddLog(LOG1, "%s: AssocRsp is now at %02x%02x", __func__,
2443 (unsigned int)pFTAssocRsp[0],
2444 (unsigned int)pFTAssocRsp[1]);
2445 assocRsplen = pRoamInfo->nAssocRspLength - FT_ASSOC_RSP_IES_OFFSET;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002446 }
2447 else
2448 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002449 hddLog(LOGE, "%s:AssocRsp is NULL", __func__);
2450 assocRsplen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002451 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002452
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002453 //Association Request
Shailender Karmuchia734f332013-04-19 14:02:48 -07002454 pFTAssocReq = (u8 *)(pRoamInfo->pbFrames +
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002455 pRoamInfo->nBeaconLength);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002456 if (pFTAssocReq != NULL)
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002457 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002458 if(!ft_carrier_on)
2459 {
2460 // pFTAssocReq needs to point to the IEs
2461 pFTAssocReq += FT_ASSOC_REQ_IES_OFFSET;
2462 hddLog(LOG1, "%s: pFTAssocReq is now at %02x%02x", __func__,
2463 (unsigned int)pFTAssocReq[0],
2464 (unsigned int)pFTAssocReq[1]);
2465 assocReqlen = pRoamInfo->nAssocReqLength - FT_ASSOC_REQ_IES_OFFSET;
2466 }
2467 else
2468 {
2469 /* This should contain only the FTIEs */
2470 assocReqlen = pRoamInfo->nAssocReqLength;
2471 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002472 }
2473 else
2474 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002475 hddLog(LOGE, "%s:AssocReq is NULL", __func__);
2476 assocReqlen = 0;
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002477 }
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002478
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002479 if(ft_carrier_on)
2480 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302481 if ( !hddDisconInProgress )
2482 {
Abhishek Singh5a597e62016-12-05 15:16:30 +05302483 struct cfg80211_bss *roam_bss;
2484
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302485 hddLog(LOG1, "%s ft_carrier_on is %d, sending roamed "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002486 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302487 chan = ieee80211_get_channel(pAdapter->wdev.wiphy,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002488 (int)pRoamInfo->pBssDesc->channelId);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302489 hddLog(LOG1, "assocReqlen %d assocRsplen %d", assocReqlen,
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002490 assocRsplen);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302491 if (pHddCtx->cfg_ini &&
2492 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302493 {
2494 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
2495 }
Abhishek Singh5a597e62016-12-05 15:16:30 +05302496 roam_bss = hdd_get_bss_entry(pAdapter->wdev.wiphy,
2497 chan, pRoamInfo->bssid,
2498 pRoamInfo->u.pConnectedProfile->SSID.ssId,
2499 pRoamInfo->u.pConnectedProfile->SSID.length);
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302500 hdd_send_roamed_ind(dev, roam_bss,
Abhishek Singh5a597e62016-12-05 15:16:30 +05302501 pFTAssocReq, assocReqlen,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302502 pFTAssocRsp, assocRsplen);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302503 }
Gopichand Nakkala3d295922013-05-07 16:19:14 +05302504 if (sme_GetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter)))
2505 {
2506 sme_SetFTPTKState(WLAN_HDD_GET_HAL_CTX(pAdapter), FALSE);
2507 pRoamInfo->fAuthRequired = FALSE;
2508
2509 vos_mem_copy(pHddStaCtx->roam_info.bssid,
2510 pRoamInfo->bssid,
2511 HDD_MAC_ADDR_LEN);
2512 vos_mem_copy(pHddStaCtx->roam_info.peerMac,
2513 pRoamInfo->peerMac,
2514 HDD_MAC_ADDR_LEN);
2515 pHddStaCtx->roam_info.roamId = roamId;
2516 pHddStaCtx->roam_info.roamStatus = roamStatus;
2517 pHddStaCtx->roam_info.deferKeyComplete = TRUE;
2518 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002519 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302520 else if ( !hddDisconInProgress )
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002521 {
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002522 hddLog(LOG1, "%s ft_carrier_on is %d, sending connect "
Arif Hussain6d2a3322013-11-17 19:50:10 -08002523 "indication", __FUNCTION__, ft_carrier_on);
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302524 hdd_connect_result(dev, pRoamInfo->bssid, pRoamInfo,
2525 pFTAssocReq, assocReqlen,
2526 pFTAssocRsp, assocRsplen,
2527 WLAN_STATUS_SUCCESS,
2528 GFP_KERNEL);
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002529 }
2530 }
2531 else
2532#endif
2533 {
2534 /* wpa supplicant expecting WPA/RSN IE in connect result */
2535 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2536 pAdapter->sessionId,
2537 &reqRsnLength,
2538 reqRsnIe);
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002539
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002540 csrRoamGetWpaRsnRspIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2541 pAdapter->sessionId,
2542 &rspRsnLength,
2543 rspRsnIe);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302544 if ( !hddDisconInProgress )
2545 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002546#if defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302547 if(ft_carrier_on)
Mukul Sharma84f27252014-07-14 18:11:42 +05302548 {
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302549 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302550 if (pHddCtx->cfg_ini &&
2551 pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302552 {
2553 vos_record_roam_event(e_HDD_SEND_REASSOC_RSP, NULL, 0);
2554 }
Mukul Sharma84f27252014-07-14 18:11:42 +05302555 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302556 else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08002557#endif /* FEATURE_WLAN_ESE */
Madan Mohan Koyyalamudif146b382012-11-06 18:53:10 -08002558
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302559 {
2560 hddLog(VOS_TRACE_LEVEL_INFO,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302561 "%s: sending connect indication to nl80211:"
2562 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302563 " result:%d and Status:%d",
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302564 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
2565 roamResult, roamStatus);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302566 /* inform connect result to nl80211 */
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302567 hdd_connect_result(dev, pRoamInfo->bssid,
2568 pRoamInfo,
2569 reqRsnIe, reqRsnLength,
2570 rspRsnIe, rspRsnLength,
2571 WLAN_STATUS_SUCCESS,
2572 GFP_KERNEL);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302573 }
Madan Mohan Koyyalamudiea773882012-11-02 13:37:21 -07002574 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002575 }
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302576 if ( !hddDisconInProgress )
2577 {
2578 cfg80211_put_bss(
Yue Maf49ba872013-08-19 12:04:25 -07002579#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302580 pHddCtx->wiphy,
Yue Maf49ba872013-08-19 12:04:25 -07002581#endif
2582 bss);
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302583 // Register the Station with TL after associated...
2584 vosStatus = hdd_roamRegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07002585 pRoamInfo,
2586 pHddStaCtx->conn_info.staId[ 0 ],
2587 NULL,
2588 pRoamInfo->pBssDesc );
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302589 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002590 }
2591 else
2592 {
Madan Mohan Koyyalamudi2dd4c8d2012-11-08 14:44:14 -08002593 /* wpa supplicant expecting WPA/RSN IE in connect result */
2594 /* in case of reassociation also need to indicate it to supplicant */
2595 csrRoamGetWpaRsnReqIE(WLAN_HDD_GET_HAL_CTX(pAdapter),
2596 pAdapter->sessionId,
2597 &reqRsnLength,
2598 reqRsnIe);
2599
2600 hdd_SendReAssocEvent(dev, pAdapter, pRoamInfo, reqRsnIe, reqRsnLength);
Jeff Johnson295189b2012-06-20 16:38:30 -07002601 //Reassoc successfully
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302602 if( pRoamInfo->fAuthRequired )
2603 {
2604 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2605 pHddStaCtx->conn_info.staId[ 0 ],
2606 WLANTL_STA_CONNECTED );
2607 pHddStaCtx->conn_info.uIsAuthenticated = VOS_FALSE;
2608 }
2609 else
2610 {
2611 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
2612 "%s: staId: %d Changing TL state to AUTHENTICATED",
2613 __func__, pHddStaCtx->conn_info.staId[ 0 ] );
2614 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
2615 pHddStaCtx->conn_info.staId[ 0 ],
2616 WLANTL_STA_AUTHENTICATED );
2617 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05302618 hdd_postTLPacketPendingInd(pAdapter,
2619 pHddStaCtx->conn_info.staId[0]);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05302620 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002621 }
2622
2623 if ( VOS_IS_STATUS_SUCCESS( vosStatus ) )
2624 {
2625 // perform any WMM-related association processing
2626 hdd_wmm_assoc(pAdapter, pRoamInfo, eCSR_BSS_TYPE_INFRASTRUCTURE);
2627 }
2628 else
2629 {
2630 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07002631 "Cannot register STA with TL. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07002632 vosStatus, vosStatus );
2633 }
Chet Lanctot186b5732013-03-18 10:26:30 -07002634#ifdef WLAN_FEATURE_11W
2635 vos_mem_zero( &pAdapter->hdd_stats.hddPmfStats,
2636 sizeof(pAdapter->hdd_stats.hddPmfStats) );
2637#endif
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302638
Jeff Johnson295189b2012-06-20 16:38:30 -07002639 // Start the Queue
Katya Nigamb130d572014-11-24 16:38:16 +05302640 if ( !hddDisconInProgress )
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302641 {
2642 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Katya Nigamb130d572014-11-24 16:38:16 +05302643 netif_tx_wake_all_queues(dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302644 }
Anurag Chouhan6f6198c2016-08-28 12:43:46 +05302645 if (pHddCtx->cfg_ini && pHddCtx->cfg_ini->gEnableRoamDelayStats)
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05302646 {
2647 vos_record_roam_event(e_HDD_ENABLE_TX_QUEUE, NULL, 0);
2648 }
Padma, Santhosh Kumar38cef182016-02-18 12:22:51 +05302649#ifdef FEATURE_WLAN_TDLS
2650 wlan_hdd_tdls_connection_callback(pAdapter);
2651#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07002652 }
2653 else
Jeff Johnson295189b2012-06-20 16:38:30 -07002654 {
Jeff Johnson295189b2012-06-20 16:38:30 -07002655 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2656
2657 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002658 if (pRoamInfo)
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302659 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2660 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
2661 MAC_ADDR_ARRAY(pRoamInfo->bssid), roamResult, roamStatus);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002662 else
Deepthi Gowric7591cc2015-12-28 15:43:17 +05302663 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2664 "wlan: connection failed with " MAC_ADDRESS_STR " result:%d and Status:%d",
Arif Hussain24bafea2013-11-15 15:10:03 -08002665 MAC_ADDR_ARRAY(pWextState->req_bssId),
2666 roamResult, roamStatus);
Abhishek Singh6782c9e2017-06-06 13:37:45 +05302667 if (!pHddStaCtx->get_mgmt_log_sent) {
2668 pHddStaCtx->get_mgmt_log_sent = TRUE;
Abhishek Singh611295e2015-07-09 11:11:54 +05302669 wlan_hdd_get_frame_logs(pAdapter,
Siddharth Bhalda0d1622015-04-24 15:47:49 +05302670 WLAN_HDD_GET_FRAME_LOG_CMD_SEND_AND_CLEAR);
Abhishek Singh6782c9e2017-06-06 13:37:45 +05302671 }
Siddharth Bhalda0d1622015-04-24 15:47:49 +05302672
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05302673 if ((eCSR_ROAM_RESULT_SCAN_FOR_SSID_FAILURE == roamResult) ||
2674 (pRoamInfo &&
2675 ((eSIR_SME_JOIN_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
2676 (eSIR_SME_AUTH_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode) ||
2677 (eSIR_SME_ASSOC_TIMEOUT_RESULT_CODE == pRoamInfo->statusCode)))) {
Abhishek Singhe6137b82019-03-22 20:06:09 +05302678 wlan_hdd_cfg80211_unlink_bss(pAdapter,
Abhishek Singhbfb3c9e2016-07-22 11:25:43 +05302679 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
2680 sme_remove_bssid_from_scan_list(pHddCtx->hHal,
2681 pRoamInfo ? pRoamInfo->bssid : pWextState->req_bssId);
2682 }
Abhishek Singhf4669da2014-05-26 15:07:49 +05302683 /* Set connection state to eConnectionState_NotConnected only when CSR
2684 * has completed operation - with a ASSOCIATION_FAILURE status
2685 */
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302686 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Abhishek Singhf4669da2014-05-26 15:07:49 +05302687 {
2688 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2689 "%s: Set HDD connState to eConnectionState_NotConnected",
2690 __func__);
2691 hdd_connSetConnectionState( pHddStaCtx, eConnectionState_NotConnected);
2692 }
Agarwal Ashish51325b52014-06-16 16:50:49 +05302693 if((pHddCtx->concurrency_mode <= 1) &&
2694 (pHddCtx->no_of_open_sessions[WLAN_HDD_INFRA_STATION] <=1))
Jeff Johnson295189b2012-06-20 16:38:30 -07002695 {
2696 pHddCtx->isAmpAllowed = VOS_TRUE;
2697 }
2698
2699 //If the Device Mode is Station
2700 // and the P2P Client is Connected
2701 //Enable BMPS
Jeff Johnsone7245742012-09-05 17:12:55 -07002702
2703 // In case of JB, as Change-Iface may or maynot be called for p2p0
Shailender Karmuchia734f332013-04-19 14:02:48 -07002704 // Enable BMPS/IMPS in case P2P_CLIENT disconnected
Jeff Johnsone7245742012-09-05 17:12:55 -07002705 if(((WLAN_HDD_INFRA_STATION == pAdapter->device_mode) ||
2706 (WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)) &&
Agarwal Ashish51325b52014-06-16 16:50:49 +05302707 (vos_concurrent_open_sessions_running()))
Jeff Johnson295189b2012-06-20 16:38:30 -07002708 {
2709 //Enable BMPS only of other Session is P2P Client
2710 hdd_context_t *pHddCtx = NULL;
2711 v_CONTEXT_t pVosContext = vos_get_global_context( VOS_MODULE_ID_HDD, NULL );
2712
2713 if (NULL != pVosContext)
2714 {
2715 pHddCtx = vos_get_context( VOS_MODULE_ID_HDD, pVosContext);
2716
2717 if(NULL != pHddCtx)
2718 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302719 //Only P2P Client is there Enable Bmps back
Agarwal Ashish51325b52014-06-16 16:50:49 +05302720 if((0 == pHddCtx->no_of_open_sessions[VOS_STA_SAP_MODE]) &&
2721 (0 == pHddCtx->no_of_open_sessions[VOS_P2P_GO_MODE]))
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302722 {
2723 if (pHddCtx->hdd_wlan_suspended)
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002724 {
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302725 hdd_set_pwrparams(pHddCtx);
Tushnim Bhattacharyya3a37def2013-02-24 11:11:15 -08002726 }
Gopichand Nakkalaa2fe5b02013-06-06 16:32:28 +05302727 hdd_enable_bmps_imps(pHddCtx);
2728 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002729 }
2730 }
2731 }
2732
James Zmudafbf5ffc2013-03-25 12:45:35 -07002733 /* CR465478: Only send up a connection failure result when CSR has
Varun Reddy Yeturuda7f0d52013-12-20 11:16:57 -08002734 * completed operation - with a ASSOCIATION_FAILURE status.*/
Abhishek Singha6cfaa42014-06-23 13:11:07 +05302735 if ( eCSR_ROAM_ASSOCIATION_FAILURE == roamStatus && !hddDisconInProgress )
Jeff Johnsone7245742012-09-05 17:12:55 -07002736 {
Masti, Narayanraddi575ccc72015-08-17 18:04:57 +05302737
2738 if (pAdapter->device_mode == WLAN_HDD_P2P_CLIENT)
2739 {
2740 hddLog(LOG1,
2741 FL("Assoication Failure for P2P client and we are trying to re-enable TDLS"));
2742 wlan_hdd_tdls_reenable(pHddCtx);
2743 }
2744
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302745 if (pRoamInfo) {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302746 hddLog(VOS_TRACE_LEVEL_ERROR,
2747 "%s: send connect failure to nl80211:"
2748 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302749 " result:%d and Status:%d reasonCode %d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302750 __func__, MAC_ADDR_ARRAY(pRoamInfo->bssid),
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302751 roamResult, roamStatus, pRoamInfo->reasonCode);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302752 pHddStaCtx->conn_info.assoc_status_code =
2753 pRoamInfo->statusCode;
2754 } else {
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302755 hddLog(VOS_TRACE_LEVEL_ERROR,
2756 "%s: connect failed:"
2757 " for bssid " MAC_ADDRESS_STR
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302758 " result:%d and Status:%d" ,
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302759 __func__, MAC_ADDR_ARRAY(pWextState->req_bssId),
2760 roamResult, roamStatus);
Anurag Chouhanbdb1fd62017-07-19 16:32:33 +05302761 }
Deepthi Gowri6649f6a2014-02-18 17:31:23 +05302762
James Zmudafbf5ffc2013-03-25 12:45:35 -07002763 /* inform association failure event to nl80211 */
2764 if ( eCSR_ROAM_RESULT_ASSOC_FAIL_CON_CHANNEL == roamResult )
2765 {
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002766 if (pRoamInfo)
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302767 hdd_connect_result(dev, pRoamInfo->bssid, NULL,
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002768 NULL, 0, NULL, 0,
2769 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302770 GFP_KERNEL);
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002771 else
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302772 hdd_connect_result(dev, pWextState->req_bssId, NULL,
Kiran Kumar Lokerec8550fa2013-04-15 22:23:00 -07002773 NULL, 0, NULL, 0,
2774 WLAN_STATUS_ASSOC_DENIED_UNSPEC,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302775 GFP_KERNEL);
James Zmudafbf5ffc2013-03-25 12:45:35 -07002776 }
2777 else
2778 {
Gao Wu6ca73b32016-05-09 14:35:49 +08002779 if (pRoamInfo)
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302780 hdd_connect_result(dev, pRoamInfo->bssid, NULL,
Gao Wu6ca73b32016-05-09 14:35:49 +08002781 NULL, 0, NULL, 0,
2782 pRoamInfo->reasonCode ?
2783 pRoamInfo->reasonCode :
2784 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302785 GFP_KERNEL);
Gao Wu6ca73b32016-05-09 14:35:49 +08002786 else
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302787 hdd_connect_result(dev, pWextState->req_bssId, NULL,
Gao Wu6ca73b32016-05-09 14:35:49 +08002788 NULL, 0, NULL, 0,
2789 WLAN_STATUS_UNSPECIFIED_FAILURE,
Abhishek Singhbbe0b2a2016-12-05 11:57:36 +05302790 GFP_KERNEL);
James Zmudafbf5ffc2013-03-25 12:45:35 -07002791 }
Abhishek Singhc0fccd22015-10-19 16:44:00 +05302792 /*Clear the roam profile*/
2793 hdd_clearRoamProfileIe( pAdapter );
Jeff Johnsone7245742012-09-05 17:12:55 -07002794 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002795
Kumar Anand82c009f2014-05-29 00:29:42 -07002796 hdd_wmm_init( pAdapter );
Madan Mohan Koyyalamudiee255f12012-09-28 15:41:19 -07002797
c_hpothu24f40982014-04-18 18:00:36 +05302798 if (pRoamInfo)
2799 {
2800 WLANTL_AssocFailed(pRoamInfo->staId);
2801 }
Mihir Sheteb7337272014-04-11 15:53:08 +05302802
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05302803 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07002804 netif_tx_disable(dev);
2805 netif_carrier_off(dev);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002806
Jeff Johnson295189b2012-06-20 16:38:30 -07002807 }
2808
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302809 if (eCSR_ROAM_RESULT_ASSOCIATED == roamResult)
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302810 {
2811 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
2812 if (pHostapdAdapter != NULL)
2813 {
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302814 /* Restart SAP if its operating channel is different
2815 * from AP channel.
2816 */
2817 if (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
2818 (int)pRoamInfo->pBssDesc->channelId)
2819 {
2820 hddLog(VOS_TRACE_LEVEL_INFO,"Restart Sap as SAP channel is %d "
2821 "and STA channel is %d", pHostapdAdapter->sessionCtx.ap.operatingChannel,
2822 (int)pRoamInfo->pBssDesc->channelId);
Hanumanth Reddy Pothula8d4b8eb2018-02-26 16:14:10 +05302823 if (pHddCtx->cfg_ini && pHddCtx->cfg_ini->force_scc_with_ecsa)
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302824 {
Abhishek Singh78c691f2017-11-30 13:48:44 +05302825 hdd_schedule_ecsa_chan_change_work(pHddCtx,
2826 pAdapter->sessionId);
2827 }
2828 else
2829 {
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302830 hdd_hostapd_stop(pHostapdAdapter->dev);
Hanumanth Reddy Pothula8d4b8eb2018-02-26 16:14:10 +05302831 if (pHddCtx->cfg_ini &&
2832 pHddCtx->cfg_ini->enable_sap_auth_offload)
Abhishek Singhceb6fe22017-11-27 13:53:18 +05302833 hdd_force_scc_restart_sap(pHostapdAdapter,
2834 pHddCtx, (int)pRoamInfo->pBssDesc->channelId);
2835 }
Agrawal Ashish574b3e62017-02-09 18:58:34 +05302836
Sushant Kaushikbf584e92014-08-06 17:59:20 +05302837 }
Sushant Kaushikba6764e2014-06-30 19:52:09 +05302838 }
2839 }
Abhishek Singh10e17cf2018-03-12 14:34:22 +05302840 else if (roamStatus == eCSR_ROAM_ASSOCIATION_FAILURE)
2841 {
2842 hdd_check_and_move_if_sap_is_on_dfs_chan(pHddCtx, pAdapter);
2843 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002844 return eHAL_STATUS_SUCCESS;
2845}
2846
2847/**============================================================================
2848 *
Jeff Johnson81c17882013-05-03 09:53:35 -07002849 @brief hdd_RoamIbssIndicationHandler() - Here we update the status of the
Jeff Johnson295189b2012-06-20 16:38:30 -07002850 Ibss when we receive information that we have started/joined an ibss session
Shailender Karmuchia734f332013-04-19 14:02:48 -07002851
Jeff Johnson295189b2012-06-20 16:38:30 -07002852 ===========================================================================*/
Jeff Johnson81c17882013-05-03 09:53:35 -07002853static void hdd_RoamIbssIndicationHandler( hdd_adapter_t *pAdapter,
2854 tCsrRoamInfo *pRoamInfo,
2855 tANI_U32 roamId,
2856 eRoamCmdStatus roamStatus,
2857 eCsrRoamResult roamResult )
Jeff Johnson295189b2012-06-20 16:38:30 -07002858{
Katya Nigam47528772015-02-11 12:24:49 +05302859 hdd_context_t *pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
2860 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
2861 struct cfg80211_bss *bss;
Abhishek Singhb25e8442015-06-23 14:28:05 +05302862 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Katya Nigam47528772015-02-11 12:24:49 +05302863
Jeff Johnson81c17882013-05-03 09:53:35 -07002864 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: id %d, status %d, result %d",
2865 __func__, pAdapter->dev->name, roamId, roamStatus, roamResult);
2866
Jeff Johnson295189b2012-06-20 16:38:30 -07002867 switch( roamResult )
2868 {
2869 // both IBSS Started and IBSS Join should come in here.
2870 case eCSR_ROAM_RESULT_IBSS_STARTED:
2871 case eCSR_ROAM_RESULT_IBSS_JOIN_SUCCESS:
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07002872 case eCSR_ROAM_RESULT_IBSS_COALESCED:
Jeff Johnson295189b2012-06-20 16:38:30 -07002873 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002874 if (NULL == pRoamInfo)
2875 {
2876 VOS_ASSERT(0);
2877 return;
2878 }
2879
2880 /* When IBSS Started comes from CSR, we need to move
2881 * connection state to IBSS Disconnected (meaning no peers
2882 * are in the IBSS).
2883 */
Abhishek Singhf4669da2014-05-26 15:07:49 +05302884 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
2885 "%s: Set HDD connState to eConnectionState_IbssDisconnected",
2886 __func__);
Jeff Johnson81c17882013-05-03 09:53:35 -07002887 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
2888 eConnectionState_IbssDisconnected );
Abhishek Singh1c21c4d2014-04-25 16:40:19 +05302889 /*notify wmm */
2890 hdd_wmm_connect(pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS);
Shailender Karmuchia734f332013-04-19 14:02:48 -07002891 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
Jeff Johnson295189b2012-06-20 16:38:30 -07002892
Jeff Johnson81c17882013-05-03 09:53:35 -07002893 if (pRoamInfo->pBssDesc)
2894 {
Anand N Sunkadfec40682015-07-29 09:51:17 +05302895#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2896 struct ieee80211_channel *chan;
2897 int chan_no;
2898 unsigned int freq;
2899#endif
Katya Nigam47528772015-02-11 12:24:49 +05302900 hdd_ibss_RegisterSTA (pAdapter, pRoamInfo,
2901 IBSS_BROADCAST_STAID,
2902 &broadcastMacAddr, pRoamInfo->pBssDesc);
Jeff Johnson81c17882013-05-03 09:53:35 -07002903
2904 /* we created the IBSS, notify supplicant */
2905 hddLog(VOS_TRACE_LEVEL_INFO, "%s: %s: created ibss "
2906 MAC_ADDRESS_STR,
2907 __func__, pAdapter->dev->name,
2908 MAC_ADDR_ARRAY(pRoamInfo->pBssDesc->bssId));
2909
2910 /* we must first give cfg80211 the BSS information */
2911 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
2912 if (NULL == bss)
2913 {
2914 hddLog(VOS_TRACE_LEVEL_ERROR,
2915 "%s: %s: unable to create IBSS entry",
2916 __func__, pAdapter->dev->name);
2917 return;
2918 }
Abhishek Singh00b71972016-01-07 10:51:04 +05302919#ifdef WLAN_FEATURE_RMC
2920 netif_carrier_on(pAdapter->dev);
2921 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
2922 netif_tx_start_all_queues(pAdapter->dev);
2923#endif
Anand N Sunkadfec40682015-07-29 09:51:17 +05302924#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,15,0))
2925 chan_no = pRoamInfo->pBssDesc->channelId;
Jeff Johnson81c17882013-05-03 09:53:35 -07002926
Anand N Sunkadfec40682015-07-29 09:51:17 +05302927 if (chan_no <= 14)
2928 freq = ieee80211_channel_to_frequency(chan_no,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302929 HDD_NL80211_BAND_2GHZ);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302930 else
2931 freq = ieee80211_channel_to_frequency(chan_no,
Rajeev Kumar Sirasanagandla5b21a9c2018-01-08 17:05:11 +05302932 HDD_NL80211_BAND_5GHZ);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302933
2934 chan = ieee80211_get_channel(pAdapter->wdev.wiphy, freq);
2935
2936 if (chan)
2937 cfg80211_ibss_joined(pAdapter->dev, bss->bssid,
2938 chan, GFP_KERNEL);
2939 else
2940 hddLog(LOGE, FL("%s: chanId: %d, can't find channel"),
2941 pAdapter->dev->name,
2942 (int)pRoamInfo->pBssDesc->channelId);
2943#else
Jeff Johnson81c17882013-05-03 09:53:35 -07002944 cfg80211_ibss_joined(pAdapter->dev, bss->bssid, GFP_KERNEL);
Anand N Sunkadfec40682015-07-29 09:51:17 +05302945#endif
Yue Maf49ba872013-08-19 12:04:25 -07002946 cfg80211_put_bss(
2947#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
2948 pHddCtx->wiphy,
2949#endif
2950 bss);
Jeff Johnson81c17882013-05-03 09:53:35 -07002951 }
Katya Nigam47528772015-02-11 12:24:49 +05302952 else
2953 {
2954 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
2955 "%s: NULL Bss Desc",__func__);
2956 }
Abhishek Singhb25e8442015-06-23 14:28:05 +05302957
2958 /* Set Broadcast key again in case IBSS_COALESCED as DEL BSS,
2959 * in IBSS_COALESCED will remove the BC key.
2960 */
2961 if ((eCSR_ROAM_RESULT_IBSS_COALESCED == roamResult) &&
2962 ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY
2963 == pHddStaCtx->ibss_enc_key.encType
2964 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY
2965 == pHddStaCtx->ibss_enc_key.encType
2966 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
2967 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType ))
2968 {
2969 u8 grpmacaddr[WNI_CFG_BSSID_LEN] = {0xFF,0xFF,0xFF,0xFF,0xFF,0xFF};
2970 VOS_STATUS vosStatus;
2971
2972 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
2973
2974 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
2975 grpmacaddr, WNI_CFG_BSSID_LEN);
2976 hddLog(VOS_TRACE_LEVEL_INFO,
2977 FL(" SET GTK in case of COALESCED"));
2978 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
2979 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
2980 if ( VOS_STATUS_SUCCESS != vosStatus )
2981 {
2982 hddLog(VOS_TRACE_LEVEL_ERROR,
2983 FL("sme_RoamSetKey failed, returned %d"),vosStatus);
2984 }
2985 }
Jeff Johnson295189b2012-06-20 16:38:30 -07002986 break;
2987 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002988
Jeff Johnson295189b2012-06-20 16:38:30 -07002989 case eCSR_ROAM_RESULT_IBSS_START_FAILED:
2990 {
Jeff Johnson81c17882013-05-03 09:53:35 -07002991 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unable to create IBSS",
2992 __func__, pAdapter->dev->name);
Jeff Johnson295189b2012-06-20 16:38:30 -07002993 break;
2994 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07002995
Jeff Johnson295189b2012-06-20 16:38:30 -07002996 default:
Jeff Johnson81c17882013-05-03 09:53:35 -07002997 hddLog(VOS_TRACE_LEVEL_ERROR, "%s: %s: unexpected result %d",
2998 __func__, pAdapter->dev->name, (int)roamResult);
Jeff Johnson295189b2012-06-20 16:38:30 -07002999 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003000 }
3001
Jeff Johnson81c17882013-05-03 09:53:35 -07003002 return;
Jeff Johnson295189b2012-06-20 16:38:30 -07003003}
3004
3005/**============================================================================
3006 *
3007 @brief roamSaveIbssStation() - Save the IBSS peer MAC address in the adapter.
3008 This information is passed to iwconfig later. The peer that joined
3009 last is passed as information to iwconfig.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003010 If we add HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07003011 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003012
Jeff Johnson295189b2012-06-20 16:38:30 -07003013 ===========================================================================*/
Nirav Shah7e3c8132015-06-22 23:51:42 +05303014static int roamSaveIbssStation(hdd_adapter_t *pAdapter, v_U8_t staId, v_MACADDR_t *peerMacAddress)
Jeff Johnson295189b2012-06-20 16:38:30 -07003015{
3016 int fSuccess = FALSE;
3017 int idx = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05303018 VOS_STATUS status;
3019 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003020
Jeff Johnson295189b2012-06-20 16:38:30 -07003021 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
3022 {
3023 if ( 0 == pHddStaCtx->conn_info.staId[ idx ] )
3024 {
3025 pHddStaCtx->conn_info.staId[ idx ] = staId;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003026
Jeff Johnson295189b2012-06-20 16:38:30 -07003027 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ], peerMacAddress );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003028
Jeff Johnson295189b2012-06-20 16:38:30 -07003029 fSuccess = TRUE;
3030 break;
3031 }
3032 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003033
Nirav Shah7e3c8132015-06-22 23:51:42 +05303034 status = hdd_sta_id_hash_add_entry(pAdapter, staId, peerMacAddress);
3035 if (status != VOS_STATUS_SUCCESS) {
3036 hddLog(VOS_TRACE_LEVEL_ERROR,
3037 FL("Not able to add staid hash %d"), staId);
3038 return FALSE;
3039 }
3040
3041 hddLog(VOS_TRACE_LEVEL_INFO,
3042 FL("New station added sta_id %d mac:"
3043 MAC_ADDRESS_STR), staId,
3044 MAC_ADDR_ARRAY(peerMacAddress->bytes));
3045
Shailender Karmuchia734f332013-04-19 14:02:48 -07003046 return( fSuccess );
Jeff Johnson295189b2012-06-20 16:38:30 -07003047}
3048/**============================================================================
3049 *
3050 @brief roamRemoveIbssStation() - Remove the IBSS peer MAC address in the adapter.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003051 If we remove HDD_MAX_NUM_IBSS_STA or less STA we return success else we
Jeff Johnson295189b2012-06-20 16:38:30 -07003052 return FALSE.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003053
Jeff Johnson295189b2012-06-20 16:38:30 -07003054 ===========================================================================*/
Ravi Joshicc57ed42013-10-12 16:31:25 -07003055static int roamRemoveIbssStation( hdd_adapter_t *pAdapter, v_U8_t staId )
Jeff Johnson295189b2012-06-20 16:38:30 -07003056{
3057 int fSuccess = FALSE;
3058 int idx = 0;
3059 v_U8_t valid_idx = 0;
3060 v_U8_t del_idx = 0;
Ravi Joshi8a934352013-09-25 16:46:58 -07003061 v_U8_t empty_slots = 0;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003062 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Nirav Shah7e3c8132015-06-22 23:51:42 +05303063 VOS_STATUS status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003064
Jeff Johnson295189b2012-06-20 16:38:30 -07003065 for ( idx = 0; idx < HDD_MAX_NUM_IBSS_STA; idx++ )
3066 {
3067 if ( staId == pHddStaCtx->conn_info.staId[ idx ] )
3068 {
3069 pHddStaCtx->conn_info.staId[ idx ] = 0;
Nirav Shah7e3c8132015-06-22 23:51:42 +05303070 status = hdd_sta_id_hash_remove_entry(pAdapter,
3071 staId, &pHddStaCtx->conn_info.peerMacAddress[idx]);
3072 if (status != VOS_STATUS_SUCCESS) {
3073 hddLog(VOS_TRACE_LEVEL_ERROR,
3074 FL("Not able to remove staid hash %d"), staId );
3075 fSuccess = FALSE;
3076 } else {
3077 hddLog(VOS_TRACE_LEVEL_INFO,
3078 FL("station removed sta_id %d mac:"
3079 MAC_ADDRESS_STR), staId,
3080 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.peerMacAddress[idx].bytes));
Jeff Johnson295189b2012-06-20 16:38:30 -07003081
Nirav Shah7e3c8132015-06-22 23:51:42 +05303082 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ idx ] );
Jeff Johnson295189b2012-06-20 16:38:30 -07003083
Nirav Shah7e3c8132015-06-22 23:51:42 +05303084 fSuccess = TRUE;
3085 // Note the deleted Index, if its 0 we need special handling
3086 del_idx = idx;
3087 empty_slots++;
3088 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003089 }
3090 else
3091 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003092 if (pHddStaCtx->conn_info.staId[idx] != 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07003093 {
3094 valid_idx = idx;
3095 }
Ravi Joshi8a934352013-09-25 16:46:58 -07003096 else
3097 {
3098 // Found an empty slot
3099 empty_slots++;
3100 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003101 }
3102 }
3103
Ravi Joshi8a934352013-09-25 16:46:58 -07003104 if (HDD_MAX_NUM_IBSS_STA == empty_slots)
3105 {
3106 // Last peer departed, set the IBSS state appropriately
3107 pHddStaCtx->conn_info.connState = eConnectionState_IbssDisconnected;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003108 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Ravi Joshi8a934352013-09-25 16:46:58 -07003109 "Last IBSS Peer Departed!!!" );
3110 }
3111
Jeff Johnson295189b2012-06-20 16:38:30 -07003112 // Find next active staId, to have a valid sta trigger for TL.
3113 if (fSuccess == TRUE)
3114 {
3115 if (del_idx == 0)
3116 {
3117 if (pHddStaCtx->conn_info.staId[valid_idx] != 0)
3118 {
3119 pHddStaCtx->conn_info.staId[0] = pHddStaCtx->conn_info.staId[valid_idx];
3120 vos_copy_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ 0 ],
3121 &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ]);
3122
3123 pHddStaCtx->conn_info.staId[valid_idx] = 0;
3124 vos_zero_macaddr( &pHddStaCtx->conn_info.peerMacAddress[ valid_idx ] );
3125 }
3126 }
3127 }
3128 return( fSuccess );
3129}
3130
3131/**============================================================================
3132 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07003133 @brief roamIbssConnectHandler() : We update the status of the IBSS to
Jeff Johnson295189b2012-06-20 16:38:30 -07003134 connected in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003135
Jeff Johnson295189b2012-06-20 16:38:30 -07003136 ===========================================================================*/
3137static eHalStatus roamIbssConnectHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo )
3138{
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003139 struct cfg80211_bss *bss;
Abhishek Singhf4669da2014-05-26 15:07:49 +05303140 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3141 "%s: IBSS Connect Indication from SME!!! "
3142 "Set HDD connState to eConnectionState_IbssConnected",
3143 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003144 // Set the internal connection state to show 'IBSS Connected' (IBSS with a partner stations)...
3145 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_IbssConnected );
3146
3147 // Save the connection info from CSR...
3148 hdd_connSaveConnectInfo( pAdapter, pRoamInfo, eCSR_BSS_TYPE_IBSS );
3149
3150 // Send the bssid address to the wext.
3151 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
Jeff Johnson295189b2012-06-20 16:38:30 -07003152 /* add bss_id to cfg80211 data base */
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003153 bss = wlan_hdd_cfg80211_update_bss_db(pAdapter, pRoamInfo);
3154 if (NULL == bss)
3155 {
3156 hddLog(VOS_TRACE_LEVEL_ERROR,
3157 "%s: %s: unable to create IBSS entry",
3158 __func__, pAdapter->dev->name);
3159 return eHAL_STATUS_FAILURE;
3160 }
Yue Maf49ba872013-08-19 12:04:25 -07003161 cfg80211_put_bss(
3162#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,9,0))
3163 WLAN_HDD_GET_CTX(pAdapter)->wiphy,
3164#endif
3165 bss);
Jeff Johnson295189b2012-06-20 16:38:30 -07003166
3167 return( eHAL_STATUS_SUCCESS );
3168}
Mukul Sharmad2589a52014-04-23 21:06:25 +05303169
3170/**============================================================================
3171 *
Jeff Johnson295189b2012-06-20 16:38:30 -07003172 @brief hdd_RoamSetKeyCompleteHandler() - Update the security parameters.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003173
Jeff Johnson295189b2012-06-20 16:38:30 -07003174 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003175static eHalStatus hdd_RoamSetKeyCompleteHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
3176 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07003177 eCsrRoamResult roamResult )
3178{
3179 eCsrEncryptionType connectedCipherAlgo;
3180 v_BOOL_t fConnected = FALSE;
3181 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
3182 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Bhargav Shaha805ef22015-07-29 17:31:38 +05303183 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003184 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303185 WLANTL_STAStateType prevTLState = WLANTL_STA_INIT;
Jeff Johnson295189b2012-06-20 16:38:30 -07003186 ENTER();
Srinivas Girigowda5a737f22013-06-28 15:21:48 -07003187
3188 if (NULL == pRoamInfo)
3189 {
3190 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "pRoamInfo is NULL");
3191 return eHAL_STATUS_FAILURE;
3192 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003193 // if ( WPA ), tell TL to go to 'authenticated' after the keys are set.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003194 // then go to 'authenticated'. For all other authentication types (those that do
Jeff Johnson295189b2012-06-20 16:38:30 -07003195 // not require upper layer authentication) we can put TL directly into 'authenticated'
3196 // state.
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003197 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3198 "Set Key completion roamStatus =%d roamResult=%d " MAC_ADDRESS_STR,
3199 roamStatus, roamResult, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003200
Jeff Johnson295189b2012-06-20 16:38:30 -07003201 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
3202 if( fConnected )
3203 {
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003204 if ( WLAN_HDD_IBSS == pAdapter->device_mode )
3205 {
3206 v_U8_t staId;
3207
3208 v_MACADDR_t broadcastMacAddr = VOS_MAC_ADDR_BROADCAST_INITIALIZER;
3209
3210 if ( 0 == memcmp( pRoamInfo->peerMac,
3211 &broadcastMacAddr, VOS_MAC_ADDR_SIZE ) )
3212 {
3213 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3214 IBSS_BROADCAST_STAID);
Abhishek Singhb25e8442015-06-23 14:28:05 +05303215 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3216 "WLAN TL STA GTK Installed for STAID=%d", IBSS_BROADCAST_STAID);
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003217 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3218 }
3219 else
3220 {
3221 vosStatus = hdd_Ibss_GetStaId(pHddStaCtx,
3222 (v_MACADDR_t*)pRoamInfo->peerMac,
3223 &staId);
3224 if ( VOS_STATUS_SUCCESS == vosStatus )
3225 {
3226 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
3227 "WLAN TL STA Ptk Installed for STAID=%d", staId);
3228 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3229 staId);
3230 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3231 }
3232 }
3233 }
3234 else
3235 {
Bhargav Shaha805ef22015-07-29 17:31:38 +05303236 WLANTL_GetSTAState(pHddCtx->pvosContext,
3237 pHddStaCtx->conn_info.staId[0],
3238 &prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303239 // TODO: Considering getting a state machine in HDD later.
3240 // This routine is invoked twice. 1)set PTK 2)set GTK.
3241 // The folloing if statement will be TRUE when setting GTK.
3242 // At this time we don't handle the state in detail.
3243 // Related CR: 174048 - TL not in authenticated state
3244 if ( ( eCSR_ROAM_RESULT_AUTHENTICATED == roamResult ) &&
3245 (pRoamInfo != NULL) && !pRoamInfo->fAuthRequired )
3246 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303247
3248 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "Key set "
3249 "for StaId=%d. Changing TL state to AUTHENTICATED from"
3250 " state:%d", pHddStaCtx->conn_info.staId[0], prevTLState);
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303251
3252 // Connections that do not need Upper layer authentication,
3253 // transition TL to 'Authenticated' state after the keys are set.
3254 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
3255 pHddStaCtx->conn_info.staId[ 0 ],
3256 WLANTL_STA_AUTHENTICATED );
3257
3258 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05303259
3260 if (WLANTL_STA_AUTHENTICATED != prevTLState)
3261 hdd_postTLPacketPendingInd(pAdapter,
3262 pHddStaCtx->conn_info.staId[0]);
Mukul Sharmad2589a52014-04-23 21:06:25 +05303263 //Need to call offload because when roaming happen at that time fwr
3264 //clean offload info as part of the DelBss
3265 // No need to configure offload if host was not suspended
3266 spin_lock(&pHddCtx->filter_lock);
3267 if(pHddCtx->hdd_wlan_suspended)
3268 {
3269 spin_unlock(&pHddCtx->filter_lock);
3270 hdd_ReConfigSuspendDataClearedDuringRoaming(pHddCtx);
3271 }
3272 else
3273 {
3274 spin_unlock(&pHddCtx->filter_lock);
3275 }
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303276 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3277 {
3278 vos_record_roam_event(e_HDD_SET_GTK_RSP, NULL, 0);
3279 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303280 }
3281 else
3282 {
3283 vosStatus = WLANTL_STAPtkInstalled( pHddCtx->pvosContext,
3284 pHddStaCtx->conn_info.staId[ 0 ]);
Bhargav Shaha805ef22015-07-29 17:31:38 +05303285
3286 /* In case of OSEN move TL to 'Authenticated' after PTK is set */
3287 if (pWextState->roamProfile.bOSENAssociation == VOS_TRUE)
3288 {
3289 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED, "PTK set"
3290 " for StaId=%d. Due to OSEN, Changing TL state to"
3291 "AUTHENTICATED from state:%d",
3292 pHddStaCtx->conn_info.staId[0], prevTLState);
3293
3294 vosStatus = WLANTL_ChangeSTAState( pHddCtx->pvosContext,
3295 pHddStaCtx->conn_info.staId[ 0 ],
3296 WLANTL_STA_AUTHENTICATED );
3297
3298 pHddStaCtx->conn_info.uIsAuthenticated = VOS_TRUE;
3299
3300 if (WLANTL_STA_AUTHENTICATED != prevTLState)
3301 hdd_postTLPacketPendingInd(pAdapter,
3302 pHddStaCtx->conn_info.staId[0]);
3303 }
3304
3305
3306
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05303307 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
3308 {
3309 vos_record_roam_event(e_HDD_SET_PTK_RSP, (void *)pRoamInfo->peerMac, 6);
3310 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303311 }
3312
3313 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003314 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003315 }
Gopichand Nakkalaecdebab2013-06-04 18:44:34 +05303316 else
3317 {
3318 // possible disassoc after issuing set key and waiting set key complete
3319 pHddStaCtx->roam_info.roamingState = HDD_ROAM_STATE_NONE;
3320 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003321
Jeff Johnson295189b2012-06-20 16:38:30 -07003322 EXIT();
3323 return( eHAL_STATUS_SUCCESS );
3324}
3325/**============================================================================
3326 *
3327 @brief hdd_RoamMicErrorIndicationHandler() - This function indicates the Mic failure to the supplicant.
3328 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003329static eHalStatus hdd_RoamMicErrorIndicationHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
Jeff Johnson295189b2012-06-20 16:38:30 -07003330 tANI_U32 roamId, eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
Shailender Karmuchia734f332013-04-19 14:02:48 -07003331{
Jeff Johnson295189b2012-06-20 16:38:30 -07003332 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3333
3334 if( eConnectionState_Associated == pHddStaCtx->conn_info.connState &&
3335 TKIP_COUNTER_MEASURE_STOPED == pHddStaCtx->WextState.mTKIPCounterMeasures )
3336 {
3337 struct iw_michaelmicfailure msg;
3338 union iwreq_data wreq;
3339 memset(&msg, '\0', sizeof(msg));
3340 msg.src_addr.sa_family = ARPHRD_ETHER;
3341 memcpy(msg.src_addr.sa_data, pRoamInfo->u.pMICFailureInfo->taMacAddr, sizeof(pRoamInfo->u.pMICFailureInfo->taMacAddr));
Arif Hussain24bafea2013-11-15 15:10:03 -08003342 hddLog(LOG1, "MIC MAC " MAC_ADDRESS_STR,
3343 MAC_ADDR_ARRAY(msg.src_addr.sa_data));
Shailender Karmuchia734f332013-04-19 14:02:48 -07003344
Jeff Johnson295189b2012-06-20 16:38:30 -07003345 if(pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE)
3346 msg.flags = IW_MICFAILURE_GROUP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003347 else
Jeff Johnson295189b2012-06-20 16:38:30 -07003348 msg.flags = IW_MICFAILURE_PAIRWISE;
3349 memset(&wreq, 0, sizeof(wreq));
3350 wreq.data.length = sizeof(msg);
3351 wireless_send_event(pAdapter->dev, IWEVMICHAELMICFAILURE, &wreq, (char *)&msg);
Jeff Johnson295189b2012-06-20 16:38:30 -07003352 /* inform mic failure to nl80211 */
Shailender Karmuchia734f332013-04-19 14:02:48 -07003353 cfg80211_michael_mic_failure(pAdapter->dev,
Jeff Johnson295189b2012-06-20 16:38:30 -07003354 pRoamInfo->u.pMICFailureInfo->taMacAddr,
3355 ((pRoamInfo->u.pMICFailureInfo->multicast == eSIR_TRUE) ?
3356 NL80211_KEYTYPE_GROUP :
3357 NL80211_KEYTYPE_PAIRWISE),
Shailender Karmuchia734f332013-04-19 14:02:48 -07003358 pRoamInfo->u.pMICFailureInfo->keyId,
3359 pRoamInfo->u.pMICFailureInfo->TSC,
Jeff Johnson295189b2012-06-20 16:38:30 -07003360 GFP_KERNEL);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003361
Jeff Johnson295189b2012-06-20 16:38:30 -07003362 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003363
Jeff Johnson295189b2012-06-20 16:38:30 -07003364 return( eHAL_STATUS_SUCCESS );
3365}
3366
3367/**============================================================================
3368 *
Shailender Karmuchia734f332013-04-19 14:02:48 -07003369 @brief roamRoamConnectStatusUpdateHandler() - The Ibss connection status is
Jeff Johnson295189b2012-06-20 16:38:30 -07003370 updated regularly here in this function.
Shailender Karmuchia734f332013-04-19 14:02:48 -07003371
Jeff Johnson295189b2012-06-20 16:38:30 -07003372 ===========================================================================*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07003373static eHalStatus roamRoamConnectStatusUpdateHandler( hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo,
3374 tANI_U32 roamId, eRoamCmdStatus roamStatus,
Jeff Johnson295189b2012-06-20 16:38:30 -07003375 eCsrRoamResult roamResult )
3376{
3377 VOS_STATUS vosStatus;
3378
3379 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3380 switch( roamResult )
3381 {
3382 case eCSR_ROAM_RESULT_IBSS_NEW_PEER:
3383 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003384 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303385 struct station_info *staInfo;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003386
Deepthi Gowric7591cc2015-12-28 15:43:17 +05303387 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3388 "IBSS New Peer indication from SME with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003389 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
3390 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
Jeff Johnson295189b2012-06-20 16:38:30 -07003391 pRoamInfo->staId );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003392
Jeff Johnson295189b2012-06-20 16:38:30 -07003393 pHddCtx->sta_to_adapter[pRoamInfo->staId] = pAdapter;
3394
Shailender Karmuchia734f332013-04-19 14:02:48 -07003395 pHddCtx->sta_to_adapter[IBSS_BROADCAST_STAID] = pAdapter;
3396 WLANTL_UpdateSTABssIdforIBSS(pHddCtx->pvosContext,
3397 IBSS_BROADCAST_STAID,pHddStaCtx->conn_info.bssId);
3398
3399 // Register the Station with TL for the new peer.
Katya Nigam47528772015-02-11 12:24:49 +05303400 vosStatus = hdd_ibss_RegisterSTA( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07003401 pRoamInfo,
3402 pRoamInfo->staId,
3403 (v_MACADDR_t *)pRoamInfo->peerMac,
3404 pRoamInfo->pBssDesc );
3405 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3406 {
3407 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003408 "Cannot register STA with TL for IBSS. Failed with vosStatus = %d [%08X]",
Jeff Johnson295189b2012-06-20 16:38:30 -07003409 vosStatus, vosStatus );
3410 }
Abhishek Singhdecf1b62016-02-09 11:53:58 +05303411 if (!roamSaveIbssStation(pAdapter,
3412 pRoamInfo->staId,
3413 (v_MACADDR_t *)pRoamInfo->peerMac))
3414 {
3415 hddLog(LOGW, FL("Not Able to add sta in sta hash"));
3416 break;
3417 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003418 pHddStaCtx->ibss_sta_generation++;
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303419
3420 staInfo = vos_mem_malloc(sizeof(*staInfo));
3421 if (staInfo == NULL) {
3422 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3423 "memory allocation for station_info failed");
3424 return eHAL_STATUS_FAILED_ALLOC;
3425 }
3426
3427 memset(staInfo, 0, sizeof(*staInfo));
3428 staInfo->filled = 0;
3429 staInfo->generation = pHddStaCtx->ibss_sta_generation;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003430
3431 cfg80211_new_sta(pAdapter->dev,
3432 (const u8 *)pRoamInfo->peerMac,
SaidiReddy Yenugabe255a62016-12-07 16:21:07 +05303433 staInfo, GFP_KERNEL);
3434 vos_mem_free(staInfo);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003435
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003436 if ( eCSR_ENCRYPT_TYPE_WEP40_STATICKEY == pHddStaCtx->ibss_enc_key.encType
3437 ||eCSR_ENCRYPT_TYPE_WEP104_STATICKEY == pHddStaCtx->ibss_enc_key.encType
3438 ||eCSR_ENCRYPT_TYPE_TKIP == pHddStaCtx->ibss_enc_key.encType
3439 ||eCSR_ENCRYPT_TYPE_AES == pHddStaCtx->ibss_enc_key.encType )
3440 {
3441 pHddStaCtx->ibss_enc_key.keyDirection = eSIR_TX_RX;
Abhishek Singhb25e8442015-06-23 14:28:05 +05303442
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003443 memcpy(&pHddStaCtx->ibss_enc_key.peerMac,
3444 pRoamInfo->peerMac, WNI_CFG_BSSID_LEN);
3445
3446 VOS_TRACE( VOS_MODULE_ID_HDD,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003447 VOS_TRACE_LEVEL_INFO_HIGH, "New peer joined set PTK encType=%d",
Shailender Karmuchi642e9812013-05-30 14:34:49 -07003448 pHddStaCtx->ibss_enc_key.encType);
3449
3450 vosStatus = sme_RoamSetKey( WLAN_HDD_GET_HAL_CTX(pAdapter),
3451 pAdapter->sessionId, &pHddStaCtx->ibss_enc_key, &roamId );
3452
3453 if ( VOS_STATUS_SUCCESS != vosStatus )
3454 {
3455 hddLog(VOS_TRACE_LEVEL_ERROR,
3456 "%s: sme_RoamSetKey failed, returned %d",
3457 __func__, vosStatus);
3458 return VOS_STATUS_E_FAILURE;
3459 }
3460 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003461 netif_carrier_on(pAdapter->dev);
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303462 hddLog(VOS_TRACE_LEVEL_INFO, FL("Enabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003463 netif_tx_start_all_queues(pAdapter->dev);
3464 break;
3465 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003466
Jeff Johnson295189b2012-06-20 16:38:30 -07003467 case eCSR_ROAM_RESULT_IBSS_CONNECT:
3468 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003469
Jeff Johnson295189b2012-06-20 16:38:30 -07003470 roamIbssConnectHandler( pAdapter, pRoamInfo );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003471
Jeff Johnson295189b2012-06-20 16:38:30 -07003472 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003473 }
Jeff Johnson295189b2012-06-20 16:38:30 -07003474 case eCSR_ROAM_RESULT_IBSS_PEER_DEPARTED:
3475 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003476 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Jeff Johnson295189b2012-06-20 16:38:30 -07003477
Ravi Joshicc57ed42013-10-12 16:31:25 -07003478 if ( !roamRemoveIbssStation(pAdapter, pRoamInfo->staId ) )
Jeff Johnson295189b2012-06-20 16:38:30 -07003479 {
3480 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3481 "IBSS peer departed by cannot find peer in our registration table with TL" );
3482 }
3483
Deepthi Gowric7591cc2015-12-28 15:43:17 +05303484 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3485 "IBSS Peer Departed from SME with peerMac " MAC_ADDRESS_STR " BSSID: " MAC_ADDRESS_STR " and stationID= %d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003486 MAC_ADDR_ARRAY(pRoamInfo->peerMac),
3487 MAC_ADDR_ARRAY(pHddStaCtx->conn_info.bssId),
3488 pRoamInfo->staId );
3489
Katya Nigam47528772015-02-11 12:24:49 +05303490 hdd_ibss_DeregisterSTA( pAdapter, pRoamInfo->staId );
Jeff Johnson295189b2012-06-20 16:38:30 -07003491
3492 pHddCtx->sta_to_adapter[pRoamInfo->staId] = NULL;
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003493 pHddStaCtx->ibss_sta_generation++;
Ravi Joshicc57ed42013-10-12 16:31:25 -07003494
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07003495 cfg80211_del_sta(pAdapter->dev,
3496 (const u8 *)&pRoamInfo->peerMac,
3497 GFP_KERNEL);
Jeff Johnson295189b2012-06-20 16:38:30 -07003498 break;
3499 }
3500 case eCSR_ROAM_RESULT_IBSS_INACTIVE:
3501 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003502 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
3503 "Received eCSR_ROAM_RESULT_IBSS_INACTIVE from SME");
Jeff Johnson295189b2012-06-20 16:38:30 -07003504 // Stop only when we are inactive
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05303505 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07003506 netif_tx_disable(pAdapter->dev);
3507 netif_carrier_off(pAdapter->dev);
Abhishek Singhf4669da2014-05-26 15:07:49 +05303508 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3509 "%s: Set HDD connState to eConnectionState_NotConnected",
3510 __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07003511 hdd_connSetConnectionState( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter), eConnectionState_NotConnected );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003512
Jeff Johnson295189b2012-06-20 16:38:30 -07003513 // Send the bssid address to the wext.
3514 hdd_SendAssociationEvent(pAdapter->dev, pRoamInfo);
3515 // clean up data path
3516 hdd_disconnect_tx_rx(pAdapter);
3517 break;
3518 }
3519 default:
3520 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003521
Jeff Johnson295189b2012-06-20 16:38:30 -07003522 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07003523
Jeff Johnson295189b2012-06-20 16:38:30 -07003524 return( eHAL_STATUS_SUCCESS );
3525}
3526
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003527#ifdef FEATURE_WLAN_TDLS
3528/**============================================================================
3529 *
3530 @brief hdd_roamRegisterTDLSSTA() - Construct the staDesc and register with
3531 TL the new STA. This is called as part of ADD_STA in the TDLS setup
3532 Return: VOS_STATUS
Shailender Karmuchia734f332013-04-19 14:02:48 -07003533
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003534 ===========================================================================*/
Anand N Sunkad9bfc2622015-07-30 15:18:54 +05303535VOS_STATUS hdd_roamRegisterTDLSSTA(hdd_adapter_t *pAdapter,
3536#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3,18,0))
3537 const tANI_U8 *peerMac,
3538#else
3539 tANI_U8 *peerMac,
3540#endif
3541 tANI_U16 staId, tANI_U8 ucastSig)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003542{
3543 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07003544 v_CONTEXT_t pVosContext = (WLAN_HDD_GET_CTX(pAdapter))->pvosContext;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003545 VOS_STATUS vosStatus = VOS_STATUS_E_FAILURE;
3546 WLAN_STADescType staDesc = {0};
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003547 eCsrEncryptionType connectedCipherAlgo = eCSR_ENCRYPT_TYPE_UNKNOWN;
3548 v_BOOL_t fConnected = FALSE;
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003549 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3550 hdd_config_t *cfg_param = pHddCtx->cfg_ini;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003551
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003552 fConnected = hdd_connGetConnectedCipherAlgo( pHddStaCtx, &connectedCipherAlgo );
3553 if (!fConnected) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003554 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003555 "%s not connected. ignored", __func__);
3556 return VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003557 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003558
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003559 /*
3560 * TDLS sta in BSS should be set as STA type TDLS and STA MAC should
3561 * be peer MAC, here we are wokrking on direct Link
3562 */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003563 staDesc.ucSTAId = staId ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003564
3565 staDesc.wSTAType = WLAN_STA_TDLS ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003566
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003567 vos_mem_copy( staDesc.vSTAMACAddress.bytes, peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003568 sizeof(tSirMacAddr) );
3569
3570 vos_mem_copy(staDesc.vBSSIDforIBSS.bytes, pHddStaCtx->conn_info.bssId,6 );
3571 vos_copy_macaddr( &staDesc.vSelfMACAddress, &pAdapter->macAddressCurrent );
3572
3573 /* set the QoS field appropriately ..*/
3574 (hdd_wmm_is_active(pAdapter)) ? (staDesc.ucQosEnabled = 1)
3575 : (staDesc.ucQosEnabled = 0) ;
3576
3577 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH, "HDD register \
Arif Hussain6d2a3322013-11-17 19:50:10 -08003578 TL QoS_enabled=%d", staDesc.ucQosEnabled );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003579
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003580 staDesc.ucProtectedFrame = (connectedCipherAlgo != eCSR_ENCRYPT_TYPE_NONE) ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003581
3582 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_MED,
Arif Hussain6d2a3322013-11-17 19:50:10 -08003583 "HDD register TL Sec_enabled= %d.", staDesc.ucProtectedFrame );
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003584
Shailender Karmuchia734f332013-04-19 14:02:48 -07003585 /*
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003586 * UMA is ready we inform TL to do frame translation.
3587 */
3588 staDesc.ucSwFrameTXXlation = 1;
3589 staDesc.ucSwFrameRXXlation = 1;
3590 staDesc.ucAddRmvLLC = 1;
3591
3592 /* Initialize signatures and state */
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003593 staDesc.ucUcastSig = ucastSig ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003594
3595 /* tdls Direct Link do not need bcastSig */
3596 staDesc.ucBcastSig = 0 ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003597
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003598 if(staDesc.ucProtectedFrame)
3599 staDesc.ucIsReplayCheckValid = VOS_TRUE;
3600 else
3601 staDesc.ucIsReplayCheckValid = VOS_FALSE;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003602
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303603 staDesc.ucInitState = WLANTL_STA_CONNECTED ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003604
Shailender Karmuchia734f332013-04-19 14:02:48 -07003605 /* Register the Station with TL... */
3606 vosStatus = WLANTL_RegisterSTAClient( pVosContext,
3607 hdd_rx_packet_cbk,
3608 hdd_tx_complete_cbk,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003609 hdd_tx_fetch_packet_cbk, &staDesc, 0 );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003610
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003611 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3612 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07003613 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003614 "%s: WLANTL_RegisterSTAClient() failed to register. "
3615 "Status= %d [0x%08X]", __func__, vosStatus, vosStatus );
Shailender Karmuchia734f332013-04-19 14:02:48 -07003616 return vosStatus;
3617 }
3618
Sudhir Sattayappa Kohalli37620692013-08-05 14:02:26 -07003619 if ( cfg_param->dynSplitscan &&
3620 ( VOS_TIMER_STATE_RUNNING !=
3621 vos_timer_getCurrentState(&pHddCtx->tx_rx_trafficTmr)) )
3622 {
3623 vos_timer_start(&pHddCtx->tx_rx_trafficTmr,
3624 cfg_param->trafficMntrTmrForSplitScan);
3625 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003626 return( vosStatus );
3627}
3628
Masti, Narayanraddi1fb32a92015-06-29 13:14:06 +05303629VOS_STATUS hdd_roamDeregisterTDLSSTA( hdd_adapter_t *pAdapter, tANI_U8 staId )
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08003630{
3631 VOS_STATUS vosStatus;
3632 vosStatus = WLANTL_ClearSTAClient( (WLAN_HDD_GET_CTX(pAdapter))->pvosContext, staId );
3633 if ( !VOS_IS_STATUS_SUCCESS( vosStatus ) )
3634 {
3635 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
3636 "%s: WLANTL_ClearSTAClient() failed to for staID %d. "
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003637 "Status= %d [0x%08X]",
Chauhan Rajeshb48f96d2013-01-24 21:00:15 -08003638 __func__, staId, vosStatus, vosStatus );
3639 }
3640 return( vosStatus );
3641}
3642
3643
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003644/*
3645 * HDD interface between SME and TL to ensure TDLS client registration with
3646 * TL in case of new TDLS client is added and deregistration at the time
3647 * TDLS client is deleted.
3648 */
3649
Shailender Karmuchia734f332013-04-19 14:02:48 -07003650eHalStatus hdd_RoamTdlsStatusUpdateHandler(hdd_adapter_t *pAdapter,
3651 tCsrRoamInfo *pRoamInfo,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003652 tANI_U32 roamId,
Shailender Karmuchia734f332013-04-19 14:02:48 -07003653 eRoamCmdStatus roamStatus,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003654 eCsrRoamResult roamResult)
3655{
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003656 hdd_context_t *pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003657 eHalStatus status = eHAL_STATUS_FAILURE ;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003658 tANI_U8 staIdx;
Hoonki Lee1090c6a2013-01-16 17:40:54 -08003659
Kaushik, Sushant8489f472014-01-27 11:41:22 +05303660 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Arif Hussain24bafea2013-11-15 15:10:03 -08003661 ("hdd_tdlsStatusUpdate: %s staIdx %d " MAC_ADDRESS_STR),
3662 roamResult == eCSR_ROAM_RESULT_ADD_TDLS_PEER ?
3663 "ADD_TDLS_PEER" :
3664 roamResult == eCSR_ROAM_RESULT_DELETE_TDLS_PEER ?
3665 "DEL_TDLS_PEER" :
3666 roamResult == eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND ?
3667 "DEL_TDLS_PEER_IND" :
3668 roamResult == eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND ?
3669 "DEL_ALL_TDLS_PEER_IND" :
3670 roamResult == eCSR_ROAM_RESULT_UPDATE_TDLS_PEER ?
3671 "UPDATE_TDLS_PEER" :
3672 roamResult == eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP ?
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303673 "LINK_ESTABLISH_REQ_RSP" :
3674 roamResult == eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP ?
3675 "CHANNEL_SWITCH_REQ_RSP" : "UNKNOWN",
Arif Hussain24bafea2013-11-15 15:10:03 -08003676 pRoamInfo->staId, MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003677 switch( roamResult )
3678 {
3679 case eCSR_ROAM_RESULT_ADD_TDLS_PEER:
3680 {
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003681 if(eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3682 {
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05303683 hddTdlsPeer_t *curr_peer;
3684
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003685 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003686 ("%s: Add Sta is failed. %d"),__func__, pRoamInfo->statusCode);
Ganesh Kondabattinif065c1f2015-08-05 23:05:23 +05303687 wlan_hdd_tdls_check_bmps(pAdapter);
Masti, Narayanraddi83dbfc22016-01-07 16:26:06 +05303688
3689 mutex_lock(&pHddCtx->tdls_lock);
3690 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3691 pRoamInfo->peerMac, FALSE);
3692 if (NULL != curr_peer)
3693 curr_peer->link_status = eTDLS_LINK_TEARING;
3694 else
3695 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3696 "%s %d curr_peer is Null", __func__,__LINE__);
3697 mutex_unlock(&pHddCtx->tdls_lock);
Lee Hoonkif987a0b2013-01-29 02:07:07 -08003698 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003699 else
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003700 {
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003701
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003702 /* check if there is available index for this new TDLS STA */
3703 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
3704 {
3705 if (0 == pHddCtx->tdlsConnInfo[staIdx].staId )
3706 {
3707 pHddCtx->tdlsConnInfo[staIdx].sessionId = pRoamInfo->sessionId;
3708 pHddCtx->tdlsConnInfo[staIdx].staId = pRoamInfo->staId;
3709
3710 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003711 ("TDLS: STA IDX at %d is %d "
3712 "of mac " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003713 staIdx, pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003714 MAC_ADDR_ARRAY(pRoamInfo->peerMac));
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003715
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003716 vos_copy_macaddr(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003717 (v_MACADDR_t *)pRoamInfo->peerMac) ;
3718 status = eHAL_STATUS_SUCCESS ;
3719 break ;
3720 }
3721 }
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003722 if (staIdx < HDD_MAX_NUM_TDLS_STA)
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003723 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003724 if (-1 == wlan_hdd_tdls_set_sta_id(pAdapter, pRoamInfo->peerMac, pRoamInfo->staId)) {
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003725 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3726 "wlan_hdd_tdls_set_sta_id() failed");
3727 return VOS_FALSE;
3728 }
3729
3730 (WLAN_HDD_GET_CTX(pAdapter))->sta_to_adapter[pRoamInfo->staId] = pAdapter;
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303731 /* store the ucast signature , if required for further reference. */
3732
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003733 wlan_hdd_tdls_set_signature( pAdapter, pRoamInfo->peerMac, pRoamInfo->ucastSig );
Gopichand Nakkala471708b2013-06-04 20:03:01 +05303734 /* start TDLS client registration with TL */
3735 status = hdd_roamRegisterTDLSSTA( pAdapter,
3736 pRoamInfo->peerMac,
3737 pRoamInfo->staId,
3738 pRoamInfo->ucastSig);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303739 wlan_hdd_tdls_increment_peer_count(pAdapter);
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003740 }
3741 else
3742 {
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003743 status = eHAL_STATUS_FAILURE;
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003744 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Hoonki Lee66b75f32013-04-16 18:30:07 -07003745 "%s: no available slot in conn_info. staId %d cannot be stored", __func__, pRoamInfo->staId);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003746 }
Gopichand Nakkalab977a972013-02-18 19:15:09 -08003747 pAdapter->tdlsAddStaStatus = status;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003748 }
Hoonki Lee11f7dda2013-02-14 16:55:44 -08003749 complete(&pAdapter->tdls_add_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003750 break ;
3751 }
Gopichand Nakkala681989c2013-03-06 22:27:48 -08003752 case eCSR_ROAM_RESULT_UPDATE_TDLS_PEER:
3753 {
3754 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3755 {
3756 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3757 "%s: Add Sta is failed. %d", __func__, pRoamInfo->statusCode);
3758 }
3759 /* store the ucast signature which will be used later when
3760 * registering to TL
3761 */
3762 pAdapter->tdlsAddStaStatus = pRoamInfo->statusCode;
3763 complete(&pAdapter->tdls_add_station_comp);
3764 break;
3765 }
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303766 case eCSR_ROAM_RESULT_LINK_ESTABLISH_REQ_RSP:
3767 {
3768 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3769 {
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303770 hddTdlsPeer_t *curr_peer;
3771
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303772 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3773 "%s: Link Establish Request failed. %d", __func__, pRoamInfo->statusCode);
Masti, Narayanraddif10fd792015-12-15 15:01:01 +05303774
3775 mutex_lock(&pHddCtx->tdls_lock);
3776 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3777 pRoamInfo->peerMac, FALSE);
3778 if (curr_peer)
3779 curr_peer->link_status = eTDLS_LINK_TEARING;
3780 else
3781 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3782 "%s %d curr_peer is Null",__func__,__LINE__);
3783 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala79ff85d2013-05-27 17:05:29 +05303784 }
3785 complete(&pAdapter->tdls_link_establish_req_comp);
3786 break;
3787 }
Masti, Narayanraddi36c67622016-01-06 16:07:34 +05303788 case eCSR_ROAM_RESULT_CHANNEL_SWITCH_REQ_RSP:
3789 {
3790 if (eSIR_SME_SUCCESS != pRoamInfo->statusCode)
3791 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3792 "%s: Channel switch request failed. %d", __func__,
3793 pRoamInfo->statusCode);
3794 else
3795 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3796 "%s: Channel switch request Success", __func__);
3797 break;
3798 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003799 case eCSR_ROAM_RESULT_DELETE_TDLS_PEER:
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003800 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003801 hddTdlsPeer_t *curr_peer;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003802 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003803 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003804 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3805 pRoamInfo->staId == pHddCtx->tdlsConnInfo[staIdx].staId)
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003806 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003807 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003808 ("HDD: del STA IDX = %x"), pRoamInfo->staId) ;
3809
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303810 mutex_lock(&pHddCtx->tdls_lock);
3811 curr_peer = wlan_hdd_tdls_find_peer(pAdapter,
3812 pRoamInfo->peerMac, FALSE);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303813 if (NULL != curr_peer)
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003814 {
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303815 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
3816 " Current status for peer" MAC_ADDRESS_STR "is %d",
3817 MAC_ADDR_ARRAY(pRoamInfo->peerMac), curr_peer->link_status);
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303818 if (TDLS_IS_CONNECTED(curr_peer) ||
3819 (eTDLS_LINK_CONNECTING == curr_peer->link_status))
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303820 {
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303821 mutex_unlock(&pHddCtx->tdls_lock);
Agarwal Ashish9cd86382014-12-18 18:24:36 +05303822 hdd_roamDeregisterTDLSSTA ( pAdapter, pRoamInfo->staId );
3823 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303824 else
3825 mutex_unlock(&pHddCtx->tdls_lock);
3826
Pradeep Reddy POTTETIa9991b62015-03-26 18:03:19 +05303827 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003828 }
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303829 else
3830 mutex_unlock(&pHddCtx->tdls_lock);
3831
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303832 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003833 wlan_hdd_tdls_reset_peer(pAdapter, pRoamInfo->peerMac);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303834 mutex_unlock(&pHddCtx->tdls_lock);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003835
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003836 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3837 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
3838 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003839 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003840 wlan_hdd_tdls_check_bmps(pAdapter);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003841 status = eHAL_STATUS_SUCCESS ;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003842 break ;
3843 }
3844 }
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003845 complete(&pAdapter->tdls_del_station_comp);
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003846 }
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003847 break ;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003848 case eCSR_ROAM_RESULT_TEARDOWN_TDLS_PEER_IND:
3849 {
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003850 hddTdlsPeer_t *curr_peer;
Hoonki Leee6bfe942013-02-05 15:01:19 -08003851 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
3852 "%s: Sending teardown to supplicant with reason code %u",
3853 __func__, pRoamInfo->reasonCode);
3854
3855#ifdef CONFIG_TDLS_IMPLICIT
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303856 mutex_lock(&pHddCtx->tdls_lock);
3857 curr_peer = wlan_hdd_tdls_find_peer(pAdapter, pRoamInfo->peerMac,
3858 FALSE);
Gopichand Nakkalae7cbc5d2013-03-27 21:09:23 -07003859 wlan_hdd_tdls_indicate_teardown(pAdapter, curr_peer, pRoamInfo->reasonCode);
Abhishek Singh96568922016-01-05 15:28:12 +05303860 hdd_send_wlan_tdls_teardown_event(eTDLS_TEARDOWN_BSS_DISCONNECT,
3861 curr_peer->peerMac);
Masti, Narayanraddi6b93b472015-09-04 17:48:11 +05303862 mutex_unlock(&pHddCtx->tdls_lock);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003863#endif
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003864 status = eHAL_STATUS_SUCCESS ;
3865 break ;
3866 }
3867 case eCSR_ROAM_RESULT_DELETE_ALL_TDLS_PEER_IND:
3868 {
3869 /* 0 staIdx is assigned to AP we dont want to touch that */
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003870 for ( staIdx = 0; staIdx < HDD_MAX_NUM_TDLS_STA; staIdx++ )
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003871 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003872 if ((pHddCtx->tdlsConnInfo[staIdx].sessionId == pRoamInfo->sessionId) &&
3873 pHddCtx->tdlsConnInfo[staIdx].staId)
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003874 {
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003875 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
Arif Hussain24bafea2013-11-15 15:10:03 -08003876 ("hdd_tdlsStatusUpdate: staIdx %d " MAC_ADDRESS_STR),
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003877 pHddCtx->tdlsConnInfo[staIdx].staId,
Arif Hussain24bafea2013-11-15 15:10:03 -08003878 MAC_ADDR_ARRAY(pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes));
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303879
3880 mutex_lock(&pHddCtx->tdls_lock);
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003881 wlan_hdd_tdls_reset_peer(pAdapter, pHddCtx->tdlsConnInfo[staIdx].peerMac.bytes);
Masti, Narayanraddi9e4f4082015-10-17 16:05:15 +05303882 mutex_unlock(&pHddCtx->tdls_lock);
3883
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003884 hdd_roamDeregisterTDLSSTA ( pAdapter, pHddCtx->tdlsConnInfo[staIdx].staId );
3885 wlan_hdd_tdls_decrement_peer_count(pAdapter);
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003886
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003887 vos_mem_zero(&pHddCtx->tdlsConnInfo[staIdx].peerMac,
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003888 sizeof(v_MACADDR_t)) ;
Gopichand Nakkala4327a152013-03-04 23:22:42 -08003889 pHddCtx->tdlsConnInfo[staIdx].staId = 0 ;
3890 pHddCtx->tdlsConnInfo[staIdx].sessionId = 255;
Gopichand Nakkala2a0a1572013-02-10 21:39:16 -08003891
3892 status = eHAL_STATUS_SUCCESS ;
3893 }
3894 }
Gopichand Nakkala40ab2752013-04-04 20:11:36 +05303895 wlan_hdd_tdls_check_bmps(pAdapter);
Hoonki Leee6bfe942013-02-05 15:01:19 -08003896 break ;
3897 }
Mohit Khanna698ba2a2012-12-04 15:08:18 -08003898 default:
3899 {
3900 break ;
3901 }
3902 }
3903
3904 return status ;
3905}
3906#endif
3907
Arun Khandavalli7eeb1592015-10-19 21:36:57 +05303908void iw_full_power_cbfn (void *pContext, eHalStatus status)
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003909{
3910 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
3911 hdd_context_t *pHddCtx = NULL;
3912 int ret;
3913
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303914 ENTER();
3915
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003916 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
3917 {
3918 hddLog(VOS_TRACE_LEVEL_ERROR,
Jeff Johnsonc135a9a2017-09-19 08:37:24 -07003919 "%s: Bad param, pAdapter [%pK]",
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003920 __func__, pAdapter);
3921 return;
3922 }
3923
3924 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
3925 ret = wlan_hdd_validate_context(pHddCtx);
3926 if (0 != ret)
3927 {
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003928 return;
3929 }
3930
3931 if (pHddCtx->cfg_ini->fIsBmpsEnabled)
3932 {
3933 sme_RequestBmps(WLAN_HDD_GET_HAL_CTX(pAdapter), NULL, NULL);
3934 }
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05303935
3936 EXIT();
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08003937}
3938
Shailender Karmuchia734f332013-04-19 14:02:48 -07003939eHalStatus hdd_smeRoamCallback( void *pContext, tCsrRoamInfo *pRoamInfo, tANI_U32 roamId,
Jeff Johnson295189b2012-06-20 16:38:30 -07003940 eRoamCmdStatus roamStatus, eCsrRoamResult roamResult )
3941{
3942 eHalStatus halStatus = eHAL_STATUS_SUCCESS;
3943 hdd_adapter_t *pAdapter = (hdd_adapter_t *)pContext;
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303944 hdd_wext_state_t *pWextState = NULL;
3945 hdd_station_ctx_t *pHddStaCtx = NULL;
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07003946 VOS_STATUS status = VOS_STATUS_SUCCESS;
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05303947 struct cfg80211_bss *bss_status;
Amar Singhal49fdfd52013-08-13 13:25:12 -07003948 hdd_context_t *pHddCtx = NULL;
Jeff Johnson295189b2012-06-20 16:38:30 -07003949
3950 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO_HIGH,
Jeff Johnson0299d0a2013-10-30 12:37:43 -07003951 "CSR Callback: status= %d result= %d roamID=%d",
Shailender Karmuchia734f332013-04-19 14:02:48 -07003952 roamStatus, roamResult, roamId );
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003953
3954 /*Sanity check*/
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303955 if ((NULL == pAdapter) || (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003956 {
3957 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
Pratik Bhalgatec625f72012-11-22 17:17:38 +05303958 "invalid adapter or adapter has invalid magic");
3959 return eHAL_STATUS_FAILURE;
3960 }
3961
3962 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
3963 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
3964
3965 if ((NULL == pWextState) || (NULL == pHddStaCtx))
3966 {
3967 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_FATAL,
3968 "invalid WEXT state or HDD station context");
Jeff Johnson04dd8a82012-06-29 20:41:40 -07003969 return eHAL_STATUS_FAILURE;
3970 }
3971
Konamki, Sreelakshmib9c45712015-07-29 11:48:19 +05303972 MTRACE(vos_trace(VOS_MODULE_ID_HDD, TRACE_CODE_HDD_RX_SME_MSG,
3973 pAdapter->sessionId, roamStatus));
Jeff Johnson295189b2012-06-20 16:38:30 -07003974 switch( roamStatus )
3975 {
3976 case eCSR_ROAM_SESSION_OPENED:
Sreelakshmi Konamki41d95e22015-08-28 12:51:32 +05303977 set_bit(SME_SESSION_OPENED, &pAdapter->event_flags);
3978 complete(&pAdapter->session_open_comp_var);
Jeff Johnson295189b2012-06-20 16:38:30 -07003979 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07003980
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08003981#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
3982 /* We did pre-auth,then we attempted a 11r or ese reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07003983 * reassoc failed due to failure, timeout, reject from ap
Shailender Karmuchia734f332013-04-19 14:02:48 -07003984 * in any case tell the OS, our carrier is off and mark
Jeff Johnson295189b2012-06-20 16:38:30 -07003985 * interface down */
3986 case eCSR_ROAM_FT_REASSOC_FAILED:
Agarwal Ashish971c2882013-10-30 20:11:12 +05303987 hddLog(LOGE, FL("Reassoc Failed with roamStatus: %d roamResult: %d SessionID: %d"),
3988 roamStatus, roamResult, pAdapter->sessionId);
c_hpothuef45bc32014-09-11 10:10:18 +05303989 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07003990 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
3991 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
3992 if ((WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set == TRUE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07003993 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
3994 }
3995 pHddStaCtx->ft_carrier_on = FALSE;
Kanchanapally, Vidyullathad883c652014-05-09 21:17:04 +05303996 pHddStaCtx->hdd_ReassocScenario = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07003997 break;
3998
3999 case eCSR_ROAM_FT_START:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004000 // When we roam for EsE and 11r, we dont want the
Jeff Johnson295189b2012-06-20 16:38:30 -07004001 // OS to be informed that the link is down. So mark
Shailender Karmuchia734f332013-04-19 14:02:48 -07004002 // the link ready for ft_start. After this the
Jeff Johnson295189b2012-06-20 16:38:30 -07004003 // eCSR_ROAM_SHOULD_ROAM will be received.
4004 // Where in we will not mark the link down
4005 // Also we want to stop tx at this point when we will be
4006 // doing disassoc at this time. This saves 30-60 msec
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004007 // after reassoc.
Jeff Johnson295189b2012-06-20 16:38:30 -07004008 {
4009 struct net_device *dev = pAdapter->dev;
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05304010 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004011 netif_tx_disable(dev);
Girish Gowlibf0e1ab2015-01-19 16:05:16 +05304012 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4013 if (pHddCtx->cfg_ini->gEnableRoamDelayStats)
4014 {
4015 vos_record_roam_event(e_HDD_DISABLE_TX_QUEUE, NULL, 0);
4016 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004017 /*
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304018 * Deregister this STA with TL, but do not flush the packets
4019 * for this STA from wmm_tx_queue. Since there is no valid STA
4020 * for these packets they will not be transmitted. Eventually
4021 * after the reassociation is successful, these packets will be
4022 * transmitted after registering STA with TL again. This ensures
4023 * that driver does not drop packets during roaming.
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07004024 */
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304025 status = WLANTL_ClearSTAClient(pHddCtx->pvosContext,
4026 pHddStaCtx->conn_info.staId[0]);
4027 if (!VOS_IS_STATUS_SUCCESS(status))
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004028 {
Kanchanapally, Vidyullathaed969c62015-02-18 11:39:11 +05304029 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4030 FL("WLANTL_ClearSTAClient failed for staID %d."
4031 "Status= %d [0x%x]"), pHddStaCtx->conn_info.staId[0],
4032 status, status);
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004033 halStatus = eHAL_STATUS_FAILURE;
Madan Mohan Koyyalamudi1bed5982012-10-22 14:38:06 -07004034 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004035 }
4036 pHddStaCtx->ft_carrier_on = TRUE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004037 pHddStaCtx->hdd_ReassocScenario = VOS_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004038 break;
4039#endif
4040
4041 case eCSR_ROAM_SHOULD_ROAM:
4042 // Dont need to do anything
4043 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004044 struct net_device *dev = pAdapter->dev;
4045 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4046 // notify apps that we can't pass traffic anymore
Padma, Santhosh Kumar9dacb5c2014-12-17 19:22:56 +05304047 hddLog(VOS_TRACE_LEVEL_INFO, FL("Disabling queues"));
Jeff Johnson295189b2012-06-20 16:38:30 -07004048 netif_tx_disable(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004049#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004050 if (pHddStaCtx->ft_carrier_on == FALSE)
4051 {
4052#endif
4053 netif_carrier_off(dev);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004054#if defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR)
Jeff Johnson295189b2012-06-20 16:38:30 -07004055 }
4056#endif
4057
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004058#if !(defined (WLAN_FEATURE_VOWIFI_11R) || defined (FEATURE_WLAN_ESE) || defined(FEATURE_WLAN_LFR))
Jeff Johnson295189b2012-06-20 16:38:30 -07004059 //We should clear all sta register with TL, for now, only one.
4060 status = hdd_roamDeregisterSTA( pAdapter, pHddStaCtx->conn_info.staId [0] );
4061 if ( !VOS_IS_STATUS_SUCCESS(status ) )
4062 {
4063 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4064 FL("hdd_roamDeregisterSTA() failed to for staID %d. Status= %d [0x%x]"),
4065 pHddStaCtx->conn_info.staId[0], status, status );
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004066 halStatus = eHAL_STATUS_FAILURE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004067 }
Madan Mohan Koyyalamudi2d8cc892012-09-18 16:24:34 -07004068#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004069 }
4070 break;
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05304071 case eCSR_ROAM_LOSTLINK_DETECTED:
4072 {
4073 if (wlan_hdd_check_and_stop_mon(pAdapter, false))
4074 halStatus = eHAL_STATUS_FAILURE;
4075 }
4076 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004077 case eCSR_ROAM_LOSTLINK:
4078 case eCSR_ROAM_DISASSOCIATED:
4079 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004080 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4081 "****eCSR_ROAM_DISASSOCIATED****");
c_hpothuef45bc32014-09-11 10:10:18 +05304082 sme_resetCoexEevent(WLAN_HDD_GET_HAL_CTX(pAdapter));
Jeff Johnson295189b2012-06-20 16:38:30 -07004083 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4084 /* Check if Mcast/Bcast Filters are set, if yes clear the filters here */
Amar Singhal49fdfd52013-08-13 13:25:12 -07004085 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4086 if (pHddCtx->hdd_mcastbcast_filter_set == TRUE)
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304087 {
Amar Singhal49fdfd52013-08-13 13:25:12 -07004088 hdd_conf_mcastbcast_filter(pHddCtx, FALSE);
Amar Singhalf8ba2b82013-12-02 12:54:38 -08004089
4090 if (VOS_TRUE == pHddCtx->sus_res_mcastbcast_filter_valid) {
4091 pHddCtx->configuredMcastBcastFilter =
4092 pHddCtx->sus_res_mcastbcast_filter;
4093 pHddCtx->sus_res_mcastbcast_filter_valid = VOS_FALSE;
4094 }
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304095
Amar Singhald53568e2013-09-26 11:03:45 -07004096 hddLog(VOS_TRACE_LEVEL_INFO,
4097 "offload: disassociation happening, restoring configuredMcastBcastFilter");
4098 hddLog(VOS_TRACE_LEVEL_INFO,"McastBcastFilter = %d",
4099 pHddCtx->configuredMcastBcastFilter);
4100 hddLog(VOS_TRACE_LEVEL_INFO,
4101 "offload: already called mcastbcast filter");
Jeff Johnson295189b2012-06-20 16:38:30 -07004102 (WLAN_HDD_GET_CTX(pAdapter))->hdd_mcastbcast_filter_set = FALSE;
4103 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004104#ifdef WLAN_FEATURE_PACKET_FILTERING
madan mohan koyyalamudibfd9cef2013-07-01 18:39:37 +05304105 /* Call to clear any MC Addr List filter applied after
4106 * successful connection.
4107 */
4108 wlan_hdd_set_mc_addr_list(pAdapter, FALSE);
Jeff Johnson295189b2012-06-20 16:38:30 -07004109#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004110 }
4111 break;
4112 case eCSR_ROAM_IBSS_LEAVE:
4113 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4114 "****eCSR_ROAM_IBSS_LEAVE****");
4115 halStatus = hdd_DisConnectHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4116 break;
4117 case eCSR_ROAM_ASSOCIATION_COMPLETION:
4118 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4119 "****eCSR_ROAM_ASSOCIATION_COMPLETION****");
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304120 // To Do - address probable memory leak with WEP encryption upon successful association
4121 if (eCSR_ROAM_RESULT_ASSOCIATED != roamResult)
Jeff Johnson295189b2012-06-20 16:38:30 -07004122 {
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304123 //Clear saved connection information in HDD
4124 hdd_connRemoveConnectInfo( WLAN_HDD_GET_STATION_CTX_PTR(pAdapter) );
Jeff Johnson295189b2012-06-20 16:38:30 -07004125 }
Abhishek Singh57a0bd92014-06-13 11:17:27 +05304126 halStatus = hdd_AssociationCompletionHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07004127
4128 break;
4129 case eCSR_ROAM_ASSOCIATION_FAILURE:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004130 halStatus = hdd_AssociationCompletionHandler( pAdapter,
Jeff Johnson295189b2012-06-20 16:38:30 -07004131 pRoamInfo, roamId, roamStatus, roamResult );
4132 break;
4133 case eCSR_ROAM_IBSS_IND:
Jeff Johnson81c17882013-05-03 09:53:35 -07004134 hdd_RoamIbssIndicationHandler( pAdapter, pRoamInfo, roamId,
4135 roamStatus, roamResult );
Jeff Johnson295189b2012-06-20 16:38:30 -07004136 break;
4137
4138 case eCSR_ROAM_CONNECT_STATUS_UPDATE:
4139 halStatus = roamRoamConnectStatusUpdateHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Shailender Karmuchia734f332013-04-19 14:02:48 -07004140 break;
Jeff Johnson295189b2012-06-20 16:38:30 -07004141
4142 case eCSR_ROAM_MIC_ERROR_IND:
4143 halStatus = hdd_RoamMicErrorIndicationHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
4144 break;
Sachin Ahuja3d47fcd2015-08-28 16:02:06 +05304145 case eCSR_ROAM_LOST_LINK_PARAMS_IND:
4146 {
4147 /*
4148 * The RSSI will be subtracted from 100 as FW is sending the RSSI by
4149 * adding the 100 value.
4150 */
4151 pAdapter->rssi_on_disconnect = pRoamInfo->u.pLostLinkParams->rssi - 100;
4152 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
4153 "%s : Rssi on Disconnect : %d",
4154 __func__, pAdapter->rssi_on_disconnect);
4155 break;
4156 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004157 case eCSR_ROAM_SET_KEY_COMPLETE:
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004158 {
4159 hdd_context_t* pHddCtx = (hdd_context_t*)pAdapter->pHddCtx;
4160
4161 if((pHddCtx) &&
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004162 (TRUE == pHddCtx->hdd_wlan_suspended) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304163 ((eCSR_ROAM_RESULT_NONE == roamResult)||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304164 (pRoamInfo && pRoamInfo->is11rAssoc)))
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004165 {
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07004166 /* Send DTIM period to the FW; only if the wlan is already
4167 in suspend. This is the case with roaming (reassoc),
4168 DELETE_BSS_REQ zeroes out Modulated/Dynamic DTIM sent in
4169 previous suspend_wlan. Sending SET_POWER_PARAMS_REQ
4170 before the ENTER_BMPS_REQ ensures Listen Interval is
4171 regained back to LI * Modulated DTIM */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004172 hdd_set_pwrparams(pHddCtx);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004173
4174 /* At this point, device should not be in BMPS;
Srinivas Girigowdaeb03ee32013-07-16 11:48:41 -07004175 if due to unexpected scenario, if we are in BMPS,
4176 then trigger Exit and Enter BMPS to take DTIM period
4177 effective */
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004178 if (BMPS == pmcGetPmcState(pHddCtx->hHal))
4179 {
4180 hddLog( LOGE, FL("Not expected: device is already in BMPS mode, Exit & Enter BMPS again!"));
4181
Srinivas Girigowda1c3f72e2013-12-18 16:07:00 -08004182 sme_RequestFullPower(WLAN_HDD_GET_HAL_CTX(pAdapter),
4183 iw_full_power_cbfn, pAdapter,
4184 eSME_FULL_PWR_NEEDED_BY_HDD);
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004185 }
4186 }
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05304187
4188 if ((pHddCtx) &&
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05304189 (FULL_POWER == pmcGetPmcState(pHddCtx->hHal)) &&
4190 (VOS_TRUE == pHddStaCtx->hdd_ReassocScenario) &&
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304191 ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304192 (pRoamInfo && pRoamInfo->is11rAssoc)))
Padma, Santhosh Kumara4c34572015-07-09 20:00:41 +05304193 {
4194 hddLog( LOG1, FL("Device in full power."
4195 "Stop and start traffic timer for roaming"));
4196 pmcStopTrafficTimer(pHddCtx->hHal);
4197 if (pmcStartTrafficTimer(pHddCtx->hHal,
4198 TRAFFIC_TIMER_ROAMING) != eHAL_STATUS_SUCCESS)
4199 {
4200 hddLog(LOGP, FL("Cannot start traffic timer"));
4201 }
4202 }
4203
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004204 halStatus = hdd_RoamSetKeyCompleteHandler( pAdapter, pRoamInfo, roamId, roamStatus, roamResult );
Padma, Santhosh Kumarc3eca802016-02-17 19:58:28 +05304205 if ((eCSR_ROAM_RESULT_NONE == roamResult) ||
Padma, Santhosh Kumarbb75a142016-02-25 18:36:46 +05304206 (pRoamInfo && pRoamInfo->is11rAssoc))
Padma, Santhosh Kumar0a623eb2015-07-27 11:55:29 +05304207 pHddStaCtx->hdd_ReassocScenario = FALSE;
Srinivas Girigowda66c05eb2013-07-14 13:06:01 -07004208 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004209 break;
4210#ifdef WLAN_FEATURE_VOWIFI_11R
4211 case eCSR_ROAM_FT_RESPONSE:
4212 hdd_SendFTEvent(pAdapter);
4213 break;
4214#endif
Madan Mohan Koyyalamudi1b4afb02012-10-22 15:25:16 -07004215#if defined(FEATURE_WLAN_LFR) && (LINUX_VERSION_CODE >= KERNEL_VERSION(3,4,0))
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004216 case eCSR_ROAM_PMK_NOTIFY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004217 if (eCSR_AUTH_TYPE_RSN == pHddStaCtx->conn_info.authType)
Jeff Johnson43971f52012-07-17 12:26:56 -07004218 {
4219 /* Notify the supplicant of a new candidate */
4220 halStatus = wlan_hdd_cfg80211_pmksa_candidate_notify(pAdapter, pRoamInfo, 1, false);
4221 }
Jeff Johnson04dd8a82012-06-29 20:41:40 -07004222 break;
4223#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004224
Yue Maef608272013-04-08 23:09:17 -07004225#ifdef FEATURE_WLAN_LFR_METRICS
4226 case eCSR_ROAM_PREAUTH_INIT_NOTIFY:
4227 /* This event is to notify pre-auth initiation */
4228 if (VOS_STATUS_SUCCESS !=
4229 wlan_hdd_cfg80211_roam_metrics_preauth(pAdapter, pRoamInfo))
4230 {
4231 halStatus = eHAL_STATUS_FAILURE;
4232 }
4233 break;
4234 case eCSR_ROAM_PREAUTH_STATUS_SUCCESS:
4235 /* This event will notify pre-auth completion in case of success */
4236 if (VOS_STATUS_SUCCESS !=
4237 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4238 pRoamInfo, 1))
4239 {
4240 halStatus = eHAL_STATUS_FAILURE;
4241 }
4242 break;
4243 case eCSR_ROAM_PREAUTH_STATUS_FAILURE:
4244 /* This event will notify pre-auth completion in case of failure. */
4245 if (VOS_STATUS_SUCCESS !=
4246 wlan_hdd_cfg80211_roam_metrics_preauth_status(pAdapter,
4247 pRoamInfo, 0))
4248 {
4249 halStatus = eHAL_STATUS_FAILURE;
4250 }
4251 break;
4252 case eCSR_ROAM_HANDOVER_SUCCESS:
4253 /* This event is to notify handover success.
4254 It will be only invoked on success */
4255 if (VOS_STATUS_SUCCESS !=
4256 wlan_hdd_cfg80211_roam_metrics_handover(pAdapter, pRoamInfo))
4257 {
4258 halStatus = eHAL_STATUS_FAILURE;
4259 }
4260 break;
4261#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004262 case eCSR_ROAM_REMAIN_CHAN_READY:
4263 hdd_remainChanReadyHandler( pAdapter );
4264 break;
4265 case eCSR_ROAM_SEND_ACTION_CNF:
4266 hdd_sendActionCnf( pAdapter,
4267 (roamResult == eCSR_ROAM_RESULT_NONE) ? TRUE : FALSE );
4268 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004269#ifdef FEATURE_WLAN_TDLS
Ng Chilamfc416462012-12-27 17:26:52 -08004270 case eCSR_ROAM_TDLS_STATUS_UPDATE:
Gopichand Nakkalab977a972013-02-18 19:15:09 -08004271 halStatus = hdd_RoamTdlsStatusUpdateHandler( pAdapter, pRoamInfo,
Ng Chilamfc416462012-12-27 17:26:52 -08004272 roamId, roamStatus, roamResult );
4273 break ;
Gopichand Nakkalab977a972013-02-18 19:15:09 -08004274 case eCSR_ROAM_RESULT_MGMT_TX_COMPLETE_IND:
4275 wlan_hdd_tdls_mgmt_completion_callback(pAdapter, pRoamInfo->reasonCode);
4276 break;
Mohit Khanna698ba2a2012-12-04 15:08:18 -08004277#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07004278#ifdef WLAN_FEATURE_11W
4279 case eCSR_ROAM_UNPROT_MGMT_FRAME_IND:
4280 hdd_indicateUnprotMgmtFrame(pAdapter, pRoamInfo->nFrameLength,
4281 pRoamInfo->pbFrames,
4282 pRoamInfo->frameType);
4283 break;
4284#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004285#if defined(FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004286 case eCSR_ROAM_TSM_IE_IND:
4287 hdd_indicateTsmIe(pAdapter, pRoamInfo->tsmIe.tsid,
4288 pRoamInfo->tsmIe.state, pRoamInfo->tsmIe.msmt_interval);
4289 break;
4290
4291 case eCSR_ROAM_CCKM_PREAUTH_NOTIFY:
4292 {
4293 if (eCSR_AUTH_TYPE_CCKM_WPA == pHddStaCtx->conn_info.authType ||
4294 eCSR_AUTH_TYPE_CCKM_RSN == pHddStaCtx->conn_info.authType)
4295 {
4296 hdd_indicateCckmPreAuth(pAdapter, pRoamInfo);
4297 }
4298 break;
4299 }
4300
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004301 case eCSR_ROAM_ESE_ADJ_AP_REPORT_IND:
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004302 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004303 hdd_indicateEseAdjApRepInd(pAdapter, pRoamInfo);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07004304 break;
4305 }
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004306
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004307 case eCSR_ROAM_ESE_BCN_REPORT_IND:
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004308 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004309 hdd_indicateEseBcnReportInd(pAdapter, pRoamInfo);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08004310 break;
4311 }
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004312#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Girish Gowlia95daca2015-02-04 20:31:31 +05304313 case eCSR_ROAM_UPDATE_MAX_RATE_IND:
4314 {
4315 pAdapter->maxRateFlags = roamResult;
4316 break;
4317 }
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304318 case eCSR_ROAM_UPDATE_SCAN_RESULT:
4319 if (pRoamInfo && pRoamInfo->pBssDesc) {
4320 bss_status = wlan_hdd_cfg80211_inform_bss_frame(pAdapter,
4321 pRoamInfo->pBssDesc);
4322 if (bss_status)
4323 cfg80211_put_bss(
4324#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)) || defined(WITH_BACKPORTS)
4325 (WLAN_HDD_GET_CTX(pAdapter))->wiphy,
4326#endif
4327 bss_status);
4328 else
4329 hddLog(LOG1, FL("UPDATE_SCAN_RESULT returned NULL"));
4330 }
Ganesh Kondabattini529397f2017-12-27 19:13:52 +05304331 case eCSR_ROAM_STA_CHANNEL_SWITCH:
4332 {
4333 hdd_adapter_t *pHostapdAdapter = NULL;
4334 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4335 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4336
4337 if (!pHddCtx || !pHddStaCtx) {
4338 hddLog(LOG1, FL("Invalid pHddCtx or pHddStaCtx"));
4339 break;
4340 }
4341
4342 hddLog(LOG1, FL("eCSR_ROAM_STA_CHANNEL_SWITCH: new channel %hu"),
4343 pRoamInfo->chan_info.chan_id);
4344
4345 pHddStaCtx->conn_info.operationChannel =
4346 pRoamInfo->chan_info.chan_id;
4347
4348 pHostapdAdapter = hdd_get_adapter(pHddCtx, WLAN_HDD_SOFTAP);
4349 if (pHostapdAdapter &&
4350 (test_bit(SOFTAP_BSS_STARTED,
4351 &pHostapdAdapter->event_flags)))
4352 {
4353 /* Restart SAP if its operating channel is different
4354 * from AP channel.
4355 */
4356 hddLog(VOS_TRACE_LEVEL_INFO,"SAP chan %d, STA chan %d, force_scc_with_ecsa %d",
4357 pHostapdAdapter->sessionCtx.ap.operatingChannel,
4358 pRoamInfo->chan_info.chan_id,
4359 pHddCtx->cfg_ini->force_scc_with_ecsa);
4360 if ((pHddCtx->cfg_ini->force_scc_with_ecsa ) &&
4361 (pHostapdAdapter->sessionCtx.ap.operatingChannel !=
4362 pRoamInfo->chan_info.chan_id))
4363 {
Ganesh Kondabattini3655a6d2018-01-08 20:25:39 +05304364 schedule_delayed_work(&pHddCtx->ecsa_chan_change_work, 0);
Ganesh Kondabattini529397f2017-12-27 19:13:52 +05304365 }
4366 else
4367 hddLog(LOG1, FL("SAP restart not required"));
4368 } else
4369 hddLog(LOG1, FL("SAP not active, nothing to do"));
4370 }
Selvaraj, Sridhar59c50392016-06-09 17:08:05 +05304371 break;
Girish Gowlia95daca2015-02-04 20:31:31 +05304372 default:
Jeff Johnson295189b2012-06-20 16:38:30 -07004373 break;
4374 }
4375 return( halStatus );
4376}
Shailender Karmuchia734f332013-04-19 14:02:48 -07004377eCsrAuthType hdd_TranslateRSNToCsrAuthType( u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004378{
4379 eCsrAuthType auth_type;
4380 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004381 if ( memcmp(auth_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004382 {
4383 auth_type = eCSR_AUTH_TYPE_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004384 } else
4385 if (memcmp(auth_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004386 {
4387 auth_type = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004388 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004389#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004390 if (memcmp(auth_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004391 {
4392 // Check for 11r FT Authentication with PSK
4393 auth_type = eCSR_AUTH_TYPE_FT_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004394 } else
4395 if (memcmp(auth_suite , ccpRSNOui03, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004396 {
4397 // Check for 11R FT Authentication with 802.1X
4398 auth_type = eCSR_AUTH_TYPE_FT_RSN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004399 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004400#endif
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004401#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004402 if (memcmp(auth_suite , ccpRSNOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004403 {
4404 auth_type = eCSR_AUTH_TYPE_CCKM_RSN;
4405 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004406#endif /* FEATURE_WLAN_ESE */
Chet Lanctot186b5732013-03-18 10:26:30 -07004407#ifdef WLAN_FEATURE_11W
4408 if (memcmp(auth_suite , ccpRSNOui07, 4) == 0)
4409 {
4410 auth_type = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4411 } else
Abhishek Singhae408032014-09-25 17:22:04 +05304412 if (memcmp(auth_suite , ccpRSNOui08, 4) == 0)
4413 {
4414 auth_type = eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4415 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07004416#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004417 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004418 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
4419 }
4420 return auth_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004421}
Jeff Johnson7dda7772013-02-27 08:36:13 -08004422
Shailender Karmuchia734f332013-04-19 14:02:48 -07004423eCsrAuthType
4424hdd_TranslateWPAToCsrAuthType(u_int8_t auth_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004425{
4426 eCsrAuthType auth_type;
4427 // is the auth type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004428 if ( memcmp(auth_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004429 {
4430 auth_type = eCSR_AUTH_TYPE_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004431 } else
4432 if (memcmp(auth_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004433 {
4434 auth_type = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004435 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004436#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004437 if (memcmp(auth_suite , ccpWpaOui06, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004438 {
4439 auth_type = eCSR_AUTH_TYPE_CCKM_WPA;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004440 } else
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004441#endif /* FEATURE_WLAN_ESE */
Shailender Karmuchia734f332013-04-19 14:02:48 -07004442 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004443 auth_type = eCSR_AUTH_TYPE_UNKNOWN;
4444 }
4445 hddLog(LOG1, FL("auth_type: %d"), auth_type);
4446 return auth_type;
4447}
Jeff Johnson7dda7772013-02-27 08:36:13 -08004448
Shailender Karmuchia734f332013-04-19 14:02:48 -07004449eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07004450hdd_TranslateRSNToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004451{
4452 eCsrEncryptionType cipher_type;
4453 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004454 if ( memcmp(cipher_suite , ccpRSNOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004455 {
4456 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004457 }
4458 else if (memcmp(cipher_suite , ccpRSNOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004459 {
4460 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004461 }
4462 else if (memcmp(cipher_suite , ccpRSNOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004463 {
4464 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004465 }
4466 else if (memcmp(cipher_suite , ccpRSNOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004467 {
4468 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004469 }
4470 else if (memcmp(cipher_suite , ccpRSNOui05, 4) == 0)
4471 {
4472 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4473 }
4474 else
4475 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004476 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4477 }
4478 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
4479 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004480}
Jeff Johnson295189b2012-06-20 16:38:30 -07004481/* To find if the MAC address is NULL */
4482static tANI_U8 hdd_IsMACAddrNULL (tANI_U8 *macAddr, tANI_U8 length)
4483{
4484 int i;
4485 for (i = 0; i < length; i++)
4486 {
4487 if (0x00 != (macAddr[i]))
4488 {
4489 return FALSE;
4490 }
4491 }
4492 return TRUE;
4493} /****** end hdd_IsMACAddrNULL() ******/
Jeff Johnson7dda7772013-02-27 08:36:13 -08004494
Shailender Karmuchia734f332013-04-19 14:02:48 -07004495eCsrEncryptionType
Jeff Johnson295189b2012-06-20 16:38:30 -07004496hdd_TranslateWPAToCsrEncryptionType(u_int8_t cipher_suite[4])
Jeff Johnson295189b2012-06-20 16:38:30 -07004497{
4498 eCsrEncryptionType cipher_type;
4499 // is the cipher type supported?
Shailender Karmuchia734f332013-04-19 14:02:48 -07004500 if ( memcmp(cipher_suite , ccpWpaOui04, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004501 {
4502 cipher_type = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004503 } else
4504 if (memcmp(cipher_suite , ccpWpaOui02, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004505 {
4506 cipher_type = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004507 } else
4508 if (memcmp(cipher_suite , ccpWpaOui00, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004509 {
4510 cipher_type = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004511 } else
4512 if (memcmp(cipher_suite , ccpWpaOui01, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004513 {
4514 cipher_type = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004515 } else
4516 if (memcmp(cipher_suite , ccpWpaOui05, 4) == 0)
Jeff Johnson295189b2012-06-20 16:38:30 -07004517 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004518 cipher_type = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
4519 } else
4520 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004521 cipher_type = eCSR_ENCRYPT_TYPE_FAILED;
4522 }
4523 hddLog(LOG1, FL("cipher_type: %d"), cipher_type);
4524 return cipher_type;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004525}
Jeff Johnson295189b2012-06-20 16:38:30 -07004526
Shailender Karmuchia734f332013-04-19 14:02:48 -07004527static tANI_S32 hdd_ProcessGENIE(hdd_adapter_t *pAdapter,
4528 struct ether_addr *pBssid,
4529 eCsrEncryptionType *pEncryptType,
4530 eCsrEncryptionType *mcEncryptType,
4531 eCsrAuthType *pAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07004532#ifdef WLAN_FEATURE_11W
4533 u_int8_t *pMfpRequired,
4534 u_int8_t *pMfpCapable,
4535#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004536 u_int16_t gen_ie_len,
4537 u_int8_t *gen_ie)
Jeff Johnson295189b2012-06-20 16:38:30 -07004538{
4539 tHalHandle halHandle = WLAN_HDD_GET_HAL_CTX(pAdapter);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004540 eHalStatus result;
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304541 tDot11fIERSN dot11RSNIE = {0};
4542 tDot11fIEWPA dot11WPAIE = {0};
Shailender Karmuchia734f332013-04-19 14:02:48 -07004543 tANI_U32 i;
Ashish Kumar Dhanotiyaffbfd8c2017-11-29 14:04:38 +05304544 tANI_U32 status;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004545 tANI_U8 *pRsnIe;
4546 tANI_U16 RSNIeLen;
Jeff Johnson295189b2012-06-20 16:38:30 -07004547 tPmkidCacheInfo PMKIDCache[4]; // Local transfer memory
Dhanashri Atre51981c62013-06-13 11:47:57 -07004548 v_BOOL_t updatePMKCache = FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004549
4550 /* Clear struct of tDot11fIERSN and tDot11fIEWPA specifically setting present
4551 flag to 0 */
4552 memset( &dot11WPAIE, 0 , sizeof(tDot11fIEWPA) );
4553 memset( &dot11RSNIE, 0 , sizeof(tDot11fIERSN) );
4554
Jeff Johnson295189b2012-06-20 16:38:30 -07004555 // Type check
Shailender Karmuchia734f332013-04-19 14:02:48 -07004556 if ( gen_ie[0] == DOT11F_EID_RSN)
4557 {
Jeff Johnson295189b2012-06-20 16:38:30 -07004558 // Validity checks
Shailender Karmuchia734f332013-04-19 14:02:48 -07004559 if ((gen_ie_len < DOT11F_IE_RSN_MIN_LEN ) ||
Jeff Johnson295189b2012-06-20 16:38:30 -07004560 (gen_ie_len > DOT11F_IE_RSN_MAX_LEN) )
4561 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304562 hddLog(LOGE, "%s: Invalid DOT11F RSN IE length :%d\n",
4563 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004564 return -EINVAL;
4565 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004566 // Skip past the EID byte and length byte
4567 pRsnIe = gen_ie + 2;
4568 RSNIeLen = gen_ie_len - 2;
4569 // Unpack the RSN IE
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304570 status = sme_unpack_rsn_ie(halHandle,
4571 pRsnIe,
4572 RSNIeLen,
4573 &dot11RSNIE);
Ashish Kumar Dhanotiyaffbfd8c2017-11-29 14:04:38 +05304574 if (DOT11F_FAILED(status))
4575 {
4576 hddLog(LOGE,
4577 FL("Parse failure in hdd_ProcessGENIE (0x%08x)"),
4578 status);
4579 return -EINVAL;
4580 }
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304581 hddLog(LOG1, FL("%s: gp_cipher_suite_present: %d"),
4582 __func__, dot11RSNIE.gp_cipher_suite_present);
4583
Shailender Karmuchia734f332013-04-19 14:02:48 -07004584 // Copy out the encryption and authentication types
4585 hddLog(LOG1, FL("%s: pairwise cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004586 __func__, dot11RSNIE.pwise_cipher_suite_count );
Shailender Karmuchia734f332013-04-19 14:02:48 -07004587 hddLog(LOG1, FL("%s: authentication suite count: %d"),
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304588 __func__, dot11RSNIE.akm_suite_cnt);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004589 /*Here we have followed the apple base code,
Jeff Johnson295189b2012-06-20 16:38:30 -07004590 but probably I suspect we can do something different*/
4591 //dot11RSNIE.akm_suite_count
Shailender Karmuchia734f332013-04-19 14:02:48 -07004592 // Just translate the FIRST one
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304593 *pAuthType = hdd_TranslateRSNToCsrAuthType(dot11RSNIE.akm_suite[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004594 //dot11RSNIE.pwise_cipher_suite_count
4595 *pEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.pwise_cipher_suites[0]);
4596 //dot11RSNIE.gp_cipher_suite_count
4597 *mcEncryptType = hdd_TranslateRSNToCsrEncryptionType(dot11RSNIE.gp_cipher_suite);
Chet Lanctot186b5732013-03-18 10:26:30 -07004598#ifdef WLAN_FEATURE_11W
4599 *pMfpRequired = (dot11RSNIE.RSN_Cap[0] >> 6) & 0x1 ;
4600 *pMfpCapable = (dot11RSNIE.RSN_Cap[0] >> 7) & 0x1 ;
4601#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004602 // Set the PMKSA ID Cache for this interface
Shailender Karmuchia734f332013-04-19 14:02:48 -07004603 for (i=0; i<dot11RSNIE.pmkid_count; i++)
Jeff Johnson295189b2012-06-20 16:38:30 -07004604 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004605 if ( pBssid == NULL)
Jeff Johnson295189b2012-06-20 16:38:30 -07004606 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304607 hddLog(LOGE, "%s: pBssid passed is NULL", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004608 break;
4609 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004610 if ( hdd_IsMACAddrNULL( (u_char *) pBssid->ether_addr_octet , 6))
Jeff Johnson295189b2012-06-20 16:38:30 -07004611 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304612 hddLog(LOGE, "%s: Invalid MAC adrr", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07004613 break;
4614 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004615 updatePMKCache = TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07004616 // For right now, I assume setASSOCIATE() has passed in the bssid.
4617 vos_mem_copy(PMKIDCache[i].BSSID,
4618 pBssid, ETHER_ADDR_LEN);
4619 vos_mem_copy(PMKIDCache[i].PMKID,
4620 dot11RSNIE.pmkid[i],
4621 CSR_RSN_PMKID_SIZE);
4622 }
Dhanashri Atre51981c62013-06-13 11:47:57 -07004623
4624 if (updatePMKCache)
4625 {
4626 // Calling csrRoamSetPMKIDCache to configure the PMKIDs into the cache
Jeff Johnson0299d0a2013-10-30 12:37:43 -07004627 hddLog(LOG1, FL("%s: Calling csrRoamSetPMKIDCache with cache entry %d."),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004628 __func__, i );
Dhanashri Atre51981c62013-06-13 11:47:57 -07004629 // Finally set the PMKSA ID Cache in CSR
4630 result = sme_RoamSetPMKIDCache(halHandle,pAdapter->sessionId,
4631 PMKIDCache,
Kanchanapally, Vidyullatha2633ace2014-09-25 15:16:50 +05304632 dot11RSNIE.pmkid_count,
4633 FALSE);
Dhanashri Atre51981c62013-06-13 11:47:57 -07004634 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004635 }
4636 else if (gen_ie[0] == DOT11F_EID_WPA)
4637 {
4638 // Validity checks
4639 if ((gen_ie_len < DOT11F_IE_WPA_MIN_LEN ) ||
4640 (gen_ie_len > DOT11F_IE_WPA_MAX_LEN))
4641 {
Arun Kumar Khandavalli138f3c12013-12-13 16:24:33 +05304642 hddLog(LOGE, "%s: Invalid DOT11F WPA IE length :%d\n",
4643 __func__, gen_ie_len);
Jeff Johnson295189b2012-06-20 16:38:30 -07004644 return -EINVAL;
4645 }
4646 // Skip past the EID byte and length byte - and four byte WiFi OUI
Shailender Karmuchia734f332013-04-19 14:02:48 -07004647 pRsnIe = gen_ie + 2 + 4;
4648 RSNIeLen = gen_ie_len - (2 + 4);
4649 // Unpack the WPA IE
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304650 status = dot11fUnpackIeWPA((tpAniSirGlobal) halHandle,
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304651 pRsnIe, RSNIeLen, &dot11WPAIE);
4652 if (!DOT11F_SUCCEEDED(status))
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304653 {
4654 hddLog(LOGE,
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304655 FL("Invalid RSN IE: parse status %d"), status);
Pragaspathi Thilagarajb2041e82018-03-28 17:14:02 +05304656 return -EINVAL;
4657 }
4658
Jeff Johnson295189b2012-06-20 16:38:30 -07004659 // Copy out the encryption and authentication types
4660 hddLog(LOG1, FL("%s: WPA unicast cipher suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004661 __func__, dot11WPAIE.unicast_cipher_count );
Jeff Johnson295189b2012-06-20 16:38:30 -07004662 hddLog(LOG1, FL("%s: WPA authentication suite count: %d"),
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004663 __func__, dot11WPAIE.auth_suite_count);
Jeff Johnson295189b2012-06-20 16:38:30 -07004664 //dot11WPAIE.auth_suite_count
4665 // Just translate the FIRST one
4666 *pAuthType = hdd_TranslateWPAToCsrAuthType(dot11WPAIE.auth_suites[0]);
4667 //dot11WPAIE.unicast_cipher_count
4668 *pEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.unicast_ciphers[0]);
4669 //dot11WPAIE.unicast_cipher_count
4670 *mcEncryptType = hdd_TranslateWPAToCsrEncryptionType(dot11WPAIE.multicast_cipher);
4671 }
4672 else
4673 {
4674 hddLog(LOGW, FL("gen_ie[0]: %d"), gen_ie[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004675 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004676 }
4677 return 0;
4678}
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304679
4680/**
4681 * hdd_set_def_rsne_override() - set default encryption type and auth type
4682 * in profile.
4683 * @roam_profile: pointer to adapter
4684 * @auth_type: pointer to auth type
4685 *
4686 * Set default value of encryption type and auth type in profile to
4687 * search the AP using filter, as in force_rsne_override the RSNIE can be
4688 * currupt and we might not get the proper encryption type and auth type
4689 * while parsing the RSNIE.
4690 *
4691 * Return: void
4692 */
4693static void hdd_set_def_rsne_override(
4694 tCsrRoamProfile *roam_profile, eCsrAuthType *auth_type)
4695{
4696 hddLog( LOG1, FL("Set def values in roam profile"));
4697 roam_profile->MFPCapable = roam_profile->MFPEnabled;
4698 roam_profile->EncryptionType.numEntries = 2;
4699 roam_profile->mcEncryptionType.numEntries = 2;
4700 /* Use the cipher type in the RSN IE */
4701 roam_profile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_AES;
4702 roam_profile->EncryptionType.encryptionType[1] = eCSR_ENCRYPT_TYPE_TKIP;
4703 roam_profile->mcEncryptionType.encryptionType[0] =
4704 eCSR_ENCRYPT_TYPE_AES;
4705 roam_profile->mcEncryptionType.encryptionType[1] =
4706 eCSR_ENCRYPT_TYPE_TKIP;
4707 *auth_type = eCSR_AUTH_TYPE_RSN_PSK;
4708}
4709
Jeff Johnson295189b2012-06-20 16:38:30 -07004710int hdd_SetGENIEToCsr( hdd_adapter_t *pAdapter, eCsrAuthType *RSNAuthType)
4711{
4712 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4713 v_U32_t status = 0;
4714 eCsrEncryptionType RSNEncryptType;
4715 eCsrEncryptionType mcRSNEncryptType;
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304716 hdd_context_t *hdd_ctx;
Chet Lanctot186b5732013-03-18 10:26:30 -07004717#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304718 u_int8_t RSNMfpRequired = 0;
4719 u_int8_t RSNMfpCapable = 0;
Chet Lanctot186b5732013-03-18 10:26:30 -07004720#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004721 struct ether_addr bSsid; // MAC address of assoc peer
4722 // MAC address of assoc peer
4723 // But, this routine is only called when we are NOT associated.
4724 vos_mem_copy(bSsid.ether_addr_octet,
4725 pWextState->roamProfile.BSSIDs.bssid,
4726 sizeof(bSsid.ether_addr_octet));
4727 if (pWextState->WPARSNIE[0] == DOT11F_EID_RSN || pWextState->WPARSNIE[0] == DOT11F_EID_WPA)
4728 {
4729 //continue
Shailender Karmuchia734f332013-04-19 14:02:48 -07004730 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004731 else
4732 {
4733 return 0;
4734 }
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304735
Jeff Johnson295189b2012-06-20 16:38:30 -07004736 // The actual processing may eventually be more extensive than this.
4737 // Right now, just consume any PMKIDs that are sent in by the app.
4738 status = hdd_ProcessGENIE(pAdapter,
4739 &bSsid, // MAC address of assoc peer
4740 &RSNEncryptType,
4741 &mcRSNEncryptType,
4742 RSNAuthType,
Chet Lanctot186b5732013-03-18 10:26:30 -07004743#ifdef WLAN_FEATURE_11W
4744 &RSNMfpRequired,
4745 &RSNMfpCapable,
4746#endif
Jeff Johnson295189b2012-06-20 16:38:30 -07004747 pWextState->WPARSNIE[1]+2,
4748 pWextState->WPARSNIE);
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304749
Jeff Johnson295189b2012-06-20 16:38:30 -07004750 if (status == 0)
4751 {
4752 // Now copy over all the security attributes you have parsed out
4753 pWextState->roamProfile.EncryptionType.numEntries = 1;
4754 pWextState->roamProfile.mcEncryptionType.numEntries = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004755
Jeff Johnson295189b2012-06-20 16:38:30 -07004756 pWextState->roamProfile.EncryptionType.encryptionType[0] = RSNEncryptType; // Use the cipher type in the RSN IE
4757 pWextState->roamProfile.mcEncryptionType.encryptionType[0] = mcRSNEncryptType;
Chet Lanctot186b5732013-03-18 10:26:30 -07004758
Shailender Karmuchi642e9812013-05-30 14:34:49 -07004759 if ( (WLAN_HDD_IBSS == pAdapter->device_mode) &&
4760 ((eCSR_ENCRYPT_TYPE_AES == mcRSNEncryptType) ||
4761 (eCSR_ENCRYPT_TYPE_TKIP == mcRSNEncryptType)))
4762 {
4763 /*For wpa none supplicant sends the WPA IE with unicast cipher as
4764 eCSR_ENCRYPT_TYPE_NONE ,where as the multicast cipher as
4765 either AES/TKIP based on group cipher configuration
4766 mentioned in the wpa_supplicant.conf.*/
4767
4768 /*Set the unicast cipher same as multicast cipher*/
4769 pWextState->roamProfile.EncryptionType.encryptionType[0]
4770 = mcRSNEncryptType;
4771 }
4772
Chet Lanctot186b5732013-03-18 10:26:30 -07004773#ifdef WLAN_FEATURE_11W
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304774 hddLog( LOG1, FL("RSNMfpRequired = %d, RSNMfpCapable = %d"),
4775 RSNMfpRequired, RSNMfpCapable);
Chet Lanctot186b5732013-03-18 10:26:30 -07004776 pWextState->roamProfile.MFPRequired = RSNMfpRequired;
4777 pWextState->roamProfile.MFPCapable = RSNMfpCapable;
4778#endif
Abhishek Singh4f6406d2015-10-07 13:43:52 +05304779 hddLog( LOG1,
4780 FL("CSR AuthType = %d, EncryptionType = %d mcEncryptionType = %d"),
4781 *RSNAuthType, RSNEncryptType, mcRSNEncryptType);
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304782 return 0;
Jeff Johnson295189b2012-06-20 16:38:30 -07004783 }
Pragaspathi Thilagaraj03e2ab12018-06-22 12:19:48 +05304784
4785 hdd_ctx = WLAN_HDD_GET_CTX(pAdapter);
4786 if (hdd_ctx->force_rsne_override &&
4787 (pWextState->WPARSNIE[0] == DOT11F_EID_RSN)) {
4788 hddLog(LOG1,
4789 FL("Test mode enabled set def Auth and enc type. RSN IE passed in connect req:"));
4790 vos_trace_hex_dump(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_WARN,
4791 pWextState->roamProfile.pRSNReqIE,
4792 pWextState->roamProfile.nRSNReqIELength);
4793
4794 pWextState->roamProfile.force_rsne_override = true;
4795 hddLog(LOG1,
4796 FL("MFPEnabled %d"), pWextState->roamProfile.MFPEnabled);
4797 /*
4798 * Reset MFPEnabled if testmode RSNE passed doesnt have MFPR
4799 * or MFPC bit set
4800 */
4801 if (pWextState->roamProfile.MFPEnabled &&
4802 !(pWextState->roamProfile.MFPRequired ||
4803 pWextState->roamProfile.MFPCapable)) {
4804 hddLog( LOG1,FL("Reset MFPEnabled"));
4805 pWextState->roamProfile.MFPEnabled = 0;
4806 }
4807
4808 /* If parsing failed set the def value for the roam profile */
4809 if (status)
4810 hdd_set_def_rsne_override(&pWextState->roamProfile,
4811 RSNAuthType);
4812 }
Pragaspathi Thilagarajd1b02df2018-06-26 17:08:05 +05304813 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07004814}
4815int hdd_set_csr_auth_type ( hdd_adapter_t *pAdapter, eCsrAuthType RSNAuthType)
4816{
4817 hdd_wext_state_t *pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
4818 tCsrRoamProfile* pRoamProfile = &(pWextState->roamProfile);
4819 hdd_station_ctx_t *pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4820 ENTER();
Shailender Karmuchia734f332013-04-19 14:02:48 -07004821
Jeff Johnson295189b2012-06-20 16:38:30 -07004822 pRoamProfile->AuthType.numEntries = 1;
Arif Hussain6d2a3322013-11-17 19:50:10 -08004823 hddLog( LOG1, "%s: pHddStaCtx->conn_info.authType = %d", __func__, pHddStaCtx->conn_info.authType);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004824
Jeff Johnson295189b2012-06-20 16:38:30 -07004825 switch( pHddStaCtx->conn_info.authType)
4826 {
4827 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
Abhinav Kumar62801ba2018-09-19 12:14:14 +05304828 case eCSR_AUTH_TYPE_AUTOSWITCH:
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004829#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07004830 case eCSR_AUTH_TYPE_CCKM_WPA:
4831 case eCSR_AUTH_TYPE_CCKM_RSN:
4832#endif
Shailender Karmuchia734f332013-04-19 14:02:48 -07004833 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_DISABLED) {
4834
Jeff Johnson295189b2012-06-20 16:38:30 -07004835 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_OPEN_SYSTEM ;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004836 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004837 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004838
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004839#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004840 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA) &&
4841 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4842 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004843 hddLog( LOG1, "%s: set authType to CCKM WPA. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004844 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
4845 } else
4846 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_WPA)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004847 hddLog( LOG1, "%s: Last chance to set authType to CCKM WPA.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004848 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_WPA;
Jeff Johnson295189b2012-06-20 16:38:30 -07004849 } else
4850#endif
4851 if((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4852 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004853 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA;
4854 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004855 if ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4856 == IW_AUTH_KEY_MGMT_PSK) {
4857 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004858 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004859 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WPA_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004860 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004861 }
4862 if (pWextState->wpaVersion & IW_AUTH_WPA_VERSION_WPA2) {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004863#ifdef FEATURE_WLAN_ESE
Shailender Karmuchia734f332013-04-19 14:02:48 -07004864 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN) &&
4865 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
4866 == IW_AUTH_KEY_MGMT_802_1X)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004867 hddLog( LOG1, "%s: set authType to CCKM RSN. AKM also 802.1X.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004868 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004869 } else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004870 if ((RSNAuthType == eCSR_AUTH_TYPE_CCKM_RSN)) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08004871 hddLog( LOG1, "%s: Last chance to set authType to CCKM RSN.", __func__);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004872 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_CCKM_RSN;
Jeff Johnson295189b2012-06-20 16:38:30 -07004873 } else
4874#endif
4875
4876#ifdef WLAN_FEATURE_VOWIFI_11R
Shailender Karmuchia734f332013-04-19 14:02:48 -07004877 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN) &&
4878 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004879 == IW_AUTH_KEY_MGMT_802_1X)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004880 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN;
Jeff Johnson43971f52012-07-17 12:26:56 -07004881 }else
Shailender Karmuchia734f332013-04-19 14:02:48 -07004882 if ((RSNAuthType == eCSR_AUTH_TYPE_FT_RSN_PSK) &&
Jeff Johnson295189b2012-06-20 16:38:30 -07004883 ((pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4884 == IW_AUTH_KEY_MGMT_PSK)) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004885 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_FT_RSN_PSK;
Jeff Johnson295189b2012-06-20 16:38:30 -07004886 } else
4887#endif
4888
Chet Lanctot186b5732013-03-18 10:26:30 -07004889#ifdef WLAN_FEATURE_11W
4890 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_PSK_SHA256) {
4891 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK_SHA256;
4892 } else
Abhishek Singhae408032014-09-25 17:22:04 +05304893 if (RSNAuthType == eCSR_AUTH_TYPE_RSN_8021X_SHA256) {
4894 pRoamProfile->AuthType.authType[0] =
4895 eCSR_AUTH_TYPE_RSN_8021X_SHA256;
4896 } else
Chet Lanctot186b5732013-03-18 10:26:30 -07004897#endif
4898
Shailender Karmuchia734f332013-04-19 14:02:48 -07004899 if( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X)
Jeff Johnson295189b2012-06-20 16:38:30 -07004900 == IW_AUTH_KEY_MGMT_802_1X) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07004901 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN;
4902 } else
Jeff Johnson295189b2012-06-20 16:38:30 -07004903 if ( (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_PSK)
4904 == IW_AUTH_KEY_MGMT_PSK) {
4905 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_RSN_PSK;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004906 } else {
Jeff Johnson295189b2012-06-20 16:38:30 -07004907 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004908 }
Jeff Johnson295189b2012-06-20 16:38:30 -07004909 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004910 break;
4911
Jeff Johnson295189b2012-06-20 16:38:30 -07004912 case eCSR_AUTH_TYPE_SHARED_KEY:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004913
4914 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_SHARED_KEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07004915 break;
4916 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07004917
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004918#ifdef FEATURE_WLAN_ESE
Arif Hussain6d2a3322013-11-17 19:50:10 -08004919 hddLog( LOG1, "%s: In default, unknown auth type.", __func__);
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08004920#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07004921 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_UNKNOWN;
4922 break;
4923 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07004924
Jeff Johnson295189b2012-06-20 16:38:30 -07004925 hddLog( LOG1, "%s Set roam Authtype to %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07004926 __func__, pWextState->roamProfile.AuthType.authType[0]);
Shailender Karmuchia734f332013-04-19 14:02:48 -07004927
Jeff Johnson295189b2012-06-20 16:38:30 -07004928 EXIT();
4929 return 0;
4930}
4931
Sravan Kumar Kairam091e5b62017-01-23 14:14:20 +05304932/**
4933 * hdd_rx_fwd_eapol() - forward cached eapol frames
4934 * @vosContext : pointer to vos global context
4935 * @pVosPacket: pointer to vos packet
4936 *
4937 * Return: None
4938 *
4939 */
4940void hdd_assoc_registerFwdEapolCB(void *pContext)
4941{
4942 WLANTL_RegisterFwdEapol(pContext, hdd_rx_fwd_eapol);
4943}
4944
Jeff Johnson295189b2012-06-20 16:38:30 -07004945/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07004946
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304947 \brief __iw_set_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07004948 This function sets the ssid received from wpa_supplicant
Shailender Karmuchia734f332013-04-19 14:02:48 -07004949 to the CSR roam profile.
4950
Jeff Johnson295189b2012-06-20 16:38:30 -07004951 \param - dev - Pointer to the net device.
4952 - info - Pointer to the iw_request_info.
4953 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07004954 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07004955 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07004956
Jeff Johnson295189b2012-06-20 16:38:30 -07004957 --------------------------------------------------------------------------*/
4958
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05304959int __iw_set_essid(struct net_device *dev,
4960 struct iw_request_info *info,
4961 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07004962{
4963 v_U32_t status = 0;
4964 hdd_wext_state_t *pWextState;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304965 hdd_adapter_t *pAdapter;
4966 hdd_context_t *pHddCtx;
Jeff Johnson295189b2012-06-20 16:38:30 -07004967 v_U32_t roamId;
4968 tCsrRoamProfile *pRoamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07004969 eCsrAuthType RSNAuthType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304970 tHalHandle hHal;
4971 hdd_station_ctx_t *pHddStaCtx;
4972 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07004973
Jeff Johnson295189b2012-06-20 16:38:30 -07004974 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304975 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
4976 if (NULL == pAdapter)
Jeff Johnson295189b2012-06-20 16:38:30 -07004977 {
Agarwal Ashish971c2882013-10-30 20:11:12 +05304978 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304979 "%s: Adapter is NULL",__func__);
4980 return -EINVAL;
Jeff Johnson295189b2012-06-20 16:38:30 -07004981 }
4982
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304983 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
4984 ret = wlan_hdd_validate_context(pHddCtx);
4985 if (0 != ret)
4986 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05304987 return ret;
4988 }
4989
4990 hHal = WLAN_HDD_GET_HAL_CTX(pAdapter);
4991 if (NULL == hHal)
4992 {
4993 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
4994 "%s: Hal Context is NULL",__func__);
4995 return -EINVAL;
4996 }
4997 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
4998 if (NULL == pHddStaCtx)
4999 {
5000 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5001 "%s: STA Context is NULL",__func__);
5002 return -EINVAL;
5003 }
5004 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5005 if (NULL == pWextState)
5006 {
5007 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5008 "%s: pWextState is NULL",__func__);
5009 return -EINVAL;
5010 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005011 if(pWextState->mTKIPCounterMeasures == TKIP_COUNTER_MEASURE_STARTED) {
5012 hddLog(VOS_TRACE_LEVEL_INFO_HIGH, "%s :Counter measure is in progress", __func__);
5013 return -EBUSY;
5014 }
5015 if( SIR_MAC_MAX_SSID_LENGTH < wrqu->essid.length )
5016 return -EINVAL;
5017 pRoamProfile = &pWextState->roamProfile;
Jeff Johnson295189b2012-06-20 16:38:30 -07005018
Rajeev Kumar Sirasanagandla8f11d542017-11-14 17:56:55 +05305019 if (wlan_hdd_check_and_stop_mon(pAdapter, true))
5020 return -EINVAL;
5021
Agrawal Ashishc407f192017-01-23 17:18:35 +05305022 /*Try disconnecting if already in connected state*/
5023 status = wlan_hdd_try_disconnect(pAdapter);
5024 if (0 > status)
Jeff Johnson295189b2012-06-20 16:38:30 -07005025 {
Agrawal Ashishc407f192017-01-23 17:18:35 +05305026 hddLog(VOS_TRACE_LEVEL_ERROR, FL("Failed to disconnect the existing"
5027 " connection"));
5028 return -EALREADY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005029 }
5030 /** wpa_supplicant 0.8.x, wext driver uses */
Shailender Karmuchia734f332013-04-19 14:02:48 -07005031 /** when cfg80211 defined, wpa_supplicant wext driver uses
5032 zero-length, null-string ssid for force disconnection.
5033 after disconnection (if previously connected) and cleaning ssid,
Jeff Johnson295189b2012-06-20 16:38:30 -07005034 driver MUST return success */
5035 if ( 0 == wrqu->essid.length ) {
5036 return 0;
5037 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005038
5039 status = hdd_wmm_get_uapsd_mask(pAdapter,
5040 &pWextState->roamProfile.uapsd_mask);
5041 if (VOS_STATUS_SUCCESS != status)
5042 {
5043 pWextState->roamProfile.uapsd_mask = 0;
5044 }
5045 pWextState->roamProfile.SSIDs.numOfSSIDs = 1;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005046
Jeff Johnson295189b2012-06-20 16:38:30 -07005047 pWextState->roamProfile.SSIDs.SSIDList->SSID.length = wrqu->essid.length;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005048
5049 vos_mem_zero(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId, sizeof(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId));
Jeff Johnson295189b2012-06-20 16:38:30 -07005050 vos_mem_copy((void *)(pWextState->roamProfile.SSIDs.SSIDList->SSID.ssId), extra, wrqu->essid.length);
5051 if (IW_AUTH_WPA_VERSION_WPA == pWextState->wpaVersion ||
5052 IW_AUTH_WPA_VERSION_WPA2 == pWextState->wpaVersion ) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005053
Jeff Johnson295189b2012-06-20 16:38:30 -07005054 //set gen ie
5055 hdd_SetGENIEToCsr(pAdapter, &RSNAuthType);
5056
5057 //set auth
5058 hdd_set_csr_auth_type(pAdapter, RSNAuthType);
5059 }
5060#ifdef FEATURE_WLAN_WAPI
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005061 hddLog(LOG1, "%s: Setting WAPI AUTH Type and Encryption Mode values", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005062 if (pAdapter->wapi_info.nWapiMode)
5063 {
5064 switch (pAdapter->wapi_info.wapiAuthMode)
5065 {
5066 case WAPI_AUTH_MODE_PSK:
5067 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005068 hddLog(LOG1, "%s: WAPI AUTH TYPE: PSK: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005069 pRoamProfile->AuthType.numEntries = 1;
5070 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_PSK;
5071 break;
5072 }
5073 case WAPI_AUTH_MODE_CERT:
5074 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005075 hddLog(LOG1, "%s: WAPI AUTH TYPE: CERT: %d", __func__, pAdapter->wapi_info.wapiAuthMode);
Jeff Johnson295189b2012-06-20 16:38:30 -07005076 pRoamProfile->AuthType.numEntries = 1;
5077 pRoamProfile->AuthType.authType[0] = eCSR_AUTH_TYPE_WAPI_WAI_CERTIFICATE;
5078 break;
5079 }
5080 } // End of switch
5081 if ( pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_PSK ||
5082 pAdapter->wapi_info.wapiAuthMode == WAPI_AUTH_MODE_CERT)
5083 {
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005084 hddLog(LOG1, "%s: WAPI PAIRWISE/GROUP ENCRYPTION: WPI", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005085 pRoamProfile->EncryptionType.numEntries = 1;
5086 pRoamProfile->EncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5087 pRoamProfile->mcEncryptionType.numEntries = 1;
5088 pRoamProfile->mcEncryptionType.encryptionType[0] = eCSR_ENCRYPT_TYPE_WPI;
5089 }
5090 }
5091#endif /* FEATURE_WLAN_WAPI */
5092 /* if previous genIE is not NULL, update AssocIE */
5093 if (0 != pWextState->genIE.length)
5094 {
5095 memset( &pWextState->assocAddIE, 0, sizeof(pWextState->assocAddIE) );
5096 memcpy( pWextState->assocAddIE.addIEdata, pWextState->genIE.addIEdata,
5097 pWextState->genIE.length);
5098 pWextState->assocAddIE.length = pWextState->genIE.length;
5099 pWextState->roamProfile.pAddIEAssoc = pWextState->assocAddIE.addIEdata;
5100 pWextState->roamProfile.nAddIEAssocLength = pWextState->assocAddIE.length;
5101
5102 /* clear previous genIE after use it */
5103 memset( &pWextState->genIE, 0, sizeof(pWextState->genIE) );
5104 }
5105
5106 /* assumes it is not WPS Association by default, except when pAddIEAssoc has WPS IE */
5107 pWextState->roamProfile.bWPSAssociation = FALSE;
5108
5109 if (NULL != wlan_hdd_get_wps_ie_ptr(pWextState->roamProfile.pAddIEAssoc,
5110 pWextState->roamProfile.nAddIEAssocLength))
5111 pWextState->roamProfile.bWPSAssociation = TRUE;
5112
5113
5114 // Disable auto BMPS entry by PMC until DHCP is done
5115 sme_SetDHCPTillPowerActiveFlag(WLAN_HDD_GET_HAL_CTX(pAdapter), TRUE);
5116
Shailender Karmuchia734f332013-04-19 14:02:48 -07005117 pWextState->roamProfile.csrPersona = pAdapter->device_mode;
Jeff Johnson295189b2012-06-20 16:38:30 -07005118 (WLAN_HDD_GET_CTX(pAdapter))->isAmpAllowed = VOS_FALSE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005119
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005120 if ( eCSR_BSS_TYPE_START_IBSS == pRoamProfile->BSSType )
5121 {
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005122 hdd_select_cbmode(pAdapter,
5123 (WLAN_HDD_GET_CTX(pAdapter))->cfg_ini->AdHocChannel5G);
5124 }
Agarwal Ashish40f9b872015-09-01 16:17:35 +05305125 /*
5126 * Change conn_state to connecting before sme_RoamConnect(),
5127 * because sme_RoamConnect() has a direct path to call
5128 * hdd_smeRoamCallback(), which will change the conn_state
5129 * If direct path, conn_state will be accordingly changed
5130 * to NotConnected or Associated by either
5131 * hdd_AssociationCompletionHandler() or hdd_DisConnectHandler()
5132 * in sme_RoamCallback()
5133 * if sme_RomConnect is to be queued,
5134 * Connecting state will remain until it is completed.
5135 *
5136 * If connection state is not changed,
5137 * connection state will remain in eConnectionState_NotConnected state.
5138 * In hdd_AssociationCompletionHandler, "hddDisconInProgress" is set to true
5139 * if conn state is eConnectionState_NotConnected.
5140 * If "hddDisconInProgress" is set to true then cfg80211 layer is not
5141 * informed of connect result indication which is an issue.
5142 */
5143 if (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5144 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode)
5145 {
5146 VOS_TRACE( VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO,
5147 FL("Set HDD connState to eConnectionState_Connecting"));
5148 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5149 eConnectionState_Connecting);
5150 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005151 status = sme_RoamConnect( hHal,pAdapter->sessionId,
5152 &(pWextState->roamProfile), &roamId);
Agarwal Ashish40f9b872015-09-01 16:17:35 +05305153
5154 if ((eHAL_STATUS_SUCCESS != status) &&
5155 (WLAN_HDD_INFRA_STATION == pAdapter->device_mode ||
5156 WLAN_HDD_P2P_CLIENT == pAdapter->device_mode))
5157 {
5158 hddLog(VOS_TRACE_LEVEL_ERROR,
5159 FL("sme_RoamConnect (session %d) failed with status %d. -> NotConnected"),
5160 pAdapter->sessionId, status);
5161 /* change back to NotAssociated */
5162 hdd_connSetConnectionState(WLAN_HDD_GET_STATION_CTX_PTR(pAdapter),
5163 eConnectionState_NotConnected);
5164 }
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005165 pRoamProfile->ChannelInfo.ChannelList = NULL;
5166 pRoamProfile->ChannelInfo.numOfChannels = 0;
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005167
Shailender Karmuchi15cd0672013-05-15 19:50:04 -07005168 EXIT();
5169 return status;
Jeff Johnson295189b2012-06-20 16:38:30 -07005170}
Ravi Joshiaeb7d9e2013-05-02 12:28:14 -07005171
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305172int iw_set_essid(struct net_device *dev,
5173 struct iw_request_info *info,
5174 union iwreq_data *wrqu, char *extra)
5175{
5176 int ret;
5177
5178 vos_ssr_protect(__func__);
5179 ret = __iw_set_essid(dev, info, wrqu, extra);
5180 vos_ssr_unprotect(__func__);
5181
5182 return ret;
5183}
5184
Jeff Johnson295189b2012-06-20 16:38:30 -07005185/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005186
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305187 \brief __iw_get_essid() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005188 This function returns the essid to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005189
Jeff Johnson295189b2012-06-20 16:38:30 -07005190 \param - dev - Pointer to the net device.
5191 - info - Pointer to the iw_request_info.
5192 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005193 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005194 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005195
Jeff Johnson295189b2012-06-20 16:38:30 -07005196 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305197int __iw_get_essid(struct net_device *dev,
5198 struct iw_request_info *info,
5199 struct iw_point *dwrq, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005200{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305201 hdd_adapter_t *pAdapter;
5202 hdd_context_t *pHddCtx;
5203 hdd_wext_state_t *wextBuf;
5204 hdd_station_ctx_t *pHddStaCtx;
5205 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305206
Jeff Johnson295189b2012-06-20 16:38:30 -07005207 ENTER();
5208
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305209 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5210 if (NULL == pAdapter)
5211 {
5212 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5213 "%s: Adapter is NULL",__func__);
5214 return -EINVAL;
5215 }
5216
5217 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5218 ret = wlan_hdd_validate_context(pHddCtx);
5219 if (0 != ret)
5220 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305221 return ret;
5222 }
5223
5224 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5225 if (NULL == pHddStaCtx)
5226 {
5227 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5228 "%s: STA Context is NULL",__func__);
5229 return -EINVAL;
5230 }
5231
5232 wextBuf = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5233 if (NULL == wextBuf)
5234 {
5235 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5236 "%s: wextBuf is NULL",__func__);
5237 return -EINVAL;
5238 }
5239
Jeff Johnson295189b2012-06-20 16:38:30 -07005240 if((pHddStaCtx->conn_info.connState == eConnectionState_Associated &&
5241 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0) ||
5242 ((pHddStaCtx->conn_info.connState == eConnectionState_IbssConnected ||
5243 pHddStaCtx->conn_info.connState == eConnectionState_IbssDisconnected) &&
5244 wextBuf->roamProfile.SSIDs.SSIDList->SSID.length > 0))
5245 {
5246 dwrq->length = pHddStaCtx->conn_info.SSID.SSID.length;
5247 memcpy(extra, pHddStaCtx->conn_info.SSID.SSID.ssId, dwrq->length);
5248 dwrq->flags = 1;
5249 } else {
5250 memset(extra, 0, dwrq->length);
5251 dwrq->length = 0;
5252 dwrq->flags = 0;
5253 }
5254 EXIT();
5255 return 0;
5256}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305257
5258int iw_get_essid(struct net_device *dev,
5259 struct iw_request_info *info,
5260 struct iw_point *dwrq, char *extra)
5261{
5262 int ret;
5263
5264 vos_ssr_protect(__func__);
5265 ret = __iw_get_essid(dev, info, dwrq, extra);
5266 vos_ssr_unprotect(__func__);
5267
5268 return ret;
5269}
Jeff Johnson295189b2012-06-20 16:38:30 -07005270/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005271
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305272 \brief __iw_set_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005273 This function sets the auth type received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005274
Jeff Johnson295189b2012-06-20 16:38:30 -07005275 \param - dev - Pointer to the net device.
5276 - info - Pointer to the iw_request_info.
5277 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005278 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005279 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005280
Jeff Johnson295189b2012-06-20 16:38:30 -07005281 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305282int __iw_set_auth(struct net_device *dev,struct iw_request_info *info,
5283 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005284{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305285 hdd_adapter_t *pAdapter;
5286 hdd_context_t *pHddCtx;
5287 hdd_wext_state_t *pWextState;
5288 hdd_station_ctx_t *pHddStaCtx;
5289 tCsrRoamProfile *pRoamProfile;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005290 eCsrEncryptionType mcEncryptionType;
Jeff Johnson295189b2012-06-20 16:38:30 -07005291 eCsrEncryptionType ucEncryptionType;
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305292 int ret = 0;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005293
Jeff Johnson295189b2012-06-20 16:38:30 -07005294 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005295
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305296 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5297 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005298 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305299 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5300 "%s: Adapter is NULL",__func__);
5301 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005302 }
5303
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305304 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5305 ret = wlan_hdd_validate_context(pHddCtx);
5306 if (0 != ret)
5307 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305308 return ret;
5309 }
5310
5311 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5312 if (NULL == pHddStaCtx)
5313 {
5314 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5315 "%s: STA Context is NULL",__func__);
5316 return -EINVAL;
5317 }
5318
5319 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5320 if (NULL == pWextState)
5321 {
5322 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5323 "%s: pWextState is NULL",__func__);
5324 return -EINVAL;
5325 }
5326
5327 pRoamProfile = &pWextState->roamProfile;
5328
Jeff Johnson295189b2012-06-20 16:38:30 -07005329 switch(wrqu->param.flags & IW_AUTH_INDEX)
5330 {
5331 case IW_AUTH_WPA_VERSION:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005332
Jeff Johnson295189b2012-06-20 16:38:30 -07005333 pWextState->wpaVersion = wrqu->param.value;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005334
Jeff Johnson295189b2012-06-20 16:38:30 -07005335 break;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005336
Jeff Johnson295189b2012-06-20 16:38:30 -07005337 case IW_AUTH_CIPHER_PAIRWISE:
5338 {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005339 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005340 ucEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005341 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005342 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5343 ucEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005344 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005345 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
5346 ucEncryptionType = eCSR_ENCRYPT_TYPE_AES;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005347 }
5348
Jeff Johnson295189b2012-06-20 16:38:30 -07005349 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005350
5351 if( (IW_AUTH_KEY_MGMT_802_1X
5352 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005353 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType) )
5354 /*Dynamic WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005355 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Jeff Johnson295189b2012-06-20 16:38:30 -07005356 else
5357 /*Static WEP key*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005358 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
5359 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005360 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005361
5362 if( ( IW_AUTH_KEY_MGMT_802_1X
5363 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X) )
Jeff Johnson295189b2012-06-20 16:38:30 -07005364 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5365 /*Dynamic WEP key*/
5366 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5367 else
5368 /*Static WEP key*/
5369 ucEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005370
Jeff Johnson295189b2012-06-20 16:38:30 -07005371 }
5372 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005373
Jeff Johnson295189b2012-06-20 16:38:30 -07005374 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07005375 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005376 return -EINVAL;
5377 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005378
Jeff Johnson295189b2012-06-20 16:38:30 -07005379 pRoamProfile->EncryptionType.numEntries = 1;
5380 pRoamProfile->EncryptionType.encryptionType[0] = ucEncryptionType;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005381 }
Jeff Johnson295189b2012-06-20 16:38:30 -07005382 break;
5383 case IW_AUTH_CIPHER_GROUP:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005384 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005385 if(wrqu->param.value & IW_AUTH_CIPHER_NONE) {
5386 mcEncryptionType = eCSR_ENCRYPT_TYPE_NONE;
5387 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005388
Jeff Johnson295189b2012-06-20 16:38:30 -07005389 else if(wrqu->param.value & IW_AUTH_CIPHER_TKIP) {
5390 mcEncryptionType = eCSR_ENCRYPT_TYPE_TKIP;
5391 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005392
5393 else if(wrqu->param.value & IW_AUTH_CIPHER_CCMP) {
Jeff Johnson295189b2012-06-20 16:38:30 -07005394 mcEncryptionType = eCSR_ENCRYPT_TYPE_AES;
5395 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005396
Jeff Johnson295189b2012-06-20 16:38:30 -07005397 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP40) {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005398
5399 if( ( IW_AUTH_KEY_MGMT_802_1X
5400 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X ))
5401 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5402
Jeff Johnson295189b2012-06-20 16:38:30 -07005403 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005404
5405 else
5406 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP40_STATICKEY;
Jeff Johnson295189b2012-06-20 16:38:30 -07005407 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005408
5409 else if(wrqu->param.value & IW_AUTH_CIPHER_WEP104)
5410 {
Jeff Johnson295189b2012-06-20 16:38:30 -07005411 /*Dynamic WEP keys won't work with shared keys*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005412 if( ( IW_AUTH_KEY_MGMT_802_1X
5413 == (pWextState->authKeyMgmt & IW_AUTH_KEY_MGMT_802_1X))
Jeff Johnson295189b2012-06-20 16:38:30 -07005414 && (eCSR_AUTH_TYPE_OPEN_SYSTEM == pHddStaCtx->conn_info.authType))
5415 {
5416 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104;
5417 }
5418 else
5419 {
5420 mcEncryptionType = eCSR_ENCRYPT_TYPE_WEP104_STATICKEY;
5421 }
5422 }
5423 else {
Shailender Karmuchia734f332013-04-19 14:02:48 -07005424
Jeff Johnson295189b2012-06-20 16:38:30 -07005425 hddLog(LOGW, "%s value %d UNKNOWN IW_AUTH_CIPHER",
Shailender Karmuchia734f332013-04-19 14:02:48 -07005426 __func__, wrqu->param.value);
Jeff Johnson295189b2012-06-20 16:38:30 -07005427 return -EINVAL;
5428 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005429
Jeff Johnson295189b2012-06-20 16:38:30 -07005430 pRoamProfile->mcEncryptionType.numEntries = 1;
5431 pRoamProfile->mcEncryptionType.encryptionType[0] = mcEncryptionType;
5432 }
5433 break;
5434
5435 case IW_AUTH_80211_AUTH_ALG:
5436 {
5437 /*Save the auth algo here and set auth type to SME Roam profile
5438 in the iw_set_ap_address*/
Shailender Karmuchia734f332013-04-19 14:02:48 -07005439 if( wrqu->param.value & IW_AUTH_ALG_OPEN_SYSTEM)
Jeff Johnson295189b2012-06-20 16:38:30 -07005440 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
Shailender Karmuchia734f332013-04-19 14:02:48 -07005441
Jeff Johnson295189b2012-06-20 16:38:30 -07005442 else if(wrqu->param.value & IW_AUTH_ALG_SHARED_KEY)
5443 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_SHARED_KEY;
5444
5445 else if(wrqu->param.value & IW_AUTH_ALG_LEAP)
5446 /*Not supported*/
5447 pHddStaCtx->conn_info.authType = eCSR_AUTH_TYPE_OPEN_SYSTEM;
5448 pWextState->roamProfile.AuthType.authType[0] = pHddStaCtx->conn_info.authType;
5449 }
5450 break;
5451
5452 case IW_AUTH_KEY_MGMT:
5453 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005454#ifdef FEATURE_WLAN_ESE
Jeff Johnson295189b2012-06-20 16:38:30 -07005455#define IW_AUTH_KEY_MGMT_CCKM 8 /* Should be in linux/wireless.h */
5456 /*Check for CCKM AKM type */
5457 if ( wrqu->param.value & IW_AUTH_KEY_MGMT_CCKM) {
Arif Hussain6d2a3322013-11-17 19:50:10 -08005458 hddLog(VOS_TRACE_LEVEL_INFO,"%s: CCKM AKM Set %d",
5459 __func__, wrqu->param.value);
Shailender Karmuchia734f332013-04-19 14:02:48 -07005460 /* Set the CCKM bit in authKeyMgmt */
5461 /* Right now, this breaks all ref to authKeyMgmt because our
5462 * code doesn't realize it is a "bitfield"
Jeff Johnson295189b2012-06-20 16:38:30 -07005463 */
5464 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_CCKM;
5465 /*Set the key management to 802.1X*/
5466 //pWextState->authKeyMgmt = IW_AUTH_KEY_MGMT_802_1X;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005467 pWextState->isESEConnection = eANI_BOOLEAN_TRUE;
Jeff Johnson295189b2012-06-20 16:38:30 -07005468 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5469 pWextState->collectedAuthType = eCSR_AUTH_TYPE_CCKM_RSN;
5470 } else if ( wrqu->param.value & IW_AUTH_KEY_MGMT_PSK) {
5471 /*Save the key management*/
5472 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_PSK;
5473 //pWextState->authKeyMgmt = wrqu->param.value;
5474 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5475 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
5476 } else if (!( wrqu->param.value & IW_AUTH_KEY_MGMT_802_1X)) {
5477 pWextState->collectedAuthType = eCSR_AUTH_TYPE_NONE; //eCSR_AUTH_TYPE_WPA_NONE
5478 /*Save the key management anyway*/
5479 pWextState->authKeyMgmt = wrqu->param.value;
5480 } else { // It must be IW_AUTH_KEY_MGMT_802_1X
5481 /*Save the key management*/
5482 pWextState->authKeyMgmt |= IW_AUTH_KEY_MGMT_802_1X;
5483 //pWextState->authKeyMgmt = wrqu->param.value;
5484 //This is test code. I need to actually KNOW whether this is an RSN Assoc or WPA.
5485 pWextState->collectedAuthType = eCSR_AUTH_TYPE_RSN;
5486 }
5487#else
5488 /*Save the key management*/
5489 pWextState->authKeyMgmt = wrqu->param.value;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005490#endif /* FEATURE_WLAN_ESE */
Jeff Johnson295189b2012-06-20 16:38:30 -07005491 }
5492 break;
5493
5494 case IW_AUTH_TKIP_COUNTERMEASURES:
5495 {
5496 if(wrqu->param.value) {
5497 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5498 "Counter Measure started %d", wrqu->param.value);
5499 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STARTED;
5500 }
5501 else {
5502 hddLog(VOS_TRACE_LEVEL_INFO_HIGH,
5503 "Counter Measure stopped=%d", wrqu->param.value);
5504 pWextState->mTKIPCounterMeasures = TKIP_COUNTER_MEASURE_STOPED;
5505 }
5506 }
5507 break;
5508 case IW_AUTH_DROP_UNENCRYPTED:
5509 case IW_AUTH_WPA_ENABLED:
5510 case IW_AUTH_RX_UNENCRYPTED_EAPOL:
5511 case IW_AUTH_ROAMING_CONTROL:
5512 case IW_AUTH_PRIVACY_INVOKED:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005513
Jeff Johnson295189b2012-06-20 16:38:30 -07005514 default:
Shailender Karmuchia734f332013-04-19 14:02:48 -07005515
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005516 hddLog(LOGW, "%s called with unsupported auth type %d", __func__,
Jeff Johnson295189b2012-06-20 16:38:30 -07005517 wrqu->param.flags & IW_AUTH_INDEX);
5518 break;
5519 }
Shailender Karmuchia734f332013-04-19 14:02:48 -07005520
Jeff Johnson295189b2012-06-20 16:38:30 -07005521 EXIT();
5522 return 0;
5523}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305524
5525int iw_set_auth(struct net_device *dev, struct iw_request_info *info,
5526 union iwreq_data *wrqu, char *extra)
5527{
5528 int ret;
5529
5530 vos_ssr_protect(__func__);
5531 ret = __iw_set_auth(dev, info, wrqu, extra);
5532 vos_ssr_unprotect(__func__);
5533
5534 return ret;
5535}
5536
Jeff Johnson295189b2012-06-20 16:38:30 -07005537/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005538
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305539 \brief __iw_get_auth() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005540 This function returns the auth type to the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005541
Jeff Johnson295189b2012-06-20 16:38:30 -07005542 \param - dev - Pointer to the net device.
5543 - info - Pointer to the iw_request_info.
5544 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005545 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005546 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005547
Jeff Johnson295189b2012-06-20 16:38:30 -07005548 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305549int __iw_get_auth(struct net_device *dev,struct iw_request_info *info,
5550 union iwreq_data *wrqu,char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005551{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305552 hdd_adapter_t* pAdapter;
5553 hdd_wext_state_t *pWextState;
5554 tCsrRoamProfile *pRoamProfile;
5555 hdd_context_t *pHddCtx;
5556 int ret = 0;
5557
Jeff Johnson295189b2012-06-20 16:38:30 -07005558 ENTER();
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005559
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305560 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5561 if (NULL == pAdapter)
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005562 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305563 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5564 "%s: Adapter is NULL",__func__);
5565 return -EINVAL;
Sameer Thalappil75ea31a2013-02-21 19:38:16 -08005566 }
5567
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305568 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5569 ret = wlan_hdd_validate_context(pHddCtx);
5570 if (0 != ret)
5571 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305572 return ret;
5573 }
5574
5575 pWextState = WLAN_HDD_GET_WEXT_STATE_PTR(pAdapter);
5576 if (NULL == pWextState)
5577 {
5578 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5579 "%s: pWextState is NULL",__func__);
5580 return -EINVAL;
5581 }
5582 pRoamProfile = &pWextState->roamProfile;
5583
Jeff Johnson295189b2012-06-20 16:38:30 -07005584 switch(pRoamProfile->negotiatedAuthType)
5585 {
5586 case eCSR_AUTH_TYPE_WPA_NONE:
5587 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5588 wrqu->param.value = IW_AUTH_WPA_VERSION_DISABLED;
5589 break;
5590 case eCSR_AUTH_TYPE_WPA:
5591 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5592 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA;
5593 break;
5594#ifdef WLAN_FEATURE_VOWIFI_11R
5595 case eCSR_AUTH_TYPE_FT_RSN:
5596#endif
5597 case eCSR_AUTH_TYPE_RSN:
5598 wrqu->param.flags = IW_AUTH_WPA_VERSION;
5599 wrqu->param.value = IW_AUTH_WPA_VERSION_WPA2;
5600 break;
5601 case eCSR_AUTH_TYPE_OPEN_SYSTEM:
5602 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5603 break;
5604 case eCSR_AUTH_TYPE_SHARED_KEY:
5605 wrqu->param.value = IW_AUTH_ALG_SHARED_KEY;
5606 break;
5607 case eCSR_AUTH_TYPE_UNKNOWN:
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005608 hddLog(LOG1,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005609 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5610 break;
5611 case eCSR_AUTH_TYPE_AUTOSWITCH:
5612 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5613 break;
5614 case eCSR_AUTH_TYPE_WPA_PSK:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305615 hddLog(LOG1,"%s called with WPA PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005616 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5617 return -EIO;
5618#ifdef WLAN_FEATURE_VOWIFI_11R
5619 case eCSR_AUTH_TYPE_FT_RSN_PSK:
5620#endif
5621 case eCSR_AUTH_TYPE_RSN_PSK:
Chet Lanctot186b5732013-03-18 10:26:30 -07005622#ifdef WLAN_FEATURE_11W
5623 case eCSR_AUTH_TYPE_RSN_PSK_SHA256:
Abhishek Singhae408032014-09-25 17:22:04 +05305624 case eCSR_AUTH_TYPE_RSN_8021X_SHA256:
Chet Lanctot186b5732013-03-18 10:26:30 -07005625#endif
Agarwal Ashish971c2882013-10-30 20:11:12 +05305626 hddLog(LOG1,"%s called with RSN PSK auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005627 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5628 return -EIO;
5629 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305630 hddLog(LOGE,"%s called with unknown auth type", __func__);
Jeff Johnson295189b2012-06-20 16:38:30 -07005631 wrqu->param.value = IW_AUTH_ALG_OPEN_SYSTEM;
5632 return -EIO;
5633 }
5634 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_PAIRWISE))
5635 {
5636 switch(pRoamProfile->negotiatedUCEncryptionType)
5637 {
5638 case eCSR_ENCRYPT_TYPE_NONE:
5639 wrqu->param.value = IW_AUTH_CIPHER_NONE;
5640 break;
5641 case eCSR_ENCRYPT_TYPE_WEP40:
5642 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5643 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
5644 break;
5645 case eCSR_ENCRYPT_TYPE_TKIP:
5646 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
5647 break;
5648 case eCSR_ENCRYPT_TYPE_WEP104:
5649 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5650 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
5651 break;
5652 case eCSR_ENCRYPT_TYPE_AES:
5653 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
5654 break;
5655 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305656 hddLog(LOG1, "%s called with unknown auth type %d ",
5657 __func__, pRoamProfile->negotiatedUCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07005658 return -EIO;
5659 }
5660 }
5661
Shailender Karmuchia734f332013-04-19 14:02:48 -07005662 if(((wrqu->param.flags & IW_AUTH_INDEX) == IW_AUTH_CIPHER_GROUP))
Jeff Johnson295189b2012-06-20 16:38:30 -07005663 {
5664 switch(pRoamProfile->negotiatedMCEncryptionType)
5665 {
5666 case eCSR_ENCRYPT_TYPE_NONE:
5667 wrqu->param.value = IW_AUTH_CIPHER_NONE;
5668 break;
5669 case eCSR_ENCRYPT_TYPE_WEP40:
5670 case eCSR_ENCRYPT_TYPE_WEP40_STATICKEY:
5671 wrqu->param.value = IW_AUTH_CIPHER_WEP40;
5672 break;
5673 case eCSR_ENCRYPT_TYPE_TKIP:
5674 wrqu->param.value = IW_AUTH_CIPHER_TKIP;
5675 break;
5676 case eCSR_ENCRYPT_TYPE_WEP104:
5677 case eCSR_ENCRYPT_TYPE_WEP104_STATICKEY:
5678 wrqu->param.value = IW_AUTH_CIPHER_WEP104;
5679 break;
5680 case eCSR_ENCRYPT_TYPE_AES:
5681 wrqu->param.value = IW_AUTH_CIPHER_CCMP;
5682 break;
5683 default:
Agarwal Ashish971c2882013-10-30 20:11:12 +05305684 hddLog(LOG1, "%s called with unknown auth type %d ",
5685 __func__, pRoamProfile->negotiatedMCEncryptionType);
Jeff Johnson295189b2012-06-20 16:38:30 -07005686 return -EIO;
5687 }
5688 }
5689
5690 hddLog(LOG1, "%s called with auth type %d",
Madan Mohan Koyyalamudi87054ba2012-11-02 13:24:12 -07005691 __func__, pRoamProfile->AuthType.authType[0]);
Jeff Johnson295189b2012-06-20 16:38:30 -07005692 EXIT();
5693 return 0;
5694}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305695
5696int iw_get_auth(struct net_device *dev,struct iw_request_info *info,
5697 union iwreq_data *wrqu,char *extra)
5698{
5699 int ret;
5700
5701 vos_ssr_protect(__func__);
5702 ret = __iw_get_auth(dev, info, wrqu, extra);
5703 vos_ssr_unprotect(__func__);
5704
5705 return ret;
5706}
5707
Jeff Johnson295189b2012-06-20 16:38:30 -07005708/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005709
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305710 \brief __iw_set_ap_address() -
Shailender Karmuchia734f332013-04-19 14:02:48 -07005711 This function calls the sme_RoamConnect function to associate
Jeff Johnson295189b2012-06-20 16:38:30 -07005712 to the AP with the specified BSSID received from the wpa_supplicant.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005713
Jeff Johnson295189b2012-06-20 16:38:30 -07005714 \param - dev - Pointer to the net device.
5715 - info - Pointer to the iw_request_info.
5716 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005717 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005718 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005719
Jeff Johnson295189b2012-06-20 16:38:30 -07005720 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305721int __iw_set_ap_address(struct net_device *dev,
5722 struct iw_request_info *info,
5723 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005724{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305725 hdd_station_ctx_t *pHddStaCtx;
5726 hdd_adapter_t *pAdapter;
5727 hdd_context_t *pHddCtx;
5728 v_U8_t *pMacAddress = NULL;
5729 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305730
Jeff Johnson295189b2012-06-20 16:38:30 -07005731 ENTER();
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305732
5733 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5734 if (NULL == pAdapter)
5735 {
5736 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5737 "%s: Adapter is NULL", __func__);
5738 return -EINVAL;
5739 }
5740 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5741 ret = wlan_hdd_validate_context(pHddCtx);
5742 if (0 != ret)
5743 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305744 return ret;
5745 }
5746 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5747 if (NULL == pHddStaCtx)
5748 {
5749 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_ERROR,
5750 "%s: pHddStaCtx is NULL", __func__);
5751 return -EINVAL;
5752 }
5753
Jeff Johnson295189b2012-06-20 16:38:30 -07005754 pMacAddress = (v_U8_t*) wrqu->ap_addr.sa_data;
Arif Hussain24bafea2013-11-15 15:10:03 -08005755 VOS_TRACE(VOS_MODULE_ID_HDD, VOS_TRACE_LEVEL_INFO, "%s "MAC_ADDRESS_STR,
5756 __func__, MAC_ADDR_ARRAY(pMacAddress));
Jeff Johnson295189b2012-06-20 16:38:30 -07005757 vos_mem_copy( pHddStaCtx->conn_info.bssId, pMacAddress, sizeof( tCsrBssid ));
Shailender Karmuchia734f332013-04-19 14:02:48 -07005758
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305759 EXIT();
Jeff Johnson295189b2012-06-20 16:38:30 -07005760 return 0;
5761}
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305762
5763int iw_set_ap_address(struct net_device *dev,
5764 struct iw_request_info *info,
5765 union iwreq_data *wrqu, char *extra)
5766{
5767 int ret;
5768
5769 vos_ssr_protect(__func__);
5770 ret = __iw_set_ap_address(dev, info, wrqu, extra);
5771 vos_ssr_unprotect(__func__);
5772
5773 return ret;
5774}
5775
Jeff Johnson295189b2012-06-20 16:38:30 -07005776/**---------------------------------------------------------------------------
Shailender Karmuchia734f332013-04-19 14:02:48 -07005777
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305778 \brief __iw_get_ap_address() -
Jeff Johnson295189b2012-06-20 16:38:30 -07005779 This function returns the BSSID to the wpa_supplicant
5780 \param - dev - Pointer to the net device.
5781 - info - Pointer to the iw_request_info.
5782 - wrqu - Pointer to the iwreq_data.
Shailender Karmuchia734f332013-04-19 14:02:48 -07005783 - extra - Pointer to the data.
Jeff Johnson295189b2012-06-20 16:38:30 -07005784 \return - 0 for success, non zero for failure
Shailender Karmuchia734f332013-04-19 14:02:48 -07005785
Jeff Johnson295189b2012-06-20 16:38:30 -07005786 --------------------------------------------------------------------------*/
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305787int __iw_get_ap_address(struct net_device *dev,
5788 struct iw_request_info *info,
5789 union iwreq_data *wrqu, char *extra)
Jeff Johnson295189b2012-06-20 16:38:30 -07005790{
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305791 hdd_station_ctx_t *pHddStaCtx;
5792 hdd_adapter_t *pAdapter;
5793 hdd_context_t *pHddCtx;
5794 int ret = 0;
Hanumantha Reddy Pothula7dc0e6c2015-03-06 15:11:16 +05305795
Jeff Johnson295189b2012-06-20 16:38:30 -07005796 ENTER();
5797
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305798 pAdapter = WLAN_HDD_GET_PRIV_PTR(dev);
5799 if (NULL == pAdapter)
5800 {
5801 hddLog(VOS_TRACE_LEVEL_ERROR,
5802 "%s: Adapter is NULL", __func__);
5803 return -EINVAL;
5804 }
5805 pHddCtx = WLAN_HDD_GET_CTX(pAdapter);
5806 ret = wlan_hdd_validate_context(pHddCtx);
5807 if (0 != ret)
5808 {
Mahesh A Saptasagar153c4662015-02-06 12:13:08 +05305809 return ret;
5810 }
5811 pHddStaCtx = WLAN_HDD_GET_STATION_CTX_PTR(pAdapter);
5812 if (NULL == pHddStaCtx)
5813 {
5814 hddLog(VOS_TRACE_LEVEL_ERROR,
5815 "%s: pHddStaCtx is NULL", __func__);
5816 return -EINVAL;
5817 }
5818
Jeff Johnson295189b2012-06-20 16:38:30 -07005819 if ((pHddStaCtx->conn_info.connState == eConnectionState_Associated) ||
5820 (eConnectionState_IbssConnected == pHddStaCtx->conn_info.connState))
5821 {
Jeff Johnson4416a782013-03-25 14:17:50 -07005822 memcpy(wrqu->ap_addr.sa_data,pHddStaCtx->conn_info.bssId,ETH_ALEN);
Jeff Johnson295189b2012-06-20 16:38:30 -07005823 }
5824 else
5825 {
5826 memset(wrqu->ap_addr.sa_data,0,sizeof(wrqu->ap_addr.sa_data));
5827 }
5828 EXIT();
5829 return 0;
5830}
Jeff Johnsond13512a2012-07-17 11:42:19 -07005831
Mahesh A Saptasagard68eb282014-12-17 14:20:19 +05305832int iw_get_ap_address(struct net_device *dev,
5833 struct iw_request_info *info,
5834 union iwreq_data *wrqu, char *extra)
5835{
5836 int ret;
5837
5838 vos_ssr_protect(__func__);
5839 ret = __iw_get_ap_address(dev, info, wrqu, extra);
5840 vos_ssr_unprotect(__func__);
5841
5842 return ret;
5843}
5844
Chet Lanctot186b5732013-03-18 10:26:30 -07005845#ifdef WLAN_FEATURE_11W
5846/**---------------------------------------------------------------------------
5847
5848 \brief hdd_indicateUnprotMgmtFrame -
5849 This function forwards the unprotected management frame to the supplicant
5850 \param - pAdapter - Pointer to HDD adapter
5851 - nFrameLength - Length of the unprotected frame being passed
5852 - pbFrames - Pointer to the frame buffer
5853 - frameType - 802.11 frame type
5854 \return - nothing
5855
5856 --------------------------------------------------------------------------*/
5857void hdd_indicateUnprotMgmtFrame( hdd_adapter_t *pAdapter,
5858 tANI_U32 nFrameLength,
5859 tANI_U8* pbFrames,
5860 tANI_U8 frameType )
5861{
5862 tANI_U8 type = 0;
5863 tANI_U8 subType = 0;
5864
5865 hddLog(VOS_TRACE_LEVEL_INFO, "%s: Frame Type = %d Frame Length = %d",
5866 __func__, frameType, nFrameLength);
5867
5868 /* Sanity Checks */
5869 if (NULL == pAdapter)
5870 {
5871 hddLog( LOGE, FL("pAdapter is NULL"));
5872 return;
5873 }
5874
5875 if (NULL == pAdapter->dev)
5876 {
5877 hddLog( LOGE, FL("pAdapter->dev is NULL"));
5878 return;
5879 }
5880
5881 if (WLAN_HDD_ADAPTER_MAGIC != pAdapter->magic)
5882 {
5883 hddLog( LOGE, FL("pAdapter has invalid magic"));
5884 return;
5885 }
5886
5887 if( !nFrameLength )
5888 {
5889 hddLog( LOGE, FL("Frame Length is Invalid ZERO"));
5890 return;
5891 }
5892
5893 if (NULL == pbFrames) {
5894 hddLog( LOGE, FL("pbFrames is NULL"));
5895 return;
5896 }
5897
5898 type = WLAN_HDD_GET_TYPE_FRM_FC(pbFrames[0]);
5899 subType = WLAN_HDD_GET_SUBTYPE_FRM_FC(pbFrames[0]);
5900
5901 /* Get pAdapter from Destination mac address of the frame */
5902 if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DISASSOC)
5903 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305904#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5905 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5906#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005907 cfg80211_send_unprot_disassoc(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305908#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005909 pAdapter->hdd_stats.hddPmfStats.numUnprotDisassocRx++;
5910 }
5911 else if (type == SIR_MAC_MGMT_FRAME && subType == SIR_MAC_MGMT_DEAUTH)
5912 {
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305913#if (LINUX_VERSION_CODE >= KERNEL_VERSION(3, 11, 0))
5914 cfg80211_rx_unprot_mlme_mgmt(pAdapter->dev, pbFrames, nFrameLength);
5915#else
Chet Lanctot186b5732013-03-18 10:26:30 -07005916 cfg80211_send_unprot_deauth(pAdapter->dev, pbFrames, nFrameLength);
Anand N Sunkade9adb1b2015-07-29 09:56:45 +05305917#endif
Chet Lanctot186b5732013-03-18 10:26:30 -07005918 pAdapter->hdd_stats.hddPmfStats.numUnprotDeauthRx++;
5919 }
5920 else
5921 {
5922 hddLog( LOGE, FL("Frame type %d and subtype %d are not valid"), type, subType);
5923 return;
5924 }
5925}
5926#endif
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005927
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005928#if defined (FEATURE_WLAN_ESE) && defined(FEATURE_WLAN_ESE_UPLOAD)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005929void hdd_indicateTsmIe(hdd_adapter_t *pAdapter, tANI_U8 tid,
5930 tANI_U8 state,
5931 tANI_U16 measInterval )
5932{
5933 union iwreq_data wrqu;
5934 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005935 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005936
5937 if (NULL == pAdapter)
5938 return;
5939
5940 // create the event
5941 memset(&wrqu, '\0', sizeof(wrqu));
5942 memset(buf, '\0', sizeof(buf));
5943
5944 hddLog(VOS_TRACE_LEVEL_INFO, "TSM Ind tid(%d) state(%d) MeasInt(%d)",
5945 tid, state, measInterval);
5946
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005947 nBytes = snprintf(buf, IW_CUSTOM_MAX, "TSMIE=%d:%d:%d",tid,state,measInterval);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005948
5949 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005950 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005951 // send the event
5952 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5953}
5954
5955void hdd_indicateCckmPreAuth(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
5956{
5957 union iwreq_data wrqu;
5958 char buf[IW_CUSTOM_MAX + 1];
5959 char *pos = buf;
5960 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
5961
5962 if ((NULL == pAdapter) || (NULL == pRoamInfo))
5963 return;
5964
5965 // create the event
5966 memset(&wrqu, '\0', sizeof(wrqu));
5967 memset(buf, '\0', sizeof(buf));
5968
5969 /* Timestamp0 is lower 32 bits and Timestamp1 is upper 32 bits */
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05305970 hddLog(VOS_TRACE_LEVEL_INFO, "CCXPREAUTHNOTIFY=%02x:%02x:%02x:%02x:%02x:%02x %u:%u",
5971 pRoamInfo->bssid[0], pRoamInfo->bssid[1], pRoamInfo->bssid[2],
5972 pRoamInfo->bssid[3], pRoamInfo->bssid[4], pRoamInfo->bssid[5],
5973 pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005974
5975 nBytes = snprintf(pos, freeBytes, "CCXPREAUTHNOTIFY=");
5976 pos += nBytes;
5977 freeBytes -= nBytes;
5978
5979 vos_mem_copy(pos, pRoamInfo->bssid, WNI_CFG_BSSID_LEN);
5980 pos += WNI_CFG_BSSID_LEN;
5981 freeBytes -= WNI_CFG_BSSID_LEN;
5982
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005983 nBytes = snprintf(pos, freeBytes, " %u:%u", pRoamInfo->timestamp[0], pRoamInfo->timestamp[1]);
5984 freeBytes -= nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005985
5986 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005987 wrqu.data.length = (IW_CUSTOM_MAX - freeBytes);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005988
5989 // send the event
5990 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
5991}
5992
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08005993void hdd_indicateEseAdjApRepInd(hdd_adapter_t *pAdapter, tCsrRoamInfo *pRoamInfo)
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005994{
5995 union iwreq_data wrqu;
5996 char buf[IW_CUSTOM_MAX + 1];
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08005997 int nBytes = 0;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07005998
5999 if ((NULL == pAdapter) || (NULL == pRoamInfo))
6000 return;
6001
6002 // create the event
6003 memset(&wrqu, '\0', sizeof(wrqu));
6004 memset(buf, '\0', sizeof(buf));
6005
6006 hddLog(VOS_TRACE_LEVEL_INFO, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
6007
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006008 nBytes = snprintf(buf, IW_CUSTOM_MAX, "CCXADJAPREP=%u", pRoamInfo->tsmRoamDelay);
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006009
6010 wrqu.data.pointer = buf;
Varun Reddy Yeturudf0e7a72013-12-05 12:12:23 -08006011 wrqu.data.length = nBytes;
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006012
6013 // send the event
6014 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6015}
6016
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07006017void hdd_indicateEseBcnReportNoResults(const hdd_adapter_t *pAdapter,
6018 const tANI_U16 measurementToken,
6019 const tANI_BOOLEAN flag,
6020 const tANI_U8 numBss)
6021{
6022 union iwreq_data wrqu;
6023 char buf[IW_CUSTOM_MAX];
6024 char *pos = buf;
6025 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6026
6027 memset(&wrqu, '\0', sizeof(wrqu));
6028 memset(buf, '\0', sizeof(buf));
6029
6030 hddLog(VOS_TRACE_LEVEL_INFO, FL("CCXBCNREP=%d %d %d"), measurementToken, flag,
6031 numBss);
6032
6033 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d", measurementToken,
6034 flag, numBss);
6035
6036 wrqu.data.pointer = buf;
6037 wrqu.data.length = nBytes;
6038 // send the event
6039 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6040}
6041
6042
6043static void hdd_indicateEseBcnReportInd(const hdd_adapter_t *pAdapter,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006044 const tCsrRoamInfo *pRoamInfo)
6045{
6046 union iwreq_data wrqu;
6047 char buf[IW_CUSTOM_MAX + 1];
6048 char *pos = buf;
6049 int nBytes = 0, freeBytes = IW_CUSTOM_MAX;
6050 tANI_U8 i = 0, len = 0;
6051 tANI_U8 tot_bcn_ieLen = 0; /* total size of the beacon report data */
6052 tANI_U8 lastSent = 0, sendBss = 0;
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006053 int bcnRepFieldSize = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[0].bcnReportFields);
6054 tANI_U8 ieLenByte = 1;
6055 /* CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes */
6056#define ESEBCNREPHEADER_LEN (18)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006057
6058 if ((NULL == pAdapter) || (NULL == pRoamInfo))
6059 return;
6060
6061 /* Custom event can pass maximum of 256 bytes of data,
6062 based on the IE len we need to identify how many BSS info can
6063 be filled in to custom event data */
6064 /*
6065 meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len bcn_rep_data
6066 bcn_rep_data will have bcn_rep_fields,ie_len,ie without any spaces
6067 CCXBCNREP=meas_tok<sp>flag<sp>no_of_bss<sp>tot_bcn_ie_len = 18 bytes
6068 */
6069
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006070 if ((pRoamInfo->pEseBcnReportRsp->flag >> 1) && (!pRoamInfo->pEseBcnReportRsp->numBss))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006071 {
6072 hddLog(VOS_TRACE_LEVEL_INFO, "Measurement Done but no scan results");
6073 /* If the measurement is none and no scan results found,
6074 indicate the supplicant about measurement done */
Srinivas Girigowda0c6d7fe2014-05-28 18:18:10 -07006075 hdd_indicateEseBcnReportNoResults(pAdapter,
6076 pRoamInfo->pEseBcnReportRsp->measurementToken,
6077 pRoamInfo->pEseBcnReportRsp->flag,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006078 pRoamInfo->pEseBcnReportRsp->numBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006079 }
6080 else
6081 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006082 while (lastSent < pRoamInfo->pEseBcnReportRsp->numBss)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006083 {
6084 memset(&wrqu, '\0', sizeof(wrqu));
6085 memset(buf, '\0', sizeof(buf));
6086 tot_bcn_ieLen = 0;
6087 sendBss = 0;
6088 pos = buf;
6089 freeBytes = IW_CUSTOM_MAX;
6090
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006091 for (i = lastSent; i < pRoamInfo->pEseBcnReportRsp->numBss; i++)
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006092 {
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006093 len = bcnRepFieldSize + ieLenByte + pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen;
6094 if ((len + tot_bcn_ieLen) > (IW_CUSTOM_MAX - ESEBCNREPHEADER_LEN))
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006095 {
6096 break;
6097 }
6098 tot_bcn_ieLen += len;
6099 sendBss++;
6100 hddLog(VOS_TRACE_LEVEL_INFO, "i(%d) sizeof bcnReportFields(%d)"
6101 "IeLength(%d) Length of Ie(%d) totLen(%d)",
6102 i, bcnRepFieldSize, 1,
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006103 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i].ieLen,
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006104 tot_bcn_ieLen);
6105 }
6106
6107 hddLog(VOS_TRACE_LEVEL_INFO, "Sending %d BSS Info", sendBss);
6108 hddLog(VOS_TRACE_LEVEL_INFO, "CCXBCNREP=%d %d %d %d",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006109 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
6110 sendBss, tot_bcn_ieLen);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006111
6112 nBytes = snprintf(pos, freeBytes, "CCXBCNREP=%d %d %d ",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006113 pRoamInfo->pEseBcnReportRsp->measurementToken, pRoamInfo->pEseBcnReportRsp->flag,
6114 sendBss);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006115 pos += nBytes;
6116 freeBytes -= nBytes;
6117
6118 /* Copy total Beacon report data length */
6119 vos_mem_copy(pos, (char*)&tot_bcn_ieLen, sizeof(tot_bcn_ieLen));
6120 pos += sizeof(tot_bcn_ieLen);
6121 freeBytes -= sizeof(tot_bcn_ieLen);
6122
6123 for (i = 0; i < sendBss; i++)
6124 {
6125 hddLog(VOS_TRACE_LEVEL_INFO, "ChanNum(%d) Spare(%d) MeasDuration(%d)"
Arun Kumar Khandavallie8768212014-02-17 16:43:34 +05306126 " PhyType(%d) RecvSigPower(%d) ParentTSF(%u)"
6127 " TargetTSF[0](%u) TargetTSF[1](%u) BeaconInterval(%u)"
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006128 " CapabilityInfo(%d) BSSID(%02X:%02X:%02X:%02X:%02X:%02X)",
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006129 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ChanNum,
6130 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Spare,
6131 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.MeasDuration,
6132 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.PhyType,
6133 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.RecvSigPower,
6134 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.ParentTsf,
6135 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[0],
6136 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.TargetTsf[1],
6137 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.BcnInterval,
6138 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.CapabilityInfo,
6139 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[0],
6140 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[1],
6141 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[2],
6142 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[3],
6143 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[4],
6144 pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields.Bssid[5]);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006145
6146 /* bcn report fields are copied */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006147 len = sizeof(pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields);
6148 vos_mem_copy(pos, (char*)&pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].bcnReportFields, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006149 pos += len;
6150 freeBytes -= len;
6151
6152 /* Add 1 byte of ie len */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006153 len = pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].ieLen;
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006154 vos_mem_copy(pos, (char*)&len, sizeof(len));
6155 pos += sizeof(len);
6156 freeBytes -= sizeof(len);
6157
6158 /* copy IE from scan results */
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006159 vos_mem_copy(pos, (char*)pRoamInfo->pEseBcnReportRsp->bcnRepBssInfo[i+lastSent].pBuf, len);
Srinivas Girigowda91ccbe82013-11-10 16:37:38 -08006160 pos += len;
6161 freeBytes -= len;
6162 }
6163
6164 wrqu.data.pointer = buf;
6165 wrqu.data.length = strlen(buf);
6166
6167 // send the event
6168 wireless_send_event(pAdapter->dev, IWEVCUSTOM, &wrqu, buf);
6169 lastSent += sendBss;
6170 }
6171 }
6172}
6173
Varun Reddy Yeturu5d5e2c62014-02-27 13:31:29 -08006174#endif /* FEATURE_WLAN_ESE && FEATURE_WLAN_ESE_UPLOAD */
Srinivas Girigowda5cecb202013-10-08 09:13:25 -07006175
Vignesh Viswanathan36575f82018-06-14 16:52:21 +05306176hdd_adapter_t *hdd_get_sta_connection_in_progress(hdd_context_t *hdd_ctx)
6177{
6178 hdd_adapter_list_node_t *adapter_node = NULL, *next = NULL;
6179 hdd_adapter_t *adapter = NULL;
6180 VOS_STATUS status;
6181 hdd_station_ctx_t *hdd_sta_ctx;
6182
6183 if (!hdd_ctx) {
6184 hddLog(LOGE, FL("HDD context is NULL"));
6185 return NULL;
6186 }
6187
6188 status = hdd_get_front_adapter(hdd_ctx, &adapter_node);
6189 while (NULL != adapter_node && VOS_STATUS_SUCCESS == status) {
6190 adapter = adapter_node->pAdapter;
6191 if (!adapter)
6192 goto end;
6193
6194 if ((WLAN_HDD_INFRA_STATION == adapter->device_mode) ||
6195 (WLAN_HDD_P2P_CLIENT == adapter->device_mode) ||
6196 (WLAN_HDD_P2P_DEVICE == adapter->device_mode)) {
6197 hdd_sta_ctx = WLAN_HDD_GET_STATION_CTX_PTR(adapter);
6198 if (eConnectionState_Connecting ==
6199 hdd_sta_ctx->conn_info.connState) {
6200 hddLog(LOG1, FL("session_id %d: Connection is in progress"),
6201 adapter->sessionId);
6202 return adapter;
6203 } else if ((eConnectionState_Associated ==
6204 hdd_sta_ctx->conn_info.connState) &&
Vignesh Viswanathan0ac8e562018-06-14 17:24:10 +05306205 sme_is_sta_key_exchange_in_progress(
6206 hdd_ctx->hHal, adapter->sessionId)) {
Vignesh Viswanathan36575f82018-06-14 16:52:21 +05306207 hddLog(LOG1, FL("session_id %d: Key exchange is in progress"),
6208 adapter->sessionId);
6209 return adapter;
6210 }
6211 }
6212end:
6213 status = hdd_get_next_adapter(hdd_ctx, adapter_node, &next);
6214 adapter_node = next;
6215 }
6216 return NULL;
6217}
6218